Skip to content

Commit db1016c

Browse files
committed
chore: update to API 0.29.0
1 parent 6e9e9ac commit db1016c

12 files changed

Lines changed: 416 additions & 10 deletions

lib/binarylane/api/server_actions/post_v2_servers_server_id_actions.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from binarylane.models.change_offsite_backup_location import ChangeOffsiteBackupLocation
2222
from binarylane.models.change_partner import ChangePartner
2323
from binarylane.models.change_port_blocking import ChangePortBlocking
24+
from binarylane.models.change_region import ChangeRegion
2425
from binarylane.models.change_reverse_name import ChangeReverseName
2526
from binarylane.models.change_separate_private_network_interface import ChangeSeparatePrivateNetworkInterface
2627
from binarylane.models.change_source_and_destination_check import ChangeSourceAndDestinationCheck
@@ -72,6 +73,7 @@ def _get_kwargs(
7273
"ChangeOffsiteBackupLocation",
7374
"ChangePartner",
7475
"ChangePortBlocking",
76+
"ChangeRegion",
7577
"ChangeReverseName",
7678
"ChangeSeparatePrivateNetworkInterface",
7779
"ChangeSourceAndDestinationCheck",
@@ -148,6 +150,9 @@ def _get_kwargs(
148150
elif isinstance(json_body, ChangePortBlocking):
149151
json_json_body = json_body.to_dict()
150152

153+
elif isinstance(json_body, ChangeRegion):
154+
json_json_body = json_body.to_dict()
155+
151156
elif isinstance(json_body, ChangeReverseName):
152157
json_json_body = json_body.to_dict()
153158

@@ -298,6 +303,7 @@ def sync_detailed(
298303
"ChangeOffsiteBackupLocation",
299304
"ChangePartner",
300305
"ChangePortBlocking",
306+
"ChangeRegion",
301307
"ChangeReverseName",
302308
"ChangeSeparatePrivateNetworkInterface",
303309
"ChangeSourceAndDestinationCheck",
@@ -342,7 +348,7 @@ def sync_detailed(
342348
'ChangeAdvancedFirewallRules', 'ChangeBackupSchedule', 'ChangeIpv6',
343349
'ChangeIpv6ReverseNameservers', 'ChangeKernel', 'ChangeManageOffsiteBackupCopies',
344350
'ChangeNetwork', 'ChangeOffsiteBackupLocation', 'ChangePartner', 'ChangePortBlocking',
345-
'ChangeReverseName', 'ChangeSeparatePrivateNetworkInterface',
351+
'ChangeRegion', 'ChangeReverseName', 'ChangeSeparatePrivateNetworkInterface',
346352
'ChangeSourceAndDestinationCheck', 'ChangeThresholdAlerts', 'ChangeVpcIpv4',
347353
'CloneUsingBackup', 'DeleteDisk', 'DetachBackup', 'DisableBackups', 'DisableSelinux',
348354
'EnableBackups', 'EnableIpv6', 'IsRunning', 'PasswordReset', 'Ping', 'PowerCycle',
@@ -389,6 +395,7 @@ def sync(
389395
"ChangeOffsiteBackupLocation",
390396
"ChangePartner",
391397
"ChangePortBlocking",
398+
"ChangeRegion",
392399
"ChangeReverseName",
393400
"ChangeSeparatePrivateNetworkInterface",
394401
"ChangeSourceAndDestinationCheck",
@@ -433,7 +440,7 @@ def sync(
433440
'ChangeAdvancedFirewallRules', 'ChangeBackupSchedule', 'ChangeIpv6',
434441
'ChangeIpv6ReverseNameservers', 'ChangeKernel', 'ChangeManageOffsiteBackupCopies',
435442
'ChangeNetwork', 'ChangeOffsiteBackupLocation', 'ChangePartner', 'ChangePortBlocking',
436-
'ChangeReverseName', 'ChangeSeparatePrivateNetworkInterface',
443+
'ChangeRegion', 'ChangeReverseName', 'ChangeSeparatePrivateNetworkInterface',
437444
'ChangeSourceAndDestinationCheck', 'ChangeThresholdAlerts', 'ChangeVpcIpv4',
438445
'CloneUsingBackup', 'DeleteDisk', 'DetachBackup', 'DisableBackups', 'DisableSelinux',
439446
'EnableBackups', 'EnableIpv6', 'IsRunning', 'PasswordReset', 'Ping', 'PowerCycle',
@@ -473,6 +480,7 @@ async def asyncio_detailed(
473480
"ChangeOffsiteBackupLocation",
474481
"ChangePartner",
475482
"ChangePortBlocking",
483+
"ChangeRegion",
476484
"ChangeReverseName",
477485
"ChangeSeparatePrivateNetworkInterface",
478486
"ChangeSourceAndDestinationCheck",
@@ -517,7 +525,7 @@ async def asyncio_detailed(
517525
'ChangeAdvancedFirewallRules', 'ChangeBackupSchedule', 'ChangeIpv6',
518526
'ChangeIpv6ReverseNameservers', 'ChangeKernel', 'ChangeManageOffsiteBackupCopies',
519527
'ChangeNetwork', 'ChangeOffsiteBackupLocation', 'ChangePartner', 'ChangePortBlocking',
520-
'ChangeReverseName', 'ChangeSeparatePrivateNetworkInterface',
528+
'ChangeRegion', 'ChangeReverseName', 'ChangeSeparatePrivateNetworkInterface',
521529
'ChangeSourceAndDestinationCheck', 'ChangeThresholdAlerts', 'ChangeVpcIpv4',
522530
'CloneUsingBackup', 'DeleteDisk', 'DetachBackup', 'DisableBackups', 'DisableSelinux',
523531
'EnableBackups', 'EnableIpv6', 'IsRunning', 'PasswordReset', 'Ping', 'PowerCycle',
@@ -562,6 +570,7 @@ async def asyncio(
562570
"ChangeOffsiteBackupLocation",
563571
"ChangePartner",
564572
"ChangePortBlocking",
573+
"ChangeRegion",
565574
"ChangeReverseName",
566575
"ChangeSeparatePrivateNetworkInterface",
567576
"ChangeSourceAndDestinationCheck",
@@ -606,7 +615,7 @@ async def asyncio(
606615
'ChangeAdvancedFirewallRules', 'ChangeBackupSchedule', 'ChangeIpv6',
607616
'ChangeIpv6ReverseNameservers', 'ChangeKernel', 'ChangeManageOffsiteBackupCopies',
608617
'ChangeNetwork', 'ChangeOffsiteBackupLocation', 'ChangePartner', 'ChangePortBlocking',
609-
'ChangeReverseName', 'ChangeSeparatePrivateNetworkInterface',
618+
'ChangeRegion', 'ChangeReverseName', 'ChangeSeparatePrivateNetworkInterface',
610619
'ChangeSourceAndDestinationCheck', 'ChangeThresholdAlerts', 'ChangeVpcIpv4',
611620
'CloneUsingBackup', 'DeleteDisk', 'DetachBackup', 'DisableBackups', 'DisableSelinux',
612621
'EnableBackups', 'EnableIpv6', 'IsRunning', 'PasswordReset', 'Ping', 'PowerCycle',
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
from __future__ import annotations
2+
3+
from http import HTTPStatus
4+
from typing import Any, Dict, Optional, Union, cast
5+
6+
import httpx
7+
8+
from binarylane import errors
9+
from binarylane.client import Client
10+
from binarylane.models.action_response import ActionResponse
11+
from binarylane.models.change_region import ChangeRegion
12+
from binarylane.models.problem_details import ProblemDetails
13+
from binarylane.models.validation_problem_details import ValidationProblemDetails
14+
from binarylane.types import Response
15+
16+
17+
def _get_kwargs(
18+
server_id: int,
19+
*,
20+
client: Client,
21+
json_body: ChangeRegion,
22+
) -> Dict[str, Any]:
23+
url = "{}/v2/servers/{server_id}/actions#ChangeRegion".format(client.base_url, server_id=server_id)
24+
25+
headers: Dict[str, str] = client.get_headers()
26+
cookies: Dict[str, Any] = client.get_cookies()
27+
28+
json_json_body = json_body.to_dict()
29+
30+
return {
31+
"method": "post",
32+
"url": url,
33+
"headers": headers,
34+
"cookies": cookies,
35+
"timeout": client.get_timeout(),
36+
"json": json_json_body,
37+
}
38+
39+
40+
def _parse_response(
41+
*, client: Client, response: httpx.Response
42+
) -> Optional[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]:
43+
if response.status_code == HTTPStatus.OK:
44+
response_200 = ActionResponse.from_dict(response.json())
45+
46+
return response_200
47+
if response.status_code == HTTPStatus.ACCEPTED:
48+
response_202 = cast(Any, None)
49+
return response_202
50+
if response.status_code == HTTPStatus.BAD_REQUEST:
51+
response_400 = ValidationProblemDetails.from_dict(response.json())
52+
53+
return response_400
54+
if response.status_code == HTTPStatus.NOT_FOUND:
55+
response_404 = ProblemDetails.from_dict(response.json())
56+
57+
return response_404
58+
if response.status_code == HTTPStatus.UNAUTHORIZED:
59+
response_401 = cast(Any, None)
60+
return response_401
61+
if client.raise_on_unexpected_status:
62+
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
63+
else:
64+
return None
65+
66+
67+
def _build_response(
68+
*, client: Client, response: httpx.Response
69+
) -> Response[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]:
70+
return Response(
71+
status_code=HTTPStatus(response.status_code),
72+
content=response.content,
73+
headers=response.headers,
74+
parsed=_parse_response(client=client, response=response),
75+
)
76+
77+
78+
def sync_detailed(
79+
server_id: int,
80+
*,
81+
client: Client,
82+
json_body: ChangeRegion,
83+
) -> Response[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]:
84+
"""Change the Region of a Server
85+
86+
This is used to move a server to a different region.
87+
Please check our knowledge base article for the current requirements for servers to be able to move
88+
between regions.
89+
90+
91+
Args:
92+
server_id (int): The ID of the server on which the action should be performed.
93+
json_body (ChangeRegion): Change the Region of a Server
94+
95+
Raises:
96+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
97+
httpx.TimeoutException: If the request takes longer than Client.timeout.
98+
99+
Returns:
100+
Response[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]
101+
"""
102+
103+
kwargs = _get_kwargs(
104+
server_id=server_id,
105+
client=client,
106+
json_body=json_body,
107+
)
108+
109+
response = httpx.request(
110+
verify=client.verify_ssl,
111+
**kwargs,
112+
)
113+
114+
return _build_response(client=client, response=response)
115+
116+
117+
def sync(
118+
server_id: int,
119+
*,
120+
client: Client,
121+
json_body: ChangeRegion,
122+
) -> Optional[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]:
123+
"""Change the Region of a Server
124+
125+
This is used to move a server to a different region.
126+
Please check our knowledge base article for the current requirements for servers to be able to move
127+
between regions.
128+
129+
130+
Args:
131+
server_id (int): The ID of the server on which the action should be performed.
132+
json_body (ChangeRegion): Change the Region of a Server
133+
134+
Raises:
135+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
136+
httpx.TimeoutException: If the request takes longer than Client.timeout.
137+
138+
Returns:
139+
Response[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]
140+
"""
141+
142+
return sync_detailed(
143+
server_id=server_id,
144+
client=client,
145+
json_body=json_body,
146+
).parsed
147+
148+
149+
async def asyncio_detailed(
150+
server_id: int,
151+
*,
152+
client: Client,
153+
json_body: ChangeRegion,
154+
) -> Response[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]:
155+
"""Change the Region of a Server
156+
157+
This is used to move a server to a different region.
158+
Please check our knowledge base article for the current requirements for servers to be able to move
159+
between regions.
160+
161+
162+
Args:
163+
server_id (int): The ID of the server on which the action should be performed.
164+
json_body (ChangeRegion): Change the Region of a Server
165+
166+
Raises:
167+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
168+
httpx.TimeoutException: If the request takes longer than Client.timeout.
169+
170+
Returns:
171+
Response[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]
172+
"""
173+
174+
kwargs = _get_kwargs(
175+
server_id=server_id,
176+
client=client,
177+
json_body=json_body,
178+
)
179+
180+
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
181+
response = await _client.request(**kwargs)
182+
183+
return _build_response(client=client, response=response)
184+
185+
186+
async def asyncio(
187+
server_id: int,
188+
*,
189+
client: Client,
190+
json_body: ChangeRegion,
191+
) -> Optional[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]:
192+
"""Change the Region of a Server
193+
194+
This is used to move a server to a different region.
195+
Please check our knowledge base article for the current requirements for servers to be able to move
196+
between regions.
197+
198+
199+
Args:
200+
server_id (int): The ID of the server on which the action should be performed.
201+
json_body (ChangeRegion): Change the Region of a Server
202+
203+
Raises:
204+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
205+
httpx.TimeoutException: If the request takes longer than Client.timeout.
206+
207+
Returns:
208+
Response[Union[ActionResponse, Any, ProblemDetails, ValidationProblemDetails]]
209+
"""
210+
211+
return (
212+
await asyncio_detailed(
213+
server_id=server_id,
214+
client=client,
215+
json_body=json_body,
216+
)
217+
).parsed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from __future__ import annotations
2+
3+
from typing import Any, Dict, List, Type, TypeVar
4+
5+
import attr
6+
7+
from binarylane.models.change_region_type import ChangeRegionType
8+
9+
T = TypeVar("T", bound="ChangeRegion")
10+
11+
12+
@attr.s(auto_attribs=True)
13+
class ChangeRegion:
14+
"""Change the Region of a Server
15+
16+
Attributes:
17+
type (ChangeRegionType):
18+
region (str): The slug of the selected region.
19+
"""
20+
21+
type: ChangeRegionType
22+
region: str
23+
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
24+
25+
def to_dict(self) -> Dict[str, Any]:
26+
type = self.type.value
27+
28+
region = self.region
29+
30+
field_dict: Dict[str, Any] = {}
31+
field_dict.update(self.additional_properties)
32+
field_dict.update(
33+
{
34+
"type": type,
35+
"region": region,
36+
}
37+
)
38+
39+
return field_dict
40+
41+
@classmethod
42+
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
43+
d = src_dict.copy()
44+
type = ChangeRegionType(d.pop("type"))
45+
46+
region = d.pop("region")
47+
48+
change_region = cls(
49+
type=type,
50+
region=region,
51+
)
52+
53+
change_region.additional_properties = d
54+
return change_region
55+
56+
@property
57+
def additional_keys(self) -> List[str]:
58+
return list(self.additional_properties.keys())
59+
60+
def __getitem__(self, key: str) -> Any:
61+
return self.additional_properties[key]
62+
63+
def __setitem__(self, key: str, value: Any) -> None:
64+
self.additional_properties[key] = value
65+
66+
def __delitem__(self, key: str) -> None:
67+
del self.additional_properties[key]
68+
69+
def __contains__(self, key: str) -> bool:
70+
return key in self.additional_properties
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from __future__ import annotations
2+
3+
from enum import Enum
4+
5+
6+
class ChangeRegionType(str, Enum):
7+
CHANGE_REGION = "change_region"
8+
9+
def __str__(self) -> str:
10+
return str(self.value)

0 commit comments

Comments
 (0)