-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to specify region because of the Hyphen #35
Comments
Hello, List rdb instances: api = API(base_url="https://api.scaleway.com", auth_token="your_token")
instances = api.query().rdb.v1.regions.__call__('fr-par').instances.get() The rdb product is regional, you can only use fr-par or nl-ams. |
adding this to improve the documentation would be nice |
Better, you can create your own from scaleway.apis import API
REGIONS = {
'fr-par': {
'url': 'https://api.scaleway.com/rdb/v1/regions/fr-par/',
},
'nl-ams': {
'url': 'https://api.scaleway.com/rdb/v1/regions/nl-ams/',
}
}
class RDBAPI(API):
def __init__(self, **kwargs):
region = kwargs.pop('region', None)
base_url = kwargs.pop('base_url', None)
assert region is None or base_url is None, \
"Specify either region or base_url, not both."
if base_url is None:
region = region or 'fr-par'
assert region in REGIONS, \
"'%s' is not a valid Scaleway region." % region
base_url = REGIONS.get(region)['url']
super(RDBAPI, self).__init__(base_url=base_url, **kwargs) Then use it as any other API: >>> rdb = RDBAPI(auth_token='xx', region='fr-par')
# or
>>> rdb = RDBAPI(auth_token='xx', region='nl-ams')
>>> rdb.query().instances.get()
{'instances': [], 'total_count': 0} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trying to list the RDB instances but I have difficulties to specify the region. That
-
Hyphen seems to be the problem, but I am not Python expert enough figure out how to escape is correctly.The text was updated successfully, but these errors were encountered: