diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index 2676a70..041f0bc 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -99a6576 +d1aa624 diff --git a/src/pydo/_client.py b/src/pydo/_client.py index 36c327f..2258638 100644 --- a/src/pydo/_client.py +++ b/src/pydo/_client.py @@ -17,6 +17,7 @@ AccountOperations, ActionsOperations, AppsOperations, + AutoscalepoolsOperations, BalanceOperations, BillingHistoryOperations, CdnOperations, @@ -589,6 +590,8 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype droplets: pydo.operations.DropletsOperations :ivar droplet_actions: DropletActionsOperations operations :vartype droplet_actions: pydo.operations.DropletActionsOperations + :ivar autoscalepools: AutoscalepoolsOperations operations + :vartype autoscalepools: pydo.operations.AutoscalepoolsOperations :ivar firewalls: FirewallsOperations operations :vartype firewalls: pydo.operations.FirewallsOperations :ivar functions: FunctionsOperations operations @@ -715,6 +718,9 @@ def __init__( self.droplet_actions = DropletActionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.autoscalepools = AutoscalepoolsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.firewalls = FirewallsOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/src/pydo/aio/_client.py b/src/pydo/aio/_client.py index 967be06..f4be6b3 100644 --- a/src/pydo/aio/_client.py +++ b/src/pydo/aio/_client.py @@ -17,6 +17,7 @@ AccountOperations, ActionsOperations, AppsOperations, + AutoscalepoolsOperations, BalanceOperations, BillingHistoryOperations, CdnOperations, @@ -589,6 +590,8 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype droplets: pydo.aio.operations.DropletsOperations :ivar droplet_actions: DropletActionsOperations operations :vartype droplet_actions: pydo.aio.operations.DropletActionsOperations + :ivar autoscalepools: AutoscalepoolsOperations operations + :vartype autoscalepools: pydo.aio.operations.AutoscalepoolsOperations :ivar firewalls: FirewallsOperations operations :vartype firewalls: pydo.aio.operations.FirewallsOperations :ivar functions: FunctionsOperations operations @@ -715,6 +718,9 @@ def __init__( self.droplet_actions = DropletActionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.autoscalepools = AutoscalepoolsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.firewalls = FirewallsOperations( 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 86b8cfe..ffa4ab4 100644 --- a/src/pydo/aio/operations/__init__.py +++ b/src/pydo/aio/operations/__init__.py @@ -18,6 +18,7 @@ from ._operations import DomainsOperations from ._operations import DropletsOperations from ._operations import DropletActionsOperations +from ._operations import AutoscalepoolsOperations from ._operations import FirewallsOperations from ._operations import FunctionsOperations from ._operations import ImagesOperations @@ -59,6 +60,7 @@ "DomainsOperations", "DropletsOperations", "DropletActionsOperations", + "AutoscalepoolsOperations", "FirewallsOperations", "FunctionsOperations", "ImagesOperations", diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index e27d915..e2be2a7 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -66,6 +66,14 @@ build_apps_update_request, build_apps_validate_app_spec_request, build_apps_validate_rollback_request, + build_autoscalepools_create_request, + build_autoscalepools_delete_dangerous_request, + build_autoscalepools_delete_request, + build_autoscalepools_get_request, + build_autoscalepools_list_history_request, + build_autoscalepools_list_members_request, + build_autoscalepools_list_request, + build_autoscalepools_update_request, build_balance_get_request, build_billing_history_list_request, build_cdn_create_endpoint_request, @@ -114865,6 +114873,1798 @@ async def get(self, droplet_id: int, action_id: int, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore +class AutoscalepoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`autoscalepools` 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, + name: Optional[str] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List All Autoscale Pools. + + To list all autoscale pools in your team, send a GET request to ``/v2/droplets/autoscale``. + The response body will be a JSON object with a key of ``autoscale_pools`` containing an array + of autoscale pool objects. + These each contain the standard autoscale pool attributes. + + :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 name: The name of the autoscale pool. Default value is None. + :paramtype name: 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. + }, + "autoscale_pools": [ + { + "active_resources_count": 0, # The number of active Droplets + in the autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in + ISO8601 combined date and time format that represents when the autoscale + pool was created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for + all Droplets in the autoscale pool. You may specify the slug or the + image ID. Required. + "region": "str", # The datacenter in which all of + the Droplets will be created. Required. Known values are: "nyc1", + "nyc2", "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", + "lon1", "fra1", "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the + Droplets in the autoscale pool. You can either specify the key ID + or the fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 + address to each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied + to all Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that + the Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each + of the Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing + user data that cloud-init consumes to configure a Droplet on first + boot. User data is often a cloud-config file or Bash script. It must + be plain text and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the + Droplets in the autoscale pool will be created. The VPC must be in + the region where you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the + Droplet agent. This must be set to true to monitor Droplets for + resource utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool + instance. This is automatically generated upon autoscale pool creation. + Required. + "name": "str", # The human-readable name set for the + autoscale pool. Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in + ISO8601 combined date and time format that represents when the autoscale + pool was last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization + of the autoscale pool. + "memory": 0.0 # Optional. The average memory + utilization of the autoscale pool. + } + } + ], + "links": { + "pages": {} + } + } + """ + 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_autoscalepools_list_request( + per_page=per_page, + page=page, + name=name, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def create( + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Autoscale Pool. + + To create a new autoscale pool, send a POST request to ``/v2/droplets/autoscale`` setting the + required attributes. + + The response body will contain a JSON object with a key called ``autoscale_pool`` containing + the standard attributes for the new autoscale pool. + + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": {}, + "droplet_template": { + "image": "str", # The Droplet image to be used for all Droplets in + the autoscale pool. You may specify the slug or the image ID. Required. + "region": "str", # The datacenter in which all of the Droplets will + be created. Required. Known values are: "nyc1", "nyc2", "nyc3", "ams2", + "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", "tor1", "blr1", and + "syd1". + "size": "str", # The Droplet size to be used for all Droplets in the + autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets in the + autoscale pool. You can either specify the key ID or the fingerprint. + Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to each of + the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all Droplets + in the autoscale pool. + "project_id": "str", # Optional. The project that the Droplets in + the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the Droplets + in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user data that + cloud-init consumes to configure a Droplet on first boot. User data is often + a cloud-config file or Bash script. It must be plain text and may not exceed + 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in the + autoscale pool will be created. The VPC must be in the region where you want + to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet agent. + This must be set to true to monitor Droplets for resource utilization + scaling. + }, + "name": "str" # The human-readable name of the autoscale pool. This field + cannot be updated. Required. + } + + # response body for status code(s): 202 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + """ + + @overload + async def create( + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Autoscale Pool. + + To create a new autoscale pool, send a POST request to ``/v2/droplets/autoscale`` setting the + required attributes. + + The response body will contain a JSON object with a key called ``autoscale_pool`` containing + the standard attributes for the new autoscale pool. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + """ + + @distributed_trace_async + async def create( + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Autoscale Pool. + + To create a new autoscale pool, send a POST request to ``/v2/droplets/autoscale`` setting the + required attributes. + + The response body will contain a JSON object with a key called ``autoscale_pool`` containing + the standard attributes for the new autoscale pool. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": {}, + "droplet_template": { + "image": "str", # The Droplet image to be used for all Droplets in + the autoscale pool. You may specify the slug or the image ID. Required. + "region": "str", # The datacenter in which all of the Droplets will + be created. Required. Known values are: "nyc1", "nyc2", "nyc3", "ams2", + "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", "tor1", "blr1", and + "syd1". + "size": "str", # The Droplet size to be used for all Droplets in the + autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets in the + autoscale pool. You can either specify the key ID or the fingerprint. + Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to each of + the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all Droplets + in the autoscale pool. + "project_id": "str", # Optional. The project that the Droplets in + the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the Droplets + in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user data that + cloud-init consumes to configure a Droplet on first boot. User data is often + a cloud-config file or Bash script. It must be plain text and may not exceed + 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in the + autoscale pool will be created. The VPC must be in the region where you want + to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet agent. + This must be set to true to monitor Droplets for resource utilization + scaling. + }, + "name": "str" # The human-readable name of the autoscale pool. This field + cannot be updated. Required. + } + + # response body for status code(s): 202 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_autoscalepools_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, autoscale_pool_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Existing Autoscale Pool. + + To show information about an individual autoscale pool, send a GET request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID``. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + # 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_autoscalepools_get_request( + autoscale_pool_id=autoscale_pool_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 update( + self, + autoscale_pool_id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Autoscale Pool. + + To update the configuration of an existing autoscale pool, send a PUT request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID``. The request must contain a full representation + of the autoscale pool including existing attributes. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": {}, + "droplet_template": { + "image": "str", # The Droplet image to be used for all Droplets in + the autoscale pool. You may specify the slug or the image ID. Required. + "region": "str", # The datacenter in which all of the Droplets will + be created. Required. Known values are: "nyc1", "nyc2", "nyc3", "ams2", + "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", "tor1", "blr1", and + "syd1". + "size": "str", # The Droplet size to be used for all Droplets in the + autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets in the + autoscale pool. You can either specify the key ID or the fingerprint. + Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to each of + the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all Droplets + in the autoscale pool. + "project_id": "str", # Optional. The project that the Droplets in + the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the Droplets + in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user data that + cloud-init consumes to configure a Droplet on first boot. User data is often + a cloud-config file or Bash script. It must be plain text and may not exceed + 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in the + autoscale pool will be created. The VPC must be in the region where you want + to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet agent. + This must be set to true to monitor Droplets for resource utilization + scaling. + }, + "name": "str" # The human-readable name of the autoscale pool. This field + cannot be updated. Required. + } + + # response body for status code(s): 200 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + # 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 update( + self, + autoscale_pool_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Autoscale Pool. + + To update the configuration of an existing autoscale pool, send a PUT request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID``. The request must contain a full representation + of the autoscale pool including existing attributes. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + # 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 update( + self, + autoscale_pool_id: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Autoscale Pool. + + To update the configuration of an existing autoscale pool, send a PUT request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID``. The request must contain a full representation + of the autoscale pool including existing attributes. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": {}, + "droplet_template": { + "image": "str", # The Droplet image to be used for all Droplets in + the autoscale pool. You may specify the slug or the image ID. Required. + "region": "str", # The datacenter in which all of the Droplets will + be created. Required. Known values are: "nyc1", "nyc2", "nyc3", "ams2", + "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", "tor1", "blr1", and + "syd1". + "size": "str", # The Droplet size to be used for all Droplets in the + autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets in the + autoscale pool. You can either specify the key ID or the fingerprint. + Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to each of + the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all Droplets + in the autoscale pool. + "project_id": "str", # Optional. The project that the Droplets in + the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the Droplets + in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user data that + cloud-init consumes to configure a Droplet on first boot. User data is often + a cloud-config file or Bash script. It must be plain text and may not exceed + 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in the + autoscale pool will be created. The VPC must be in the region where you want + to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet agent. + This must be set to true to monitor Droplets for resource utilization + scaling. + }, + "name": "str" # The human-readable name of the autoscale pool. This field + cannot be updated. Required. + } + + # response body for status code(s): 200 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_autoscalepools_update_request( + autoscale_pool_id=autoscale_pool_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, autoscale_pool_id: str, **kwargs: Any) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete autoscale pool. + + To destroy an autoscale pool, send a DELETE request to the + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID`` endpoint. + + A successful response will include a 202 response code and no content. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_autoscalepools_delete_request( + autoscale_pool_id=autoscale_pool_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) + + deserialized = None + 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.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, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_dangerous( + self, autoscale_pool_id: str, *, x_dangerous: bool, **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete autoscale pool and resources. + + To destroy an autoscale pool and its associated resources (Droplets), + send a DELETE request to the ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/dangerous`` endpoint. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :keyword x_dangerous: Acknowledge this action will destroy the autoscale pool and its + associated resources and *can not* be reversed. Required. + :paramtype x_dangerous: bool + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_autoscalepools_delete_dangerous_request( + autoscale_pool_id=autoscale_pool_id, + x_dangerous=x_dangerous, + 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) + + deserialized = None + 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.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, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_members( + self, + autoscale_pool_id: str, + *, + per_page: int = 20, + page: int = 1, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List members. + + To list the Droplets in an autoscale pool, send a GET request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/members``. + + The response body will be a JSON object with a key of ``droplets``. This will be + set to an array containing information about each of the Droplets in the autoscale pool. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_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. + }, + "droplets": [ + { + "created_at": "2020-02-20 00:00:00", # The creation time of + the Droplet in ISO8601 combined date and time format. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The CPU utilization average + of the individual Droplet. + "memory": 0.0 # Optional. The memory utilization + average of the individual Droplet. + }, + "droplet_id": 0, # The unique identifier of the Droplet. + Required. + "health_status": "str", # The health status of the Droplet. + Required. + "status": "str", # The power status of the Droplet. + Required. Known values are: "provisioning", "active", "deleting", and + "off". + "updated_at": "2020-02-20 00:00:00" # The last updated time + of the Droplet in ISO8601 combined date and time format. Required. + } + ], + "links": { + "pages": {} + } + } + # 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_autoscalepools_list_members_request( + autoscale_pool_id=autoscale_pool_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 + + @distributed_trace_async + async def list_history( + self, + autoscale_pool_id: str, + *, + per_page: int = 20, + page: int = 1, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List history events. + + To list all of the scaling history events of an autoscale pool, send a GET request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/history``. + + The response body will be a JSON object with a key of ``history``. This will be + set to an array containing objects each representing a history event. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_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. + }, + "history": [ + { + "created_at": "2020-02-20 00:00:00", # The creation time of + the history event in ISO8601 combined date and time format. Required. + "current_instance_count": 0, # The current number of + Droplets in the autoscale pool. Required. + "desired_instance_count": 0, # The target number of Droplets + for the autoscale pool after the scaling event. Required. + "history_event_id": "str", # The unique identifier of the + history event. Required. + "reason": "str", # The reason for the scaling event. + Required. Known values are: "CONFIGURATION_CHANGE", "SCALE_UP", and + "SCALE_DOWN". + "status": "str", # The status of the scaling event. + Required. Known values are: "in_progress", "success", and "error". + "updated_at": "2020-02-20 00:00:00" # The last updated time + of the history event in ISO8601 combined date and time format. Required. + } + ], + "links": { + "pages": {} + } + } + # 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_autoscalepools_list_history_request( + autoscale_pool_id=autoscale_pool_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 + + class FirewallsOperations: """ .. warning:: diff --git a/src/pydo/operations/__init__.py b/src/pydo/operations/__init__.py index 86b8cfe..ffa4ab4 100644 --- a/src/pydo/operations/__init__.py +++ b/src/pydo/operations/__init__.py @@ -18,6 +18,7 @@ from ._operations import DomainsOperations from ._operations import DropletsOperations from ._operations import DropletActionsOperations +from ._operations import AutoscalepoolsOperations from ._operations import FirewallsOperations from ._operations import FunctionsOperations from ._operations import ImagesOperations @@ -59,6 +60,7 @@ "DomainsOperations", "DropletsOperations", "DropletActionsOperations", + "AutoscalepoolsOperations", "FirewallsOperations", "FunctionsOperations", "ImagesOperations", diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index 54991da..8f727ec 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -3691,6 +3691,224 @@ def build_droplet_actions_get_request( return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) +def build_autoscalepools_list_request( + *, per_page: int = 20, page: int = 1, name: 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/droplets/autoscale" + + # 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 name is not None: + _params["name"] = _SERIALIZER.query("name", name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_autoscalepools_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/droplets/autoscale" + + # 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_autoscalepools_get_request( + autoscale_pool_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/droplets/autoscale/{autoscale_pool_id}" + path_format_arguments = { + "autoscale_pool_id": _SERIALIZER.url( + "autoscale_pool_id", autoscale_pool_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_autoscalepools_update_request( + autoscale_pool_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/droplets/autoscale/{autoscale_pool_id}" + path_format_arguments = { + "autoscale_pool_id": _SERIALIZER.url( + "autoscale_pool_id", autoscale_pool_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="PUT", url=_url, headers=_headers, **kwargs) + + +def build_autoscalepools_delete_request( + autoscale_pool_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/droplets/autoscale/{autoscale_pool_id}" + path_format_arguments = { + "autoscale_pool_id": _SERIALIZER.url( + "autoscale_pool_id", autoscale_pool_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_autoscalepools_delete_dangerous_request( # pylint: disable=name-too-long + autoscale_pool_id: str, *, x_dangerous: bool, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/droplets/autoscale/{autoscale_pool_id}/dangerous" + path_format_arguments = { + "autoscale_pool_id": _SERIALIZER.url( + "autoscale_pool_id", autoscale_pool_id, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["X-Dangerous"] = _SERIALIZER.header("x_dangerous", x_dangerous, "bool") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + + +def build_autoscalepools_list_members_request( # pylint: disable=name-too-long + autoscale_pool_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/droplets/autoscale/{autoscale_pool_id}/members" + path_format_arguments = { + "autoscale_pool_id": _SERIALIZER.url( + "autoscale_pool_id", autoscale_pool_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_autoscalepools_list_history_request( # pylint: disable=name-too-long + autoscale_pool_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/droplets/autoscale/{autoscale_pool_id}/history" + path_format_arguments = { + "autoscale_pool_id": _SERIALIZER.url( + "autoscale_pool_id", autoscale_pool_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_firewalls_list_request( *, per_page: int = 20, page: int = 1, **kwargs: Any ) -> HttpRequest: @@ -123148,6 +123366,1798 @@ def get(self, droplet_id: int, action_id: int, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore +class AutoscalepoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`autoscalepools` 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, + name: Optional[str] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List All Autoscale Pools. + + To list all autoscale pools in your team, send a GET request to ``/v2/droplets/autoscale``. + The response body will be a JSON object with a key of ``autoscale_pools`` containing an array + of autoscale pool objects. + These each contain the standard autoscale pool attributes. + + :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 name: The name of the autoscale pool. Default value is None. + :paramtype name: 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. + }, + "autoscale_pools": [ + { + "active_resources_count": 0, # The number of active Droplets + in the autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in + ISO8601 combined date and time format that represents when the autoscale + pool was created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for + all Droplets in the autoscale pool. You may specify the slug or the + image ID. Required. + "region": "str", # The datacenter in which all of + the Droplets will be created. Required. Known values are: "nyc1", + "nyc2", "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", + "lon1", "fra1", "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the + Droplets in the autoscale pool. You can either specify the key ID + or the fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 + address to each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied + to all Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that + the Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each + of the Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing + user data that cloud-init consumes to configure a Droplet on first + boot. User data is often a cloud-config file or Bash script. It must + be plain text and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the + Droplets in the autoscale pool will be created. The VPC must be in + the region where you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the + Droplet agent. This must be set to true to monitor Droplets for + resource utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool + instance. This is automatically generated upon autoscale pool creation. + Required. + "name": "str", # The human-readable name set for the + autoscale pool. Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in + ISO8601 combined date and time format that represents when the autoscale + pool was last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization + of the autoscale pool. + "memory": 0.0 # Optional. The average memory + utilization of the autoscale pool. + } + } + ], + "links": { + "pages": {} + } + } + """ + 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_autoscalepools_list_request( + per_page=per_page, + page=page, + name=name, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def create( + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Autoscale Pool. + + To create a new autoscale pool, send a POST request to ``/v2/droplets/autoscale`` setting the + required attributes. + + The response body will contain a JSON object with a key called ``autoscale_pool`` containing + the standard attributes for the new autoscale pool. + + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": {}, + "droplet_template": { + "image": "str", # The Droplet image to be used for all Droplets in + the autoscale pool. You may specify the slug or the image ID. Required. + "region": "str", # The datacenter in which all of the Droplets will + be created. Required. Known values are: "nyc1", "nyc2", "nyc3", "ams2", + "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", "tor1", "blr1", and + "syd1". + "size": "str", # The Droplet size to be used for all Droplets in the + autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets in the + autoscale pool. You can either specify the key ID or the fingerprint. + Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to each of + the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all Droplets + in the autoscale pool. + "project_id": "str", # Optional. The project that the Droplets in + the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the Droplets + in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user data that + cloud-init consumes to configure a Droplet on first boot. User data is often + a cloud-config file or Bash script. It must be plain text and may not exceed + 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in the + autoscale pool will be created. The VPC must be in the region where you want + to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet agent. + This must be set to true to monitor Droplets for resource utilization + scaling. + }, + "name": "str" # The human-readable name of the autoscale pool. This field + cannot be updated. Required. + } + + # response body for status code(s): 202 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + """ + + @overload + def create( + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Autoscale Pool. + + To create a new autoscale pool, send a POST request to ``/v2/droplets/autoscale`` setting the + required attributes. + + The response body will contain a JSON object with a key called ``autoscale_pool`` containing + the standard attributes for the new autoscale pool. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + """ + + @distributed_trace + def create( + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Autoscale Pool. + + To create a new autoscale pool, send a POST request to ``/v2/droplets/autoscale`` setting the + required attributes. + + The response body will contain a JSON object with a key called ``autoscale_pool`` containing + the standard attributes for the new autoscale pool. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": {}, + "droplet_template": { + "image": "str", # The Droplet image to be used for all Droplets in + the autoscale pool. You may specify the slug or the image ID. Required. + "region": "str", # The datacenter in which all of the Droplets will + be created. Required. Known values are: "nyc1", "nyc2", "nyc3", "ams2", + "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", "tor1", "blr1", and + "syd1". + "size": "str", # The Droplet size to be used for all Droplets in the + autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets in the + autoscale pool. You can either specify the key ID or the fingerprint. + Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to each of + the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all Droplets + in the autoscale pool. + "project_id": "str", # Optional. The project that the Droplets in + the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the Droplets + in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user data that + cloud-init consumes to configure a Droplet on first boot. User data is often + a cloud-config file or Bash script. It must be plain text and may not exceed + 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in the + autoscale pool will be created. The VPC must be in the region where you want + to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet agent. + This must be set to true to monitor Droplets for resource utilization + scaling. + }, + "name": "str" # The human-readable name of the autoscale pool. This field + cannot be updated. Required. + } + + # response body for status code(s): 202 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_autoscalepools_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, autoscale_pool_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Existing Autoscale Pool. + + To show information about an individual autoscale pool, send a GET request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID``. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + # 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_autoscalepools_get_request( + autoscale_pool_id=autoscale_pool_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 update( + self, + autoscale_pool_id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Autoscale Pool. + + To update the configuration of an existing autoscale pool, send a PUT request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID``. The request must contain a full representation + of the autoscale pool including existing attributes. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": {}, + "droplet_template": { + "image": "str", # The Droplet image to be used for all Droplets in + the autoscale pool. You may specify the slug or the image ID. Required. + "region": "str", # The datacenter in which all of the Droplets will + be created. Required. Known values are: "nyc1", "nyc2", "nyc3", "ams2", + "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", "tor1", "blr1", and + "syd1". + "size": "str", # The Droplet size to be used for all Droplets in the + autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets in the + autoscale pool. You can either specify the key ID or the fingerprint. + Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to each of + the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all Droplets + in the autoscale pool. + "project_id": "str", # Optional. The project that the Droplets in + the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the Droplets + in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user data that + cloud-init consumes to configure a Droplet on first boot. User data is often + a cloud-config file or Bash script. It must be plain text and may not exceed + 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in the + autoscale pool will be created. The VPC must be in the region where you want + to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet agent. + This must be set to true to monitor Droplets for resource utilization + scaling. + }, + "name": "str" # The human-readable name of the autoscale pool. This field + cannot be updated. Required. + } + + # response body for status code(s): 200 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + # 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 update( + self, + autoscale_pool_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Autoscale Pool. + + To update the configuration of an existing autoscale pool, send a PUT request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID``. The request must contain a full representation + of the autoscale pool including existing attributes. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + # 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 update( + self, + autoscale_pool_id: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Autoscale Pool. + + To update the configuration of an existing autoscale pool, send a PUT request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID``. The request must contain a full representation + of the autoscale pool including existing attributes. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": {}, + "droplet_template": { + "image": "str", # The Droplet image to be used for all Droplets in + the autoscale pool. You may specify the slug or the image ID. Required. + "region": "str", # The datacenter in which all of the Droplets will + be created. Required. Known values are: "nyc1", "nyc2", "nyc3", "ams2", + "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", "tor1", "blr1", and + "syd1". + "size": "str", # The Droplet size to be used for all Droplets in the + autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets in the + autoscale pool. You can either specify the key ID or the fingerprint. + Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to each of + the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all Droplets + in the autoscale pool. + "project_id": "str", # Optional. The project that the Droplets in + the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the Droplets + in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user data that + cloud-init consumes to configure a Droplet on first boot. User data is often + a cloud-config file or Bash script. It must be plain text and may not exceed + 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in the + autoscale pool will be created. The VPC must be in the region where you want + to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet agent. + This must be set to true to monitor Droplets for resource utilization + scaling. + }, + "name": "str" # The human-readable name of the autoscale pool. This field + cannot be updated. Required. + } + + # response body for status code(s): 200 + response == { + "autoscale_pool": { + "active_resources_count": 0, # The number of active Droplets in the + autoscale pool. Required. + "config": {}, + "created_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + created. Required. + "droplet_template": { + "image": "str", # The Droplet image to be used for all + Droplets in the autoscale pool. You may specify the slug or the image ID. + Required. + "region": "str", # The datacenter in which all of the + Droplets will be created. Required. Known values are: "nyc1", "nyc2", + "nyc3", "ams2", "ams3", "sfo1", "sfo2", "sfo3", "sgp1", "lon1", "fra1", + "tor1", "blr1", and "syd1". + "size": "str", # The Droplet size to be used for all + Droplets in the autoscale pool. Required. + "ssh_keys": [ + "str" # The SSH keys to be installed on the Droplets + in the autoscale pool. You can either specify the key ID or the + fingerprint. Required. + ], + "ipv6": bool, # Optional. Assigns a unique IPv6 address to + each of the Droplets in the autoscale pool. + "name": "str", # Optional. The name(s) to be applied to all + Droplets in the autoscale pool. + "project_id": "str", # Optional. The project that the + Droplets in the autoscale pool will belong to. + "tags": [ + "str" # Optional. The tags to apply to each of the + Droplets in the autoscale pool. + ], + "user_data": "str", # Optional. A string containing user + data that cloud-init consumes to configure a Droplet on first boot. User + data is often a cloud-config file or Bash script. It must be plain text + and may not exceed 64 KiB in size. + "vpc_uuid": "str", # Optional. The VPC where the Droplets in + the autoscale pool will be created. The VPC must be in the region where + you want to create the Droplets. + "with_droplet_agent": bool # Optional. Installs the Droplet + agent. This must be set to true to monitor Droplets for resource + utilization scaling. + }, + "id": "str", # A unique identifier for each autoscale pool instance. + This is automatically generated upon autoscale pool creation. Required. + "name": "str", # The human-readable name set for the autoscale pool. + Required. + "status": "str", # The current status of the autoscale pool. + Required. Known values are: "active", "deleting", and "error". + "updated_at": "2020-02-20 00:00:00", # A time value given in ISO8601 + combined date and time format that represents when the autoscale pool was + last updated. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The average CPU utilization of the + autoscale pool. + "memory": 0.0 # Optional. The average memory utilization of + the autoscale pool. + } + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_autoscalepools_update_request( + autoscale_pool_id=autoscale_pool_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, autoscale_pool_id: str, **kwargs: Any) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete autoscale pool. + + To destroy an autoscale pool, send a DELETE request to the + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID`` endpoint. + + A successful response will include a 202 response code and no content. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_autoscalepools_delete_request( + autoscale_pool_id=autoscale_pool_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) + + deserialized = None + 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.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, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_dangerous( + self, autoscale_pool_id: str, *, x_dangerous: bool, **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete autoscale pool and resources. + + To destroy an autoscale pool and its associated resources (Droplets), + send a DELETE request to the ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/dangerous`` endpoint. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_id: str + :keyword x_dangerous: Acknowledge this action will destroy the autoscale pool and its + associated resources and *can not* be reversed. Required. + :paramtype x_dangerous: bool + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_autoscalepools_delete_dangerous_request( + autoscale_pool_id=autoscale_pool_id, + x_dangerous=x_dangerous, + 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) + + deserialized = None + 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.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, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_members( + self, + autoscale_pool_id: str, + *, + per_page: int = 20, + page: int = 1, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List members. + + To list the Droplets in an autoscale pool, send a GET request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/members``. + + The response body will be a JSON object with a key of ``droplets``. This will be + set to an array containing information about each of the Droplets in the autoscale pool. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_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. + }, + "droplets": [ + { + "created_at": "2020-02-20 00:00:00", # The creation time of + the Droplet in ISO8601 combined date and time format. Required. + "current_utilization": { + "cpu": 0.0, # Optional. The CPU utilization average + of the individual Droplet. + "memory": 0.0 # Optional. The memory utilization + average of the individual Droplet. + }, + "droplet_id": 0, # The unique identifier of the Droplet. + Required. + "health_status": "str", # The health status of the Droplet. + Required. + "status": "str", # The power status of the Droplet. + Required. Known values are: "provisioning", "active", "deleting", and + "off". + "updated_at": "2020-02-20 00:00:00" # The last updated time + of the Droplet in ISO8601 combined date and time format. Required. + } + ], + "links": { + "pages": {} + } + } + # 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_autoscalepools_list_members_request( + autoscale_pool_id=autoscale_pool_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 + + @distributed_trace + def list_history( + self, + autoscale_pool_id: str, + *, + per_page: int = 20, + page: int = 1, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List history events. + + To list all of the scaling history events of an autoscale pool, send a GET request to + ``/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/history``. + + The response body will be a JSON object with a key of ``history``. This will be + set to an array containing objects each representing a history event. + + :param autoscale_pool_id: A unique identifier for an autoscale pool. Required. + :type autoscale_pool_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. + }, + "history": [ + { + "created_at": "2020-02-20 00:00:00", # The creation time of + the history event in ISO8601 combined date and time format. Required. + "current_instance_count": 0, # The current number of + Droplets in the autoscale pool. Required. + "desired_instance_count": 0, # The target number of Droplets + for the autoscale pool after the scaling event. Required. + "history_event_id": "str", # The unique identifier of the + history event. Required. + "reason": "str", # The reason for the scaling event. + Required. Known values are: "CONFIGURATION_CHANGE", "SCALE_UP", and + "SCALE_DOWN". + "status": "str", # The status of the scaling event. + Required. Known values are: "in_progress", "success", and "error". + "updated_at": "2020-02-20 00:00:00" # The last updated time + of the history event in ISO8601 combined date and time format. Required. + } + ], + "links": { + "pages": {} + } + } + # 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_autoscalepools_list_history_request( + autoscale_pool_id=autoscale_pool_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 + + class FirewallsOperations: """ .. warning::