diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index f712b54..ca12bb7 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -12a6416 +47108d8 diff --git a/requirements.txt b/requirements.txt index 830c840..5524bd2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -aiohttp==3.9.5 ; python_version >= "3.8" and python_full_version < "4.0.0" +aiohappyeyeballs==2.3.5 ; python_version >= "3.8" and python_full_version < "4.0.0" +aiohttp==3.10.2 ; python_version >= "3.8" and python_full_version < "4.0.0" aiosignal==1.3.1 ; python_version >= "3.8" and python_full_version < "4.0.0" async-timeout==4.0.3 ; python_version >= "3.8" and python_version < "3.11" attrs==23.2.0 ; python_version >= "3.8" and python_full_version < "4.0.0" diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index 289e280..899607e 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -88,6 +88,7 @@ build_databases_delete_kafka_topic_request, build_databases_delete_logsink_request, build_databases_delete_online_migration_request, + build_databases_delete_opensearch_index_request, build_databases_delete_request, build_databases_delete_user_request, build_databases_destroy_cluster_request, @@ -112,6 +113,7 @@ build_databases_list_firewall_rules_request, build_databases_list_kafka_topics_request, build_databases_list_logsink_request, + build_databases_list_opeasearch_indexes_request, build_databases_list_options_request, build_databases_list_replicas_request, build_databases_list_request, @@ -102537,6 +102539,248 @@ async def update_cluster_metrics_credentials( # pylint: disable=inconsistent-re if cls: return cls(pipeline_response, None, response_headers) # type: ignore + @distributed_trace_async + async def list_opeasearch_indexes( + self, database_cluster_uuid: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Indexes for a OpenSearch Cluster. + + To list all of a OpenSearch cluster's indexes, send a GET request to + ``/v2/databases/$DATABASE_ID/indexes``. + + The result will be a JSON object with a ``indexes`` key. + + :param database_cluster_uuid: A unique identifier for a database cluster. Required. + :type database_cluster_uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "indexes": [ + { + "created_time": "2020-02-20 00:00:00", # Optional. The date + and time the index was created. + "health": "str", # Optional. The health of the OpenSearch + index. Known values are: "unknown", "green", "yellow", "red", and "red*". + "index_name": "str", # Optional. The name of the opensearch + index. + "number_of_replicas": 0, # Optional. The number of replicas + for the index. + "number_of_shards": 0, # Optional. The number of shards for + the index. + "size": 0, # Optional. The size of the index. + "status": "str" # Optional. The status of the OpenSearch + index. Known values are: "unknown", "open", "close", and "none". + } + ] + } + # 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_databases_list_opeasearch_indexes_request( + database_cluster_uuid=database_cluster_uuid, + 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_opensearch_index( + self, database_cluster_uuid: str, index_name: str, **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete Index for OpenSearch Cluster. + + To delete a single index within OpenSearch cluster, send a DELETE request + to ``/v2/databases/$DATABASE_ID/indexes/$INDEX_NAME``. + + A status of 204 will be given. This indicates that the request was + processed successfully, but that no response body is needed. + + :param database_cluster_uuid: A unique identifier for a database cluster. Required. + :type database_cluster_uuid: str + :param index_name: The name of the OpenSearch index. Required. + :type index_name: 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_databases_delete_opensearch_index_request( + database_cluster_uuid=database_cluster_uuid, + index_name=index_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 [204, 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 == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + class DomainsOperations: """ diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index ec3261c..958651f 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -2732,6 +2732,53 @@ def build_databases_update_cluster_metrics_credentials_request( # pylint: disab return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) +def build_databases_list_opeasearch_indexes_request( # pylint: disable=name-too-long + database_cluster_uuid: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/databases/{database_cluster_uuid}/indexes" + path_format_arguments = { + "database_cluster_uuid": _SERIALIZER.url( + "database_cluster_uuid", database_cluster_uuid, "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_databases_delete_opensearch_index_request( # pylint: disable=name-too-long + database_cluster_uuid: str, index_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/databases/{database_cluster_uuid}/indexes/{index_name}" + path_format_arguments = { + "database_cluster_uuid": _SERIALIZER.url( + "database_cluster_uuid", database_cluster_uuid, "str" + ), + "index_name": _SERIALIZER.url("index_name", index_name, "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_domains_list_request( *, per_page: int = 20, page: int = 1, **kwargs: Any ) -> HttpRequest: @@ -109628,6 +109675,248 @@ def update_cluster_metrics_credentials( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, response_headers) # type: ignore + @distributed_trace + def list_opeasearch_indexes( + self, database_cluster_uuid: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Indexes for a OpenSearch Cluster. + + To list all of a OpenSearch cluster's indexes, send a GET request to + ``/v2/databases/$DATABASE_ID/indexes``. + + The result will be a JSON object with a ``indexes`` key. + + :param database_cluster_uuid: A unique identifier for a database cluster. Required. + :type database_cluster_uuid: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "indexes": [ + { + "created_time": "2020-02-20 00:00:00", # Optional. The date + and time the index was created. + "health": "str", # Optional. The health of the OpenSearch + index. Known values are: "unknown", "green", "yellow", "red", and "red*". + "index_name": "str", # Optional. The name of the opensearch + index. + "number_of_replicas": 0, # Optional. The number of replicas + for the index. + "number_of_shards": 0, # Optional. The number of shards for + the index. + "size": 0, # Optional. The size of the index. + "status": "str" # Optional. The status of the OpenSearch + index. Known values are: "unknown", "open", "close", and "none". + } + ] + } + # 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_databases_list_opeasearch_indexes_request( + database_cluster_uuid=database_cluster_uuid, + 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_opensearch_index( + self, database_cluster_uuid: str, index_name: str, **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete Index for OpenSearch Cluster. + + To delete a single index within OpenSearch cluster, send a DELETE request + to ``/v2/databases/$DATABASE_ID/indexes/$INDEX_NAME``. + + A status of 204 will be given. This indicates that the request was + processed successfully, but that no response body is needed. + + :param database_cluster_uuid: A unique identifier for a database cluster. Required. + :type database_cluster_uuid: str + :param index_name: The name of the OpenSearch index. Required. + :type index_name: 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_databases_delete_opensearch_index_request( + database_cluster_uuid=database_cluster_uuid, + index_name=index_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 [204, 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 == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + class DomainsOperations: """