|
1 | 1 | from requests import Session |
2 | 2 |
|
3 | | -HYPERNODE_API_URL = 'https://api.hypernode.com' |
| 3 | +HYPERNODE_API_URL = "https://api.hypernode.com" |
| 4 | + |
| 5 | +HYPERNODE_API_APP_FLAVOR_ENDPOINT = "/v2/app/{}/flavor/" |
4 | 6 |
|
5 | 7 |
|
6 | 8 | class HypernodeAPIPython: |
7 | 9 | def __init__(self, token, api_url=None): |
8 | 10 | self.session = Session() |
9 | 11 | self.token = token |
10 | 12 | self.api_url = api_url if api_url else HYPERNODE_API_URL |
11 | | - self.authorization_header = 'Token {}'.format(self.token) |
| 13 | + self.authorization_header = "Token {}".format(self.token) |
12 | 14 |
|
13 | 15 | def requests(self, method, path, *args, **kwargs): |
14 | | - kwargs.setdefault('headers', {}).update({ |
15 | | - 'Accept': 'application/json', |
16 | | - 'Authorization': self.authorization_header, |
17 | | - 'Accept-Language': 'en-US' |
18 | | - }) |
19 | | - return session.request(method, HYPERNODE_API_URL.rstrip('/') + path, *args, **kwargs) |
| 16 | + kwargs.setdefault("headers", {}).update( |
| 17 | + { |
| 18 | + "Accept": "application/json", |
| 19 | + "Authorization": self.authorization_header, |
| 20 | + "Accept-Language": "en-US", |
| 21 | + } |
| 22 | + ) |
| 23 | + return self.session.request( |
| 24 | + method, HYPERNODE_API_URL.rstrip("/") + path, *args, **kwargs |
| 25 | + ) |
20 | 26 |
|
21 | 27 | def get_app_flavor(self, app_name): |
22 | | - return self.requests('GET', HYPERNODE_API_APP_FLAVOR_ENDPOINT.format(app_name)) |
| 28 | + return self.requests("GET", HYPERNODE_API_APP_FLAVOR_ENDPOINT.format(app_name)) |
0 commit comments