Skip to content

Commit

Permalink
[bot] Updated client based on openapi-47108d8/clientgen (#321)
Browse files Browse the repository at this point in the history
Co-authored-by: API Engineering <[email protected]>
  • Loading branch information
digitalocean-engineering and API Engineering authored Aug 20, 2024
1 parent 0e2261d commit 9a0a6a5
Show file tree
Hide file tree
Showing 4 changed files with 536 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DO_OPENAPI_COMMIT_SHA.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12a6416
47108d8
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
244 changes: 244 additions & 0 deletions src/pydo/aio/operations/_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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:
"""
Expand Down
Loading

0 comments on commit 9a0a6a5

Please sign in to comment.