Skip to content

Commit 2dd30f3

Browse files
authored
feat(dedibox): provide ListIPv6Blocks endpoint (scaleway#1298)
1 parent 12629ae commit 2dd30f3

File tree

8 files changed

+340
-198
lines changed

8 files changed

+340
-198
lines changed

scaleway-async/scaleway_async/dedibox/v1/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
from .types import InstallPartition
105105
from .types import FailoverIP
106106
from .types import ListIPv6BlockSubnetsAvailableResponseSubnet
107+
from .types import IPv6Block
107108
from .types import InvoiceSummary
108109
from .types import RpnSanIp
109110
from .types import RefundSummary
@@ -158,19 +159,20 @@
158159
from .types import GetServerInstallRequest
159160
from .types import GetServerRequest
160161
from .types import GetServiceRequest
161-
from .types import IPv6Block
162162
from .types import IPv6BlockApiCreateIPv6BlockRequest
163163
from .types import IPv6BlockApiCreateIPv6BlockSubnetRequest
164164
from .types import IPv6BlockApiDeleteIPv6BlockRequest
165165
from .types import IPv6BlockApiGetIPv6BlockQuotasRequest
166166
from .types import IPv6BlockApiGetIPv6BlockRequest
167167
from .types import IPv6BlockApiListIPv6BlockSubnetsAvailableRequest
168+
from .types import IPv6BlockApiListIPv6BlocksRequest
168169
from .types import IPv6BlockApiUpdateIPv6BlockRequest
169170
from .types import InstallServerRequest
170171
from .types import Invoice
171172
from .types import ListFailoverIPsRequest
172173
from .types import ListFailoverIPsResponse
173174
from .types import ListIPv6BlockSubnetsAvailableResponse
175+
from .types import ListIPv6BlocksResponse
174176
from .types import ListInvoicesResponse
175177
from .types import ListIpsResponse
176178
from .types import ListOSRequest
@@ -374,6 +376,7 @@
374376
"InstallPartition",
375377
"FailoverIP",
376378
"ListIPv6BlockSubnetsAvailableResponseSubnet",
379+
"IPv6Block",
377380
"InvoiceSummary",
378381
"RpnSanIp",
379382
"RefundSummary",
@@ -428,19 +431,20 @@
428431
"GetServerInstallRequest",
429432
"GetServerRequest",
430433
"GetServiceRequest",
431-
"IPv6Block",
432434
"IPv6BlockApiCreateIPv6BlockRequest",
433435
"IPv6BlockApiCreateIPv6BlockSubnetRequest",
434436
"IPv6BlockApiDeleteIPv6BlockRequest",
435437
"IPv6BlockApiGetIPv6BlockQuotasRequest",
436438
"IPv6BlockApiGetIPv6BlockRequest",
437439
"IPv6BlockApiListIPv6BlockSubnetsAvailableRequest",
440+
"IPv6BlockApiListIPv6BlocksRequest",
438441
"IPv6BlockApiUpdateIPv6BlockRequest",
439442
"InstallServerRequest",
440443
"Invoice",
441444
"ListFailoverIPsRequest",
442445
"ListFailoverIPsResponse",
443446
"ListIPv6BlockSubnetsAvailableResponse",
447+
"ListIPv6BlocksResponse",
444448
"ListInvoicesResponse",
445449
"ListIpsResponse",
446450
"ListOSRequest",

scaleway-async/scaleway_async/dedibox/v1/api.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
InvoiceSummary,
6767
ListFailoverIPsResponse,
6868
ListIPv6BlockSubnetsAvailableResponse,
69+
ListIPv6BlocksResponse,
6970
ListInvoicesResponse,
7071
ListIpsResponse,
7172
ListOSResponse,
@@ -153,17 +154,18 @@
153154
unmarshal_RpnV2Group,
154155
unmarshal_Service,
155156
unmarshal_FailoverIP,
157+
unmarshal_IPv6Block,
156158
unmarshal_BMCAccess,
157159
unmarshal_Backup,
158160
unmarshal_CanOrderResponse,
159161
unmarshal_CreateFailoverIPsResponse,
160162
unmarshal_GetIPv6BlockQuotasResponse,
161163
unmarshal_GetRemainingQuotaResponse,
162164
unmarshal_GetRpnStatusResponse,
163-
unmarshal_IPv6Block,
164165
unmarshal_Invoice,
165166
unmarshal_ListFailoverIPsResponse,
166167
unmarshal_ListIPv6BlockSubnetsAvailableResponse,
168+
unmarshal_ListIPv6BlocksResponse,
167169
unmarshal_ListInvoicesResponse,
168170
unmarshal_ListIpsResponse,
169171
unmarshal_ListOSResponse,
@@ -2812,14 +2814,42 @@ async def create_i_pv6_block(
28122814
self._throw_on_error(res)
28132815
return unmarshal_IPv6Block(res.json())
28142816

2817+
async def list_i_pv6_blocks(
2818+
self,
2819+
*,
2820+
project_id: Optional[str] = None,
2821+
) -> ListIPv6BlocksResponse:
2822+
"""
2823+
List IPv6 blocks.
2824+
List IPv6 blocks associated given project ID.
2825+
:param project_id:
2826+
:return: :class:`ListIPv6BlocksResponse <ListIPv6BlocksResponse>`
2827+
2828+
Usage:
2829+
::
2830+
2831+
result = await api.list_i_pv6_blocks()
2832+
"""
2833+
2834+
res = self._request(
2835+
"GET",
2836+
"/dedibox/v1/ipv6-blocks",
2837+
params={
2838+
"project_id": project_id or self.client.default_project_id,
2839+
},
2840+
)
2841+
2842+
self._throw_on_error(res)
2843+
return unmarshal_ListIPv6BlocksResponse(res.json())
2844+
28152845
async def get_i_pv6_block(
28162846
self,
28172847
*,
28182848
project_id: Optional[str] = None,
28192849
) -> IPv6Block:
28202850
"""
2821-
Get a specific IPv6 block.
2822-
Get the IPv6 block associated with the given ID.
2851+
Get first IPv6 block.
2852+
Get the first IPv6 block associated with the given project ID.
28232853
:param project_id: ID of the project.
28242854
:return: :class:`IPv6Block <IPv6Block>`
28252855

scaleway-async/scaleway_async/dedibox/v1/marshalling.py

Lines changed: 82 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
Service,
7878
FailoverBlock,
7979
FailoverIP,
80+
IPv6Block,
8081
BMCAccess,
8182
Backup,
8283
CanOrderResponse,
@@ -85,11 +86,11 @@
8586
GetIPv6BlockQuotasResponse,
8687
GetRemainingQuotaResponse,
8788
GetRpnStatusResponse,
88-
IPv6Block,
8989
Invoice,
9090
ListFailoverIPsResponse,
9191
ListIPv6BlockSubnetsAvailableResponseSubnet,
9292
ListIPv6BlockSubnetsAvailableResponse,
93+
ListIPv6BlocksResponse,
9394
InvoiceSummary,
9495
ListInvoicesResponse,
9596
RpnSanIpRpnV2Group,
@@ -1802,6 +1803,61 @@ def unmarshal_FailoverIP(data: Any) -> FailoverIP:
18021803
return FailoverIP(**args)
18031804

18041805

1806+
def unmarshal_IPv6Block(data: Any) -> IPv6Block:
1807+
if not isinstance(data, dict):
1808+
raise TypeError(
1809+
"Unmarshalling the type 'IPv6Block' failed as data isn't a dictionary."
1810+
)
1811+
1812+
args: dict[str, Any] = {}
1813+
1814+
field = data.get("id", None)
1815+
if field is not None:
1816+
args["id"] = field
1817+
else:
1818+
args["id"] = 0
1819+
1820+
field = data.get("address", None)
1821+
if field is not None:
1822+
args["address"] = field
1823+
else:
1824+
args["address"] = None
1825+
1826+
field = data.get("duid", None)
1827+
if field is not None:
1828+
args["duid"] = field
1829+
else:
1830+
args["duid"] = None
1831+
1832+
field = data.get("nameservers", None)
1833+
if field is not None:
1834+
args["nameservers"] = field
1835+
else:
1836+
args["nameservers"] = []
1837+
1838+
field = data.get("cidr", None)
1839+
if field is not None:
1840+
args["cidr"] = field
1841+
else:
1842+
args["cidr"] = 0
1843+
1844+
field = data.get("subnets", None)
1845+
if field is not None:
1846+
args["subnets"] = (
1847+
[unmarshal_IPv6Block(v) for v in field] if field is not None else None
1848+
)
1849+
else:
1850+
args["subnets"] = []
1851+
1852+
field = data.get("delegation_status", None)
1853+
if field is not None:
1854+
args["delegation_status"] = field
1855+
else:
1856+
args["delegation_status"] = IPv6BlockDelegationStatus.UNKNOWN_STATUS
1857+
1858+
return IPv6Block(**args)
1859+
1860+
18051861
def unmarshal_BMCAccess(data: Any) -> BMCAccess:
18061862
if not isinstance(data, dict):
18071863
raise TypeError(
@@ -2108,61 +2164,6 @@ def unmarshal_GetRpnStatusResponse(data: Any) -> GetRpnStatusResponse:
21082164
return GetRpnStatusResponse(**args)
21092165

21102166

2111-
def unmarshal_IPv6Block(data: Any) -> IPv6Block:
2112-
if not isinstance(data, dict):
2113-
raise TypeError(
2114-
"Unmarshalling the type 'IPv6Block' failed as data isn't a dictionary."
2115-
)
2116-
2117-
args: dict[str, Any] = {}
2118-
2119-
field = data.get("id", None)
2120-
if field is not None:
2121-
args["id"] = field
2122-
else:
2123-
args["id"] = 0
2124-
2125-
field = data.get("address", None)
2126-
if field is not None:
2127-
args["address"] = field
2128-
else:
2129-
args["address"] = None
2130-
2131-
field = data.get("duid", None)
2132-
if field is not None:
2133-
args["duid"] = field
2134-
else:
2135-
args["duid"] = None
2136-
2137-
field = data.get("nameservers", None)
2138-
if field is not None:
2139-
args["nameservers"] = field
2140-
else:
2141-
args["nameservers"] = []
2142-
2143-
field = data.get("cidr", None)
2144-
if field is not None:
2145-
args["cidr"] = field
2146-
else:
2147-
args["cidr"] = 0
2148-
2149-
field = data.get("subnets", None)
2150-
if field is not None:
2151-
args["subnets"] = (
2152-
[unmarshal_IPv6Block(v) for v in field] if field is not None else None
2153-
)
2154-
else:
2155-
args["subnets"] = []
2156-
2157-
field = data.get("delegation_status", None)
2158-
if field is not None:
2159-
args["delegation_status"] = field
2160-
else:
2161-
args["delegation_status"] = IPv6BlockDelegationStatus.UNKNOWN_STATUS
2162-
2163-
return IPv6Block(**args)
2164-
2165-
21662167
def unmarshal_Invoice(data: Any) -> Invoice:
21672168
if not isinstance(data, dict):
21682169
raise TypeError(
@@ -2307,6 +2308,31 @@ def unmarshal_ListIPv6BlockSubnetsAvailableResponse(
23072308
return ListIPv6BlockSubnetsAvailableResponse(**args)
23082309

23092310

2311+
def unmarshal_ListIPv6BlocksResponse(data: Any) -> ListIPv6BlocksResponse:
2312+
if not isinstance(data, dict):
2313+
raise TypeError(
2314+
"Unmarshalling the type 'ListIPv6BlocksResponse' failed as data isn't a dictionary."
2315+
)
2316+
2317+
args: dict[str, Any] = {}
2318+
2319+
field = data.get("total_count", None)
2320+
if field is not None:
2321+
args["total_count"] = field
2322+
else:
2323+
args["total_count"] = None
2324+
2325+
field = data.get("ipv6_blocks", None)
2326+
if field is not None:
2327+
args["ipv6_blocks"] = (
2328+
[unmarshal_IPv6Block(v) for v in field] if field is not None else None
2329+
)
2330+
else:
2331+
args["ipv6_blocks"] = None
2332+
2333+
return ListIPv6BlocksResponse(**args)
2334+
2335+
23102336
def unmarshal_InvoiceSummary(data: Any) -> InvoiceSummary:
23112337
if not isinstance(data, dict):
23122338
raise TypeError(

0 commit comments

Comments
 (0)