From 471969fd36059360e26b6adddcbdeadf2d08b895 Mon Sep 17 00:00:00 2001 From: digitalocean-engineering Date: Wed, 26 Feb 2025 10:55:03 -0500 Subject: [PATCH] [bot] Updated client based on openapi-31fb5b2/clientgen (#417) Co-authored-by: API Engineering --- DO_OPENAPI_COMMIT_SHA.txt | 2 +- src/pydo/_client.py | 12 + src/pydo/aio/_client.py | 12 + src/pydo/aio/operations/__init__.py | 4 + src/pydo/aio/operations/_operations.py | 958 +++++++++++++++++++++ src/pydo/operations/__init__.py | 4 + src/pydo/operations/_operations.py | 1069 ++++++++++++++++++++++++ 7 files changed, 2060 insertions(+), 1 deletion(-) diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index bf2186d..939aca1 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -44575ea +31fb5b2 diff --git a/src/pydo/_client.py b/src/pydo/_client.py index 60df5ed..b3c56e2 100644 --- a/src/pydo/_client.py +++ b/src/pydo/_client.py @@ -41,6 +41,8 @@ RegistryOperations, ReservedIPsActionsOperations, ReservedIPsOperations, + ReservedIPv6ActionsOperations, + ReservedIPv6Operations, SizesOperations, SnapshotsOperations, SshKeysOperations, @@ -617,6 +619,10 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype reserved_ips: pydo.operations.ReservedIPsOperations :ivar reserved_ips_actions: ReservedIPsActionsOperations operations :vartype reserved_ips_actions: pydo.operations.ReservedIPsActionsOperations + :ivar reserved_ipv6: ReservedIPv6Operations operations + :vartype reserved_ipv6: pydo.operations.ReservedIPv6Operations + :ivar reserved_ipv6_actions: ReservedIPv6ActionsOperations operations + :vartype reserved_ipv6_actions: pydo.operations.ReservedIPv6ActionsOperations :ivar sizes: SizesOperations operations :vartype sizes: pydo.operations.SizesOperations :ivar snapshots: SnapshotsOperations operations @@ -760,6 +766,12 @@ def __init__( self.reserved_ips_actions = ReservedIPsActionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.reserved_ipv6 = ReservedIPv6Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.reserved_ipv6_actions = ReservedIPv6ActionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sizes = SizesOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/src/pydo/aio/_client.py b/src/pydo/aio/_client.py index 813f325..aba3ba9 100644 --- a/src/pydo/aio/_client.py +++ b/src/pydo/aio/_client.py @@ -41,6 +41,8 @@ RegistryOperations, ReservedIPsActionsOperations, ReservedIPsOperations, + ReservedIPv6ActionsOperations, + ReservedIPv6Operations, SizesOperations, SnapshotsOperations, SshKeysOperations, @@ -617,6 +619,10 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype reserved_ips: pydo.aio.operations.ReservedIPsOperations :ivar reserved_ips_actions: ReservedIPsActionsOperations operations :vartype reserved_ips_actions: pydo.aio.operations.ReservedIPsActionsOperations + :ivar reserved_ipv6: ReservedIPv6Operations operations + :vartype reserved_ipv6: pydo.aio.operations.ReservedIPv6Operations + :ivar reserved_ipv6_actions: ReservedIPv6ActionsOperations operations + :vartype reserved_ipv6_actions: pydo.aio.operations.ReservedIPv6ActionsOperations :ivar sizes: SizesOperations operations :vartype sizes: pydo.aio.operations.SizesOperations :ivar snapshots: SnapshotsOperations operations @@ -760,6 +766,12 @@ def __init__( self.reserved_ips_actions = ReservedIPsActionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.reserved_ipv6 = ReservedIPv6Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.reserved_ipv6_actions = ReservedIPv6ActionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sizes = SizesOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/src/pydo/aio/operations/__init__.py b/src/pydo/aio/operations/__init__.py index 1198110..9977414 100644 --- a/src/pydo/aio/operations/__init__.py +++ b/src/pydo/aio/operations/__init__.py @@ -31,6 +31,8 @@ from ._operations import RegistryOperations from ._operations import ReservedIPsOperations from ._operations import ReservedIPsActionsOperations +from ._operations import ReservedIPv6Operations +from ._operations import ReservedIPv6ActionsOperations from ._operations import SizesOperations from ._operations import SnapshotsOperations from ._operations import TagsOperations @@ -74,6 +76,8 @@ "RegistryOperations", "ReservedIPsOperations", "ReservedIPsActionsOperations", + "ReservedIPv6Operations", + "ReservedIPv6ActionsOperations", "SizesOperations", "SnapshotsOperations", "TagsOperations", diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index 9a27a78..c7d0a25 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -389,6 +389,11 @@ build_reserved_ips_delete_request, build_reserved_ips_get_request, build_reserved_ips_list_request, + build_reserved_ipv6_actions_post_request, + build_reserved_ipv6_create_request, + build_reserved_ipv6_delete_request, + build_reserved_ipv6_get_request, + build_reserved_ipv6_list_request, build_sizes_list_request, build_snapshots_delete_request, build_snapshots_get_request, @@ -154039,6 +154044,959 @@ async def get(self, reserved_ip: str, action_id: int, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore +class ReservedIPv6Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`reserved_ipv6` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace_async + async def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] List All Reserved IPv6s. + + To list all of the reserved IPv6s available on your account, send a GET request to + ``/v2/reserved_ipv6``. + + :keyword per_page: Number of items returned per page. Default value is 20. + :paramtype per_page: int + :keyword page: Which 'page' of paginated results to return. Default value is 1. + :paramtype page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "meta": { + "total": 0 # Optional. Number of objects returned by the request. + }, + "links": { + "pages": {} + }, + "reserved_ipv6s": [ + { + "droplet": {}, + "ip": "str", # Optional. The public IP address of the + reserved IPv6. It also serves as its identifier. + "region_slug": "str", # Optional. The region that the + reserved IPv6 is reserved to. When you query a reserved IPv6,the + region_slug will be returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. + } + ] + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_reserved_ipv6_list_request( + per_page=per_page, + page=page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Create a New Reserved IPv6. + + On creation, a reserved IPv6 must be reserved to a region. + + + * To create a new reserved IPv6 reserved to a region, send a POST request to + ``/v2/reserved_ipv6`` with the ``region_slug`` attribute. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "region_slug": "str" # The slug identifier for the region the reserved IPv6 + will be reserved to. Required. + } + + # response body for status code(s): 201 + response == { + "reserved_ipv6": { + "ip": "str", # Optional. The public IP address of the reserved IPv6. + It also serves as its identifier. + "region_slug": "str", # Optional. The region that the reserved IPv6 + is reserved to. When you query a reserved IPv6,the region_slug will be + returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. + } + } + """ + + @overload + async def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Create a New Reserved IPv6. + + On creation, a reserved IPv6 must be reserved to a region. + + + * To create a new reserved IPv6 reserved to a region, send a POST request to + ``/v2/reserved_ipv6`` with the ``region_slug`` attribute. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "reserved_ipv6": { + "ip": "str", # Optional. The public IP address of the reserved IPv6. + It also serves as its identifier. + "region_slug": "str", # Optional. The region that the reserved IPv6 + is reserved to. When you query a reserved IPv6,the region_slug will be + returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. + } + } + """ + + @distributed_trace_async + async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Create a New Reserved IPv6. + + On creation, a reserved IPv6 must be reserved to a region. + + + * To create a new reserved IPv6 reserved to a region, send a POST request to + ``/v2/reserved_ipv6`` with the ``region_slug`` attribute. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "region_slug": "str" # The slug identifier for the region the reserved IPv6 + will be reserved to. Required. + } + + # response body for status code(s): 201 + response == { + "reserved_ipv6": { + "ip": "str", # Optional. The public IP address of the reserved IPv6. + It also serves as its identifier. + "region_slug": "str", # Optional. The region that the reserved IPv6 + is reserved to. When you query a reserved IPv6,the region_slug will be + returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_reserved_ipv6_create_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get(self, reserved_ipv6: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Retrieve an Existing Reserved IPv6. + + To show information about a reserved IPv6, send a GET request to + ``/v2/reserved_ipv6/$RESERVED_IPV6``. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "reserved_ipv6": { + "droplet": {}, + "ip": "str", # Optional. The public IP address of the reserved IPv6. + It also serves as its identifier. + "region_slug": "str", # Optional. The region that the reserved IPv6 + is reserved to. When you query a reserved IPv6,the region_slug will be + returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. The date and time + when the reserved IPv6 was reserved. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_reserved_ipv6_get_request( + reserved_ipv6=reserved_ipv6, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def delete(self, reserved_ipv6: str, **kwargs: Any) -> Optional[JSON]: + # pylint: disable=line-too-long + """[Public Preview] Delete a Reserved IPv6. + + To delete a reserved IP and remove it from your account, send a DELETE request + to ``/v2/reserved_ipv6/$RESERVED_IPV6``. + + A successful request will receive a 204 status code with no body in response. + This indicates that the request was processed successfully. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404, 422 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_reserved_ipv6_delete_request( + reserved_ipv6=reserved_ipv6, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404, 422]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 422: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class ReservedIPv6ActionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`reserved_ipv6_actions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @overload + async def post( + self, + reserved_ipv6: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Initiate a Reserved IPv6 Action. + + To initiate an action on a reserved IPv6 send a POST request to + ``/v2/reserved_ipv6/$RESERVED_IPV6/actions``. In the JSON body to the request, + set the ``type`` attribute to on of the supported action types: + + .. list-table:: + :header-rows: 1 + + * - Action + - Details + * - ``assign`` + - Assigns a reserved IPv6 to a Droplet + * - ``unassign`` + - Unassign a reserved IPv6 from a Droplet. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :param body: The ``type`` attribute set in the request body will specify the action that + will be taken on the reserved IPv6. Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = {} + + # response body for status code(s): 201 + response == { + "action": { + "completed_at": "2020-02-20 00:00:00", # Optional. A time value + given in ISO8601 combined date and time format that represents when the + action was completed. + "id": 0, # Optional. A unique numeric ID that can be used to + identify and reference an action. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": {}, # This attribute is set to an array which + contains features available in this region. Required. + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": {}, # This attribute is set to an array which + contains the identifying slugs for the sizes available in this region. + Required. + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "region_slug": "str", # Optional. A human-readable string that is + used as a unique identifier for each region. + "resource_id": 0, # Optional. A unique identifier for the resource + that the action is associated with. + "resource_type": "str", # Optional. The type of resource that the + action is associated with. + "started_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the action was + initiated. + "status": "in-progress", # Optional. Default value is "in-progress". + The current status of the action. This can be "in-progress", "completed", or + "errored". Known values are: "in-progress", "completed", and "errored". + "type": "str" # Optional. This is the type of action that the object + represents. For example, this could be "transfer" to represent the state of + an image transfer action. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def post( + self, + reserved_ipv6: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Initiate a Reserved IPv6 Action. + + To initiate an action on a reserved IPv6 send a POST request to + ``/v2/reserved_ipv6/$RESERVED_IPV6/actions``. In the JSON body to the request, + set the ``type`` attribute to on of the supported action types: + + .. list-table:: + :header-rows: 1 + + * - Action + - Details + * - ``assign`` + - Assigns a reserved IPv6 to a Droplet + * - ``unassign`` + - Unassign a reserved IPv6 from a Droplet. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :param body: The ``type`` attribute set in the request body will specify the action that + will be taken on the reserved IPv6. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "action": { + "completed_at": "2020-02-20 00:00:00", # Optional. A time value + given in ISO8601 combined date and time format that represents when the + action was completed. + "id": 0, # Optional. A unique numeric ID that can be used to + identify and reference an action. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": {}, # This attribute is set to an array which + contains features available in this region. Required. + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": {}, # This attribute is set to an array which + contains the identifying slugs for the sizes available in this region. + Required. + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "region_slug": "str", # Optional. A human-readable string that is + used as a unique identifier for each region. + "resource_id": 0, # Optional. A unique identifier for the resource + that the action is associated with. + "resource_type": "str", # Optional. The type of resource that the + action is associated with. + "started_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the action was + initiated. + "status": "in-progress", # Optional. Default value is "in-progress". + The current status of the action. This can be "in-progress", "completed", or + "errored". Known values are: "in-progress", "completed", and "errored". + "type": "str" # Optional. This is the type of action that the object + represents. For example, this could be "transfer" to represent the state of + an image transfer action. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def post( + self, + reserved_ipv6: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Initiate a Reserved IPv6 Action. + + To initiate an action on a reserved IPv6 send a POST request to + ``/v2/reserved_ipv6/$RESERVED_IPV6/actions``. In the JSON body to the request, + set the ``type`` attribute to on of the supported action types: + + .. list-table:: + :header-rows: 1 + + * - Action + - Details + * - ``assign`` + - Assigns a reserved IPv6 to a Droplet + * - ``unassign`` + - Unassign a reserved IPv6 from a Droplet. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :param body: The ``type`` attribute set in the request body will specify the action that + will be taken on the reserved IPv6. Is either a JSON type or a IO[bytes] type. Default value + is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = {} + + # response body for status code(s): 201 + response == { + "action": { + "completed_at": "2020-02-20 00:00:00", # Optional. A time value + given in ISO8601 combined date and time format that represents when the + action was completed. + "id": 0, # Optional. A unique numeric ID that can be used to + identify and reference an action. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": {}, # This attribute is set to an array which + contains features available in this region. Required. + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": {}, # This attribute is set to an array which + contains the identifying slugs for the sizes available in this region. + Required. + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "region_slug": "str", # Optional. A human-readable string that is + used as a unique identifier for each region. + "resource_id": 0, # Optional. A unique identifier for the resource + that the action is associated with. + "resource_type": "str", # Optional. The type of resource that the + action is associated with. + "started_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the action was + initiated. + "status": "in-progress", # Optional. Default value is "in-progress". + The current status of the action. This can be "in-progress", "completed", or + "errored". Known values are: "in-progress", "completed", and "errored". + "type": "str" # Optional. This is the type of action that the object + represents. For example, this could be "transfer" to represent the state of + an image transfer action. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_reserved_ipv6_actions_post_request( + reserved_ipv6=reserved_ipv6, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + class SizesOperations: """ .. warning:: diff --git a/src/pydo/operations/__init__.py b/src/pydo/operations/__init__.py index 1198110..9977414 100644 --- a/src/pydo/operations/__init__.py +++ b/src/pydo/operations/__init__.py @@ -31,6 +31,8 @@ from ._operations import RegistryOperations from ._operations import ReservedIPsOperations from ._operations import ReservedIPsActionsOperations +from ._operations import ReservedIPv6Operations +from ._operations import ReservedIPv6ActionsOperations from ._operations import SizesOperations from ._operations import SnapshotsOperations from ._operations import TagsOperations @@ -74,6 +76,8 @@ "RegistryOperations", "ReservedIPsOperations", "ReservedIPsActionsOperations", + "ReservedIPv6Operations", + "ReservedIPv6ActionsOperations", "SizesOperations", "SnapshotsOperations", "TagsOperations", diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index 0007aaf..e485e8e 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -7856,6 +7856,122 @@ def build_reserved_ips_actions_get_request( return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) +def build_reserved_ipv6_list_request( + *, per_page: int = 20, page: int = 1, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/reserved_ipv6" + + # Construct parameters + if per_page is not None: + _params["per_page"] = _SERIALIZER.query( + "per_page", per_page, "int", maximum=200, minimum=1 + ) + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int", minimum=1) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_reserved_ipv6_create_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/reserved_ipv6" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_reserved_ipv6_get_request(reserved_ipv6: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/reserved_ipv6/{reserved_ipv6}" + path_format_arguments = { + "reserved_ipv6": _SERIALIZER.url("reserved_ipv6", reserved_ipv6, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_reserved_ipv6_delete_request( + reserved_ipv6: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/reserved_ipv6/{reserved_ipv6}" + path_format_arguments = { + "reserved_ipv6": _SERIALIZER.url("reserved_ipv6", reserved_ipv6, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + + +def build_reserved_ipv6_actions_post_request( + reserved_ipv6: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/reserved_ipv6/{reserved_ipv6}/actions" + path_format_arguments = { + "reserved_ipv6": _SERIALIZER.url("reserved_ipv6", reserved_ipv6, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + def build_sizes_list_request( *, per_page: int = 20, page: int = 1, **kwargs: Any ) -> HttpRequest: @@ -163702,6 +163818,959 @@ def get(self, reserved_ip: str, action_id: int, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore +class ReservedIPv6Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`reserved_ipv6` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace + def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] List All Reserved IPv6s. + + To list all of the reserved IPv6s available on your account, send a GET request to + ``/v2/reserved_ipv6``. + + :keyword per_page: Number of items returned per page. Default value is 20. + :paramtype per_page: int + :keyword page: Which 'page' of paginated results to return. Default value is 1. + :paramtype page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "meta": { + "total": 0 # Optional. Number of objects returned by the request. + }, + "links": { + "pages": {} + }, + "reserved_ipv6s": [ + { + "droplet": {}, + "ip": "str", # Optional. The public IP address of the + reserved IPv6. It also serves as its identifier. + "region_slug": "str", # Optional. The region that the + reserved IPv6 is reserved to. When you query a reserved IPv6,the + region_slug will be returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. + } + ] + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_reserved_ipv6_list_request( + per_page=per_page, + page=page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Create a New Reserved IPv6. + + On creation, a reserved IPv6 must be reserved to a region. + + + * To create a new reserved IPv6 reserved to a region, send a POST request to + ``/v2/reserved_ipv6`` with the ``region_slug`` attribute. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "region_slug": "str" # The slug identifier for the region the reserved IPv6 + will be reserved to. Required. + } + + # response body for status code(s): 201 + response == { + "reserved_ipv6": { + "ip": "str", # Optional. The public IP address of the reserved IPv6. + It also serves as its identifier. + "region_slug": "str", # Optional. The region that the reserved IPv6 + is reserved to. When you query a reserved IPv6,the region_slug will be + returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. + } + } + """ + + @overload + def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Create a New Reserved IPv6. + + On creation, a reserved IPv6 must be reserved to a region. + + + * To create a new reserved IPv6 reserved to a region, send a POST request to + ``/v2/reserved_ipv6`` with the ``region_slug`` attribute. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "reserved_ipv6": { + "ip": "str", # Optional. The public IP address of the reserved IPv6. + It also serves as its identifier. + "region_slug": "str", # Optional. The region that the reserved IPv6 + is reserved to. When you query a reserved IPv6,the region_slug will be + returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. + } + } + """ + + @distributed_trace + def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Create a New Reserved IPv6. + + On creation, a reserved IPv6 must be reserved to a region. + + + * To create a new reserved IPv6 reserved to a region, send a POST request to + ``/v2/reserved_ipv6`` with the ``region_slug`` attribute. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "region_slug": "str" # The slug identifier for the region the reserved IPv6 + will be reserved to. Required. + } + + # response body for status code(s): 201 + response == { + "reserved_ipv6": { + "ip": "str", # Optional. The public IP address of the reserved IPv6. + It also serves as its identifier. + "region_slug": "str", # Optional. The region that the reserved IPv6 + is reserved to. When you query a reserved IPv6,the region_slug will be + returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_reserved_ipv6_create_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get(self, reserved_ipv6: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Retrieve an Existing Reserved IPv6. + + To show information about a reserved IPv6, send a GET request to + ``/v2/reserved_ipv6/$RESERVED_IPV6``. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "reserved_ipv6": { + "droplet": {}, + "ip": "str", # Optional. The public IP address of the reserved IPv6. + It also serves as its identifier. + "region_slug": "str", # Optional. The region that the reserved IPv6 + is reserved to. When you query a reserved IPv6,the region_slug will be + returned. + "reserved_at": "2020-02-20 00:00:00" # Optional. The date and time + when the reserved IPv6 was reserved. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_reserved_ipv6_get_request( + reserved_ipv6=reserved_ipv6, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def delete(self, reserved_ipv6: str, **kwargs: Any) -> Optional[JSON]: + # pylint: disable=line-too-long + """[Public Preview] Delete a Reserved IPv6. + + To delete a reserved IP and remove it from your account, send a DELETE request + to ``/v2/reserved_ipv6/$RESERVED_IPV6``. + + A successful request will receive a 204 status code with no body in response. + This indicates that the request was processed successfully. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404, 422 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_reserved_ipv6_delete_request( + reserved_ipv6=reserved_ipv6, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404, 422]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 422: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class ReservedIPv6ActionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`reserved_ipv6_actions` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @overload + def post( + self, + reserved_ipv6: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Initiate a Reserved IPv6 Action. + + To initiate an action on a reserved IPv6 send a POST request to + ``/v2/reserved_ipv6/$RESERVED_IPV6/actions``. In the JSON body to the request, + set the ``type`` attribute to on of the supported action types: + + .. list-table:: + :header-rows: 1 + + * - Action + - Details + * - ``assign`` + - Assigns a reserved IPv6 to a Droplet + * - ``unassign`` + - Unassign a reserved IPv6 from a Droplet. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :param body: The ``type`` attribute set in the request body will specify the action that + will be taken on the reserved IPv6. Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = {} + + # response body for status code(s): 201 + response == { + "action": { + "completed_at": "2020-02-20 00:00:00", # Optional. A time value + given in ISO8601 combined date and time format that represents when the + action was completed. + "id": 0, # Optional. A unique numeric ID that can be used to + identify and reference an action. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": {}, # This attribute is set to an array which + contains features available in this region. Required. + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": {}, # This attribute is set to an array which + contains the identifying slugs for the sizes available in this region. + Required. + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "region_slug": "str", # Optional. A human-readable string that is + used as a unique identifier for each region. + "resource_id": 0, # Optional. A unique identifier for the resource + that the action is associated with. + "resource_type": "str", # Optional. The type of resource that the + action is associated with. + "started_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the action was + initiated. + "status": "in-progress", # Optional. Default value is "in-progress". + The current status of the action. This can be "in-progress", "completed", or + "errored". Known values are: "in-progress", "completed", and "errored". + "type": "str" # Optional. This is the type of action that the object + represents. For example, this could be "transfer" to represent the state of + an image transfer action. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def post( + self, + reserved_ipv6: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Initiate a Reserved IPv6 Action. + + To initiate an action on a reserved IPv6 send a POST request to + ``/v2/reserved_ipv6/$RESERVED_IPV6/actions``. In the JSON body to the request, + set the ``type`` attribute to on of the supported action types: + + .. list-table:: + :header-rows: 1 + + * - Action + - Details + * - ``assign`` + - Assigns a reserved IPv6 to a Droplet + * - ``unassign`` + - Unassign a reserved IPv6 from a Droplet. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :param body: The ``type`` attribute set in the request body will specify the action that + will be taken on the reserved IPv6. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "action": { + "completed_at": "2020-02-20 00:00:00", # Optional. A time value + given in ISO8601 combined date and time format that represents when the + action was completed. + "id": 0, # Optional. A unique numeric ID that can be used to + identify and reference an action. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": {}, # This attribute is set to an array which + contains features available in this region. Required. + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": {}, # This attribute is set to an array which + contains the identifying slugs for the sizes available in this region. + Required. + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "region_slug": "str", # Optional. A human-readable string that is + used as a unique identifier for each region. + "resource_id": 0, # Optional. A unique identifier for the resource + that the action is associated with. + "resource_type": "str", # Optional. The type of resource that the + action is associated with. + "started_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the action was + initiated. + "status": "in-progress", # Optional. Default value is "in-progress". + The current status of the action. This can be "in-progress", "completed", or + "errored". Known values are: "in-progress", "completed", and "errored". + "type": "str" # Optional. This is the type of action that the object + represents. For example, this could be "transfer" to represent the state of + an image transfer action. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def post( + self, + reserved_ipv6: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """[Public Preview] Initiate a Reserved IPv6 Action. + + To initiate an action on a reserved IPv6 send a POST request to + ``/v2/reserved_ipv6/$RESERVED_IPV6/actions``. In the JSON body to the request, + set the ``type`` attribute to on of the supported action types: + + .. list-table:: + :header-rows: 1 + + * - Action + - Details + * - ``assign`` + - Assigns a reserved IPv6 to a Droplet + * - ``unassign`` + - Unassign a reserved IPv6 from a Droplet. + + :param reserved_ipv6: A reserved IPv6 address. Required. + :type reserved_ipv6: str + :param body: The ``type`` attribute set in the request body will specify the action that + will be taken on the reserved IPv6. Is either a JSON type or a IO[bytes] type. Default value + is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = {} + + # response body for status code(s): 201 + response == { + "action": { + "completed_at": "2020-02-20 00:00:00", # Optional. A time value + given in ISO8601 combined date and time format that represents when the + action was completed. + "id": 0, # Optional. A unique numeric ID that can be used to + identify and reference an action. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": {}, # This attribute is set to an array which + contains features available in this region. Required. + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": {}, # This attribute is set to an array which + contains the identifying slugs for the sizes available in this region. + Required. + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "region_slug": "str", # Optional. A human-readable string that is + used as a unique identifier for each region. + "resource_id": 0, # Optional. A unique identifier for the resource + that the action is associated with. + "resource_type": "str", # Optional. The type of resource that the + action is associated with. + "started_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the action was + initiated. + "status": "in-progress", # Optional. Default value is "in-progress". + The current status of the action. This can be "in-progress", "completed", or + "errored". Known values are: "in-progress", "completed", and "errored". + "type": "str" # Optional. This is the type of action that the object + represents. For example, this could be "transfer" to represent the state of + an image transfer action. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_reserved_ipv6_actions_post_request( + reserved_ipv6=reserved_ipv6, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + class SizesOperations: """ .. warning::