| Total Complexity | 4 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | # -*- coding: utf-8 -*- |
||
| 23 | class ComputeAPI(API): |
||
| 24 | """ The default region is par1 as it was the first availability zone |
||
| 25 | provided by Scaleway, but it could change in the future. |
||
| 26 | """ |
||
| 27 | |||
| 28 | def __init__(self, **kwargs): |
||
| 29 | region = kwargs.pop('region', None) |
||
| 30 | base_url = kwargs.pop('base_url', None) |
||
| 31 | |||
| 32 | assert region is None or base_url is None, \ |
||
| 33 | "Specify either region or base_url, not both." |
||
| 34 | |||
| 35 | if base_url is None: |
||
| 36 | region = region or 'par1' |
||
| 37 | |||
| 38 | assert region in REGIONS, \ |
||
| 39 | "'%s' is not a valid Scaleway region." % region |
||
| 40 | |||
| 41 | base_url = REGIONS.get(region)['url'] |
||
| 42 | |||
| 43 | super(ComputeAPI, self).__init__(base_url=base_url, **kwargs) |
||
| 44 |