From 46a7f3840859c1a32e51c533477bda9adcb5d5f1 Mon Sep 17 00:00:00 2001 From: ckunki Date: Mon, 11 Aug 2025 08:21:13 +0200 Subject: [PATCH 1/2] #112: Updated open API client --- doc/changes/unreleased.md | 9 +- .../openapi/api/databases/dlhc_activate.py | 114 ++++++++++++ .../api/databases/get_dlhc_activate_status.py | 171 ++++++++++++++++++ exasol/saas/client/openapi/models/__init__.py | 2 + .../openapi/models/dlhc_activate_status.py | 82 +++++++++ exasol/saas/client/openapi/py.typed | 1 + openapi.json | 114 +++++++++++- 7 files changed, 491 insertions(+), 2 deletions(-) create mode 100644 exasol/saas/client/openapi/api/databases/dlhc_activate.py create mode 100644 exasol/saas/client/openapi/api/databases/get_dlhc_activate_status.py create mode 100644 exasol/saas/client/openapi/models/dlhc_activate_status.py create mode 100644 exasol/saas/client/openapi/py.typed diff --git a/doc/changes/unreleased.md b/doc/changes/unreleased.md index 00ff721..9923dea 100644 --- a/doc/changes/unreleased.md +++ b/doc/changes/unreleased.md @@ -1,5 +1,12 @@ # Unreleased +This release updates the Python API generated from file `openapi.json`. + +Changes to `open-api.json` in detail: +* added `paths` / `/api/v1/accounts/{accountId}/databases/{databaseId}/dlhc-activate` +* added `components` / `schemas` / `DlhcActivateStatus` + ## Refactorings -* #110: Updated exasol-toolbox to 1.6.0 & activated sonar \ No newline at end of file +* #110: Updated exasol-toolbox to 1.6.0 & activated sonar +* #112: Updated open API client diff --git a/exasol/saas/client/openapi/api/databases/dlhc_activate.py b/exasol/saas/client/openapi/api/databases/dlhc_activate.py new file mode 100644 index 0000000..6feb25b --- /dev/null +++ b/exasol/saas/client/openapi/api/databases/dlhc_activate.py @@ -0,0 +1,114 @@ +from http import HTTPStatus +from typing import ( + Any, + Optional, + Union, + cast, +) + +import httpx + +from ... import errors +from ...client import ( + AuthenticatedClient, + Client, +) +from ...types import ( + UNSET, + Response, +) + + +def _get_kwargs( + account_id: str, + database_id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "post", + "url": f"/api/v1/accounts/{account_id}/databases/{database_id}/dlhc-activate", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: + if response.status_code == 202: + return None + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + account_id: str, + database_id: str, + *, + client: AuthenticatedClient, +) -> Response[Any]: + """ + Args: + account_id (str): + database_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + account_id=account_id, + database_id=database_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + account_id: str, + database_id: str, + *, + client: AuthenticatedClient, +) -> Response[Any]: + """ + Args: + account_id (str): + database_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + account_id=account_id, + database_id=database_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/exasol/saas/client/openapi/api/databases/get_dlhc_activate_status.py b/exasol/saas/client/openapi/api/databases/get_dlhc_activate_status.py new file mode 100644 index 0000000..4e4df47 --- /dev/null +++ b/exasol/saas/client/openapi/api/databases/get_dlhc_activate_status.py @@ -0,0 +1,171 @@ +from http import HTTPStatus +from typing import ( + Any, + Optional, + Union, + cast, +) + +import httpx + +from ... import errors +from ...client import ( + AuthenticatedClient, + Client, +) +from ...models.dlhc_activate_status import DlhcActivateStatus +from ...types import ( + UNSET, + Response, +) + + +def _get_kwargs( + account_id: str, + database_id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/api/v1/accounts/{account_id}/databases/{database_id}/dlhc-activate", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[DlhcActivateStatus]: + if response.status_code == 200: + response_200 = DlhcActivateStatus.from_dict(response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[DlhcActivateStatus]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + account_id: str, + database_id: str, + *, + client: AuthenticatedClient, +) -> Response[DlhcActivateStatus]: + """ + Args: + account_id (str): + database_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DlhcActivateStatus] + """ + + kwargs = _get_kwargs( + account_id=account_id, + database_id=database_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + account_id: str, + database_id: str, + *, + client: AuthenticatedClient, +) -> Optional[DlhcActivateStatus]: + """ + Args: + account_id (str): + database_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DlhcActivateStatus + """ + + return sync_detailed( + account_id=account_id, + database_id=database_id, + client=client, + ).parsed + + +async def asyncio_detailed( + account_id: str, + database_id: str, + *, + client: AuthenticatedClient, +) -> Response[DlhcActivateStatus]: + """ + Args: + account_id (str): + database_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DlhcActivateStatus] + """ + + kwargs = _get_kwargs( + account_id=account_id, + database_id=database_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + account_id: str, + database_id: str, + *, + client: AuthenticatedClient, +) -> Optional[DlhcActivateStatus]: + """ + Args: + account_id (str): + database_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DlhcActivateStatus + """ + + return ( + await asyncio_detailed( + account_id=account_id, + database_id=database_id, + client=client, + ) + ).parsed diff --git a/exasol/saas/client/openapi/models/__init__.py b/exasol/saas/client/openapi/models/__init__.py index d8d2feb..24f04bc 100644 --- a/exasol/saas/client/openapi/models/__init__.py +++ b/exasol/saas/client/openapi/models/__init__.py @@ -18,6 +18,7 @@ from .create_extension_instance import CreateExtensionInstance from .database_settings import DatabaseSettings from .database_upgrade_info import DatabaseUpgradeInfo +from .dlhc_activate_status import DlhcActivateStatus from .download_file import DownloadFile from .exasol_database import ExasolDatabase from .exasol_database_clusters import ExasolDatabaseClusters @@ -72,6 +73,7 @@ "CreateExtensionInstance", "DatabaseSettings", "DatabaseUpgradeInfo", + "DlhcActivateStatus", "DownloadFile", "ExasolDatabase", "ExasolDatabaseClusters", diff --git a/exasol/saas/client/openapi/models/dlhc_activate_status.py b/exasol/saas/client/openapi/models/dlhc_activate_status.py new file mode 100644 index 0000000..e8ad86d --- /dev/null +++ b/exasol/saas/client/openapi/models/dlhc_activate_status.py @@ -0,0 +1,82 @@ +from collections.abc import ( + Generator, + Mapping, +) +from typing import ( + TYPE_CHECKING, + Any, + BinaryIO, + Optional, + TextIO, + TypeVar, +) + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import ( + UNSET, + Unset, +) + +T = TypeVar("T", bound="DlhcActivateStatus") + + +@_attrs_define +class DlhcActivateStatus: + """ + Attributes: + status (str): + created_at (str): + """ + + status: str + created_at: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + status = self.status + + created_at = self.created_at + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "status": status, + "created_at": created_at, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + status = d.pop("status") + + created_at = d.pop("created_at") + + dlhc_activate_status = cls( + status=status, + created_at=created_at, + ) + + dlhc_activate_status.additional_properties = d + return dlhc_activate_status + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/exasol/saas/client/openapi/py.typed b/exasol/saas/client/openapi/py.typed new file mode 100644 index 0000000..1aad327 --- /dev/null +++ b/exasol/saas/client/openapi/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/openapi.json b/openapi.json index 2fe82ee..ca56f51 100644 --- a/openapi.json +++ b/openapi.json @@ -6,7 +6,7 @@ "version": "1.0", "download": { "source": "https://cloud.exasol.com/openapi.json", - "timestamp": "2025-06-26T11:37:16.532441+00:00" + "timestamp": "2025-08-11T06:11:17.721349+00:00" } }, "servers": [ @@ -1674,6 +1674,103 @@ ] } }, + "/api/v1/accounts/{accountId}/databases/{databaseId}/dlhc-activate": { + "get": { + "operationId": "GetDlhcActivateStatus", + "responses": { + "200": { + "description": "dlhc activate status", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DlhcActivateStatus" + } + } + } + }, + "default": { + "description": "Default api error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiError" + } + } + } + } + }, + "tags": [ + "Databases" + ], + "parameters": [ + { + "in": "path", + "required": true, + "name": "accountId", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "required": true, + "name": "databaseId", + "schema": { + "type": "string" + } + } + ], + "security": [ + { + "authorizer": [] + } + ] + }, + "post": { + "operationId": "DlhcActivate", + "responses": { + "202": { + "description": "Request accepted for processing; activation is in progress" + }, + "default": { + "description": "Default api error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiError" + } + } + } + } + }, + "tags": [ + "Databases" + ], + "parameters": [ + { + "in": "path", + "required": true, + "name": "accountId", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "required": true, + "name": "databaseId", + "schema": { + "type": "string" + } + } + ], + "security": [ + { + "authorizer": [] + } + ] + } + }, "/api/v1/accounts/{accountId}/databases/{databaseId}/folder/{key}": { "post": { "operationId": "CreateFolder", @@ -3326,6 +3423,21 @@ }, "type": "object" }, + "DlhcActivateStatus": { + "required": [ + "status", + "created_at" + ], + "properties": { + "status": { + "type": "string" + }, + "created_at": { + "type": "string" + } + }, + "type": "object" + }, "DownloadFile": { "required": [ "url" From 27c14e53705feac4a9326f28b770911e8d9923d1 Mon Sep 17 00:00:00 2001 From: ckunki Date: Mon, 11 Aug 2025 09:15:42 +0200 Subject: [PATCH 2/2] Exclude generated files from sonar --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e476fa5..36bfdf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,4 +119,4 @@ tbx = 'exasol.toolbox.tools.tbx:CLI' projectKey = "com.exasol:saas-api-python" hostUrl = "https://sonarcloud.io" organization = "exasol" -exclusions = "exasol/saas/client/openapi/*" \ No newline at end of file +exclusions = "exasol/saas/client/openapi/**" \ No newline at end of file