Skip to content

Commit b3406b8

Browse files
author
Elias Nygren
committed
use API 1.2 to support IPv6 firewall rules
1 parent c77bead commit b3406b8

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def manager():
1111

1212

1313
class Mock():
14-
base_url = 'https://api.upcloud.com/1.1'
14+
base_url = 'https://api.upcloud.com/1.2'
1515

1616
@staticmethod
1717
def read_from_file(filename):

upcloud/base.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44

55
class BaseAPI(object):
66
api = "api.upcloud.com"
7-
api_v = "1.1"
7+
api_v = "1.2"
88

99
def __init__(self, token):
1010
self.token = token
1111

1212
"""
13-
Performs a request with a given body to a given endpoint in UpCloud's API.
13+
Performs a request with a given body to a given endpoint in UpCloud's API.
1414
Handles errors with __error_middleware.
1515
"""
1616
def request(self, method, endpoint, body=None):
1717
if(method not in {"GET", "POST", "PUT", "DELETE"}):
1818
raise Exception("Invalid/Forbidden HTTP method")
1919

2020
url = "/" + self.api_v + endpoint
21-
headers = {
22-
"Authorization": self.token,
21+
headers = {
22+
"Authorization": self.token,
2323
"Content-Type": "application/json"
2424
}
2525

@@ -32,21 +32,21 @@ def request(self, method, endpoint, body=None):
3232
if( res.text ):
3333
res_json = res.json()
3434
else: res_json = {}
35-
35+
3636
return self.__error_middleware(res, res_json)
3737

3838

3939
"""
40-
Performs a GET request to a given endpoint in UpCloud's API.
40+
Performs a GET request to a given endpoint in UpCloud's API.
4141
"""
4242
def get_request(self, endpoint):
43-
return self.request("GET", endpoint)
44-
43+
return self.request("GET", endpoint)
44+
4545
"""
46-
Performs a POST request to a given endpoint in UpCloud's API.
46+
Performs a POST request to a given endpoint in UpCloud's API.
4747
"""
4848
def post_request(self, endpoint, body=None):
49-
return self.request("POST", endpoint, body)
49+
return self.request("POST", endpoint, body)
5050

5151
"""
5252
Middleware that raises an exception when HTTP statuscode is an error code.

0 commit comments

Comments
 (0)