diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index a0fd776..e8a1233 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -e67d14f +b78970b diff --git a/src/pydo/_client.py b/src/pydo/_client.py index e0cf735..36c327f 100644 --- a/src/pydo/_client.py +++ b/src/pydo/_client.py @@ -47,6 +47,7 @@ VolumeActionsOperations, VolumeSnapshotsOperations, VolumesOperations, + VpcPeeringsOperations, VpcsOperations, ) @@ -626,6 +627,8 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype volume_snapshots: pydo.operations.VolumeSnapshotsOperations :ivar vpcs: VpcsOperations operations :vartype vpcs: pydo.operations.VpcsOperations + :ivar vpc_peerings: VpcPeeringsOperations operations + :vartype vpc_peerings: pydo.operations.VpcPeeringsOperations :ivar uptime: UptimeOperations operations :vartype uptime: pydo.operations.UptimeOperations :param credential: Credential needed for the client to connect to Azure. Required. @@ -769,6 +772,9 @@ def __init__( self.vpcs = VpcsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.vpc_peerings = VpcPeeringsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.uptime = UptimeOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/src/pydo/aio/_client.py b/src/pydo/aio/_client.py index 7d75cad..967be06 100644 --- a/src/pydo/aio/_client.py +++ b/src/pydo/aio/_client.py @@ -47,6 +47,7 @@ VolumeActionsOperations, VolumeSnapshotsOperations, VolumesOperations, + VpcPeeringsOperations, VpcsOperations, ) @@ -626,6 +627,8 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype volume_snapshots: pydo.aio.operations.VolumeSnapshotsOperations :ivar vpcs: VpcsOperations operations :vartype vpcs: pydo.aio.operations.VpcsOperations + :ivar vpc_peerings: VpcPeeringsOperations operations + :vartype vpc_peerings: pydo.aio.operations.VpcPeeringsOperations :ivar uptime: UptimeOperations operations :vartype uptime: pydo.aio.operations.UptimeOperations :param credential: Credential needed for the client to connect to Azure. Required. @@ -769,6 +772,9 @@ def __init__( self.vpcs = VpcsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.vpc_peerings = VpcPeeringsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.uptime = UptimeOperations( 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 930e654..86b8cfe 100644 --- a/src/pydo/aio/operations/__init__.py +++ b/src/pydo/aio/operations/__init__.py @@ -37,6 +37,7 @@ from ._operations import VolumeActionsOperations from ._operations import VolumeSnapshotsOperations from ._operations import VpcsOperations +from ._operations import VpcPeeringsOperations from ._operations import UptimeOperations from ._patch import __all__ as _patch_all @@ -77,6 +78,7 @@ "VolumeActionsOperations", "VolumeSnapshotsOperations", "VpcsOperations", + "VpcPeeringsOperations", "UptimeOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index 0adaed4..600bf40 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -359,11 +359,19 @@ build_volumes_delete_request, build_volumes_get_request, build_volumes_list_request, + build_vpc_peerings_create_request, + build_vpc_peerings_delete_request, + build_vpc_peerings_get_request, + build_vpc_peerings_list_request, + build_vpc_peerings_patch_request, + build_vpcs_create_peerings_request, build_vpcs_create_request, build_vpcs_delete_request, build_vpcs_get_request, build_vpcs_list_members_request, + build_vpcs_list_peerings_request, build_vpcs_list_request, + build_vpcs_patch_peerings_request, build_vpcs_patch_request, build_vpcs_update_request, ) @@ -148405,6 +148413,1610 @@ async def list_members( return cast(JSON, deserialized) # type: ignore + @distributed_trace_async + async def list_peerings( + self, vpc_id: str, *, per_page: int = 20, page: int = 1, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List the Peerings of a VPC. + + To list all of a VPC's peerings, send a GET request to + ``/v2/vpcs/$VPC_ID/peerings``. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :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": {} + }, + "peerings": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must + be unique within the team and may only contain alphanumeric characters + and dashes. + "status": "str", # Optional. The current status of the VPC + peering. Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs + IDs. + ] + } + ] + } + # 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_vpcs_list_peerings_request( + vpc_id=vpc_id, + 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, 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 + + @overload + async def create_peerings( + self, + vpc_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Peering with a VPC. + + To create a new VPC peering for a given VPC, send a POST request to + ``/v2/vpcs/$VPC_ID/peerings``. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :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 = { + "name": "str", # The name of the VPC peering. Must be unique and may only + contain alphanumeric characters, dashes, and periods. Required. + "vpc_id": "str" # The ID of the VPC to peer with. Required. + } + + # response body for status code(s): 202 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 create_peerings( + self, + vpc_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Peering with a VPC. + + To create a new VPC peering for a given VPC, send a POST request to + ``/v2/vpcs/$VPC_ID/peerings``. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :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): 202 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 create_peerings( + self, vpc_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Peering with a VPC. + + To create a new VPC peering for a given VPC, send a POST request to + ``/v2/vpcs/$VPC_ID/peerings``. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :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 = { + "name": "str", # The name of the VPC peering. Must be unique and may only + contain alphanumeric characters, dashes, and periods. Required. + "vpc_id": "str" # The ID of the VPC to peer with. Required. + } + + # response body for status code(s): 202 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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: + _json = body + + _request = build_vpcs_create_peerings_request( + vpc_id=vpc_id, + 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 [202, 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 == 202: + 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 + + @overload + async def patch_peerings( + self, + vpc_id: str, + vpc_peering_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC Peering. + + To update the name of a VPC peering in a particular VPC, send a PATCH request + to ``/v2/vpcs/$VPC_ID/peerings/$VPC_PEERING_ID`` with the new ``name`` in the + request body. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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 = { + "name": "str" # Optional. The name of the VPC peering. Must be unique within + the team and may only contain alphanumeric characters and dashes. + } + + # response body for status code(s): 200 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 patch_peerings( + self, + vpc_id: str, + vpc_peering_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC Peering. + + To update the name of a VPC peering in a particular VPC, send a PATCH request + to ``/v2/vpcs/$VPC_ID/peerings/$VPC_PEERING_ID`` with the new ``name`` in the + request body. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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): 200 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 patch_peerings( + self, + vpc_id: str, + vpc_peering_id: str, + body: Union[JSON, IO[bytes]], + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC Peering. + + To update the name of a VPC peering in a particular VPC, send a PATCH request + to ``/v2/vpcs/$VPC_ID/peerings/$VPC_PEERING_ID`` with the new ``name`` in the + request body. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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 = { + "name": "str" # Optional. The name of the VPC peering. Must be unique within + the team and may only contain alphanumeric characters and dashes. + } + + # response body for status code(s): 200 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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: + _json = body + + _request = build_vpcs_patch_peerings_request( + vpc_id=vpc_id, + vpc_peering_id=vpc_peering_id, + 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 [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 + + +class VpcPeeringsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`vpc_peerings` 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, + region: Optional[str] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List All VPC Peerings. + + To list all of the VPC peerings on your account, send a GET request to ``/v2/vpc_peerings``. + + :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 + :keyword region: The slug identifier for the region where the resource is available. Known + values are: "ams1", "ams2", "ams3", "blr1", "fra1", "lon1", "nyc1", "nyc2", "nyc3", "sfo1", + "sfo2", "sfo3", "sgp1", "tor1", and "syd1". Default value is None. + :paramtype region: str + :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": {} + }, + "vpc_peerings": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must + be unique within the team and may only contain alphanumeric characters + and dashes. + "status": "str", # Optional. The current status of the VPC + peering. Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs + IDs. + ] + } + ] + } + # 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_vpc_peerings_list_request( + per_page=per_page, + page=page, + region=region, + 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 + + @overload + async def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New VPC Peering. + + To create a new VPC Peering, send a POST request to ``/v2/vpc_peerings`` + specifying a name and a list of two VPC IDs to peer. The response code, 202 + Accepted, does not indicate the success or failure of the operation, just + that the request has been accepted for processing. + + :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 = { + "name": "str", # Optional. The name of the VPC peering. Must be unique + within the team and may only contain alphanumeric characters and dashes. + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + + # response body for status code(s): 202 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + """ + + @overload + async def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New VPC Peering. + + To create a new VPC Peering, send a POST request to ``/v2/vpc_peerings`` + specifying a name and a list of two VPC IDs to peer. The response code, 202 + Accepted, does not indicate the success or failure of the operation, just + that the request has been accepted for processing. + + :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): 202 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + """ + + @distributed_trace_async + async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create a New VPC Peering. + + To create a new VPC Peering, send a POST request to ``/v2/vpc_peerings`` + specifying a name and a list of two VPC IDs to peer. The response code, 202 + Accepted, does not indicate the success or failure of the operation, just + that the request has been accepted for processing. + + :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 = { + "name": "str", # Optional. The name of the VPC peering. Must be unique + within the team and may only contain alphanumeric characters and dashes. + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + + # response body for status code(s): 202 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + """ + 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_vpc_peerings_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 [202]: + 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, vpc_peering_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Existing VPC Peering. + + To show information about an existing VPC Peering, send a GET request to + ``/v2/vpc_peerings/$VPC_PEERING_ID``. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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_vpc_peerings_get_request( + vpc_peering_id=vpc_peering_id, + 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 + + @overload + async def patch( + self, + vpc_peering_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC peering. + + To update the name of a VPC peering, send a PATCH request to + ``/v2/vpc_peerings/$VPC_PEERING_ID`` with the new ``name`` in the request body. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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 = { + "name": "str" # Optional. The name of the VPC peering. Must be unique within + the team and may only contain alphanumeric characters and dashes. + } + + # response body for status code(s): 200 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 patch( + self, + vpc_peering_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC peering. + + To update the name of a VPC peering, send a PATCH request to + ``/v2/vpc_peerings/$VPC_PEERING_ID`` with the new ``name`` in the request body. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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): 200 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 patch( + self, vpc_peering_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC peering. + + To update the name of a VPC peering, send a PATCH request to + ``/v2/vpc_peerings/$VPC_PEERING_ID`` with the new ``name`` in the request body. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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 = { + "name": "str" # Optional. The name of the VPC peering. Must be unique within + the team and may only contain alphanumeric characters and dashes. + } + + # response body for status code(s): 200 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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: + _json = body + + _request = build_vpc_peerings_patch_request( + vpc_peering_id=vpc_peering_id, + 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 [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, vpc_peering_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Delete a VPC peering. + + To delete a VPC peering, send a DELETE request to ``/v2/vpc_peerings/$VPC_PEERING_ID``. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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_vpc_peerings_delete_request( + vpc_peering_id=vpc_peering_id, + 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 [202, 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 == 202: + 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 UptimeOperations: """ diff --git a/src/pydo/operations/__init__.py b/src/pydo/operations/__init__.py index 930e654..86b8cfe 100644 --- a/src/pydo/operations/__init__.py +++ b/src/pydo/operations/__init__.py @@ -37,6 +37,7 @@ from ._operations import VolumeActionsOperations from ._operations import VolumeSnapshotsOperations from ._operations import VpcsOperations +from ._operations import VpcPeeringsOperations from ._operations import UptimeOperations from ._patch import __all__ as _patch_all @@ -77,6 +78,7 @@ "VolumeActionsOperations", "VolumeSnapshotsOperations", "VpcsOperations", + "VpcPeeringsOperations", "UptimeOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index 9a83b7d..22c5b12 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -7955,6 +7955,209 @@ def build_vpcs_list_members_request( ) +def build_vpcs_list_peerings_request( + vpc_id: str, *, 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/vpcs/{vpc_id}/peerings" + path_format_arguments = { + "vpc_id": _SERIALIZER.url("vpc_id", vpc_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_vpcs_create_peerings_request(vpc_id: 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/vpcs/{vpc_id}/peerings" + path_format_arguments = { + "vpc_id": _SERIALIZER.url("vpc_id", vpc_id, "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_vpcs_patch_peerings_request( + vpc_id: str, vpc_peering_id: 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/vpcs/{vpc_id}/peerings/{vpc_peering_id}" + path_format_arguments = { + "vpc_id": _SERIALIZER.url("vpc_id", vpc_id, "str"), + "vpc_peering_id": _SERIALIZER.url("vpc_peering_id", vpc_peering_id, "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="PATCH", url=_url, headers=_headers, **kwargs) + + +def build_vpc_peerings_list_request( + *, per_page: int = 20, page: int = 1, region: Optional[str] = None, **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/vpc_peerings" + + # 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) + if region is not None: + _params["region"] = _SERIALIZER.query("region", region, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_vpc_peerings_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/vpc_peerings" + + # 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_vpc_peerings_get_request(vpc_peering_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vpc_peerings/{vpc_peering_id}" + path_format_arguments = { + "vpc_peering_id": _SERIALIZER.url("vpc_peering_id", vpc_peering_id, "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_vpc_peerings_patch_request(vpc_peering_id: 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/vpc_peerings/{vpc_peering_id}" + path_format_arguments = { + "vpc_peering_id": _SERIALIZER.url("vpc_peering_id", vpc_peering_id, "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="PATCH", url=_url, headers=_headers, **kwargs) + + +def build_vpc_peerings_delete_request( + vpc_peering_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vpc_peerings/{vpc_peering_id}" + path_format_arguments = { + "vpc_peering_id": _SERIALIZER.url("vpc_peering_id", vpc_peering_id, "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_uptime_list_checks_request( *, per_page: int = 20, page: int = 1, **kwargs: Any ) -> HttpRequest: @@ -156199,6 +156402,1610 @@ def list_members( return cast(JSON, deserialized) # type: ignore + @distributed_trace + def list_peerings( + self, vpc_id: str, *, per_page: int = 20, page: int = 1, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List the Peerings of a VPC. + + To list all of a VPC's peerings, send a GET request to + ``/v2/vpcs/$VPC_ID/peerings``. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :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": {} + }, + "peerings": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must + be unique within the team and may only contain alphanumeric characters + and dashes. + "status": "str", # Optional. The current status of the VPC + peering. Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs + IDs. + ] + } + ] + } + # 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_vpcs_list_peerings_request( + vpc_id=vpc_id, + 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, 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 + + @overload + def create_peerings( + self, + vpc_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create a Peering with a VPC. + + To create a new VPC peering for a given VPC, send a POST request to + ``/v2/vpcs/$VPC_ID/peerings``. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :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 = { + "name": "str", # The name of the VPC peering. Must be unique and may only + contain alphanumeric characters, dashes, and periods. Required. + "vpc_id": "str" # The ID of the VPC to peer with. Required. + } + + # response body for status code(s): 202 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 create_peerings( + self, + vpc_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create a Peering with a VPC. + + To create a new VPC peering for a given VPC, send a POST request to + ``/v2/vpcs/$VPC_ID/peerings``. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :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): 202 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 create_peerings( + self, vpc_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Peering with a VPC. + + To create a new VPC peering for a given VPC, send a POST request to + ``/v2/vpcs/$VPC_ID/peerings``. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :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 = { + "name": "str", # The name of the VPC peering. Must be unique and may only + contain alphanumeric characters, dashes, and periods. Required. + "vpc_id": "str" # The ID of the VPC to peer with. Required. + } + + # response body for status code(s): 202 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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: + _json = body + + _request = build_vpcs_create_peerings_request( + vpc_id=vpc_id, + 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 [202, 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 == 202: + 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 + + @overload + def patch_peerings( + self, + vpc_id: str, + vpc_peering_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC Peering. + + To update the name of a VPC peering in a particular VPC, send a PATCH request + to ``/v2/vpcs/$VPC_ID/peerings/$VPC_PEERING_ID`` with the new ``name`` in the + request body. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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 = { + "name": "str" # Optional. The name of the VPC peering. Must be unique within + the team and may only contain alphanumeric characters and dashes. + } + + # response body for status code(s): 200 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 patch_peerings( + self, + vpc_id: str, + vpc_peering_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC Peering. + + To update the name of a VPC peering in a particular VPC, send a PATCH request + to ``/v2/vpcs/$VPC_ID/peerings/$VPC_PEERING_ID`` with the new ``name`` in the + request body. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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): 200 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 patch_peerings( + self, + vpc_id: str, + vpc_peering_id: str, + body: Union[JSON, IO[bytes]], + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC Peering. + + To update the name of a VPC peering in a particular VPC, send a PATCH request + to ``/v2/vpcs/$VPC_ID/peerings/$VPC_PEERING_ID`` with the new ``name`` in the + request body. + + :param vpc_id: A unique identifier for a VPC. Required. + :type vpc_id: str + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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 = { + "name": "str" # Optional. The name of the VPC peering. Must be unique within + the team and may only contain alphanumeric characters and dashes. + } + + # response body for status code(s): 200 + response == { + "peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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: + _json = body + + _request = build_vpcs_patch_peerings_request( + vpc_id=vpc_id, + vpc_peering_id=vpc_peering_id, + 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 [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 + + +class VpcPeeringsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`vpc_peerings` 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, + region: Optional[str] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List All VPC Peerings. + + To list all of the VPC peerings on your account, send a GET request to ``/v2/vpc_peerings``. + + :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 + :keyword region: The slug identifier for the region where the resource is available. Known + values are: "ams1", "ams2", "ams3", "blr1", "fra1", "lon1", "nyc1", "nyc2", "nyc3", "sfo1", + "sfo2", "sfo3", "sgp1", "tor1", and "syd1". Default value is None. + :paramtype region: str + :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": {} + }, + "vpc_peerings": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must + be unique within the team and may only contain alphanumeric characters + and dashes. + "status": "str", # Optional. The current status of the VPC + peering. Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs + IDs. + ] + } + ] + } + # 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_vpc_peerings_list_request( + per_page=per_page, + page=page, + region=region, + 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 + + @overload + def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New VPC Peering. + + To create a new VPC Peering, send a POST request to ``/v2/vpc_peerings`` + specifying a name and a list of two VPC IDs to peer. The response code, 202 + Accepted, does not indicate the success or failure of the operation, just + that the request has been accepted for processing. + + :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 = { + "name": "str", # Optional. The name of the VPC peering. Must be unique + within the team and may only contain alphanumeric characters and dashes. + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + + # response body for status code(s): 202 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + """ + + @overload + def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New VPC Peering. + + To create a new VPC Peering, send a POST request to ``/v2/vpc_peerings`` + specifying a name and a list of two VPC IDs to peer. The response code, 202 + Accepted, does not indicate the success or failure of the operation, just + that the request has been accepted for processing. + + :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): 202 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + """ + + @distributed_trace + def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create a New VPC Peering. + + To create a new VPC Peering, send a POST request to ``/v2/vpc_peerings`` + specifying a name and a list of two VPC IDs to peer. The response code, 202 + Accepted, does not indicate the success or failure of the operation, just + that the request has been accepted for processing. + + :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 = { + "name": "str", # Optional. The name of the VPC peering. Must be unique + within the team and may only contain alphanumeric characters and dashes. + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + + # response body for status code(s): 202 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + """ + 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_vpc_peerings_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 [202]: + 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, vpc_peering_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Existing VPC Peering. + + To show information about an existing VPC Peering, send a GET request to + ``/v2/vpc_peerings/$VPC_PEERING_ID``. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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_vpc_peerings_get_request( + vpc_peering_id=vpc_peering_id, + 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 + + @overload + def patch( + self, + vpc_peering_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC peering. + + To update the name of a VPC peering, send a PATCH request to + ``/v2/vpc_peerings/$VPC_PEERING_ID`` with the new ``name`` in the request body. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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 = { + "name": "str" # Optional. The name of the VPC peering. Must be unique within + the team and may only contain alphanumeric characters and dashes. + } + + # response body for status code(s): 200 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 patch( + self, + vpc_peering_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC peering. + + To update the name of a VPC peering, send a PATCH request to + ``/v2/vpc_peerings/$VPC_PEERING_ID`` with the new ``name`` in the request body. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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): 200 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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 patch( + self, vpc_peering_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a VPC peering. + + To update the name of a VPC peering, send a PATCH request to + ``/v2/vpc_peerings/$VPC_PEERING_ID`` with the new ``name`` in the request body. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :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 = { + "name": "str" # Optional. The name of the VPC peering. Must be unique within + the team and may only contain alphanumeric characters and dashes. + } + + # response body for status code(s): 200 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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: + _json = body + + _request = build_vpc_peerings_patch_request( + vpc_peering_id=vpc_peering_id, + 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 [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, vpc_peering_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Delete a VPC peering. + + To delete a VPC peering, send a DELETE request to ``/v2/vpc_peerings/$VPC_PEERING_ID``. + + :param vpc_peering_id: A unique identifier for a VPC peering. Required. + :type vpc_peering_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "vpc_peering": { + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format. + "id": "str", # Optional. A unique ID that can be used to identify + and reference the VPC peering. + "name": "str", # Optional. The name of the VPC peering. Must be + unique within the team and may only contain alphanumeric characters and + dashes. + "status": "str", # Optional. The current status of the VPC peering. + Known values are: "PROVISIONING", "ACTIVE", and "DELETING". + "vpc_ids": [ + "str" # Optional. An array of the two peered VPCs IDs. + ] + } + } + # 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_vpc_peerings_delete_request( + vpc_peering_id=vpc_peering_id, + 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 [202, 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 == 202: + 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 UptimeOperations: """