dwave.cloud.regions.get_regions#
- get_regions(config: ClientConfig | str | dict | None = None, *, refresh: bool = False, maxage: float | None = None, no_cache: bool = False) list[Region] [source]#
Retrieve available Solver API regions.
- Parameters:
config – Client configuration used for requests to Metadata API. Given as a
ClientConfig
object, it defines connection parameters in full. Raw config (full or partial) loaded from a file/env withload_config()
can be passed in as adict
and is validated asClientConfig
. A stringconfig
value is interpreted asmetadata_api_endpoint
.refresh – Force regions cache refresh.
maxage – Default maximum allowed age, in seconds, of cached regions metadata. Overridden by Metadata API cache control.
no_cache – Do not use cache.
- Returns:
List of
Region
objects, each describing one region.
Added in version 0.11.0: Added
get_regions()
.Changed in version 0.12.2:
maxage
parameter is now just a default value for the maximum allowed cache age, and it’s typically overridden by regions API’s cache control.Examples
Fetch available regions using the default client configuration:
>>> from dwave.cloud.regions import get_regions >>> get_regions() [Region(code='na-west-1', name='North America', endpoint='https://na-west-1.cloud.dwavesys.com/sapi/v2/'), Region(code='eu-central-1', name='Europe', endpoint='https://eu-central-1.cloud.dwavesys.com/sapi/v2/')]
Alternatively, to fetch available regions using an already configured client:
from dwave.cloud import Client from dwave.cloud.regions import get_regions with Client.from_config(...) as client: get_regions(config=client.config)