diff --git a/cirro_api_client/v1/api/app_registrations/__init__.py b/cirro_api_client/v1/api/app_registrations/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/cirro_api_client/v1/api/app_registrations/approve_app.py b/cirro_api_client/v1/api/app_registrations/approve_app.py new file mode 100644 index 0000000..8eea3c5 --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/approve_app.py @@ -0,0 +1,101 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import Client +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/app-registrations/{id}:approve".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> Any | None: + if response.status_code == 200: + return None + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: 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( + id: str, + *, + client: Client, +) -> Response[Any]: + """Approve application + + Mark application as approved by an administrator. + + Args: + id (str): + client (Client): instance of the API client + + 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( + id=id, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + id: str, + *, + client: Client, +) -> Response[Any]: + """Approve application + + Mark application as approved by an administrator. + + Args: + id (str): + client (Client): instance of the API client + + 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( + id=id, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) diff --git a/cirro_api_client/v1/api/app_registrations/archive_app_registration.py b/cirro_api_client/v1/api/app_registrations/archive_app_registration.py new file mode 100644 index 0000000..4223e82 --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/archive_app_registration.py @@ -0,0 +1,101 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import Client +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "delete", + "url": "/app-registrations/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> Any | None: + if response.status_code == 200: + return None + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: 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( + id: str, + *, + client: Client, +) -> Response[Any]: + """Archive app registration + + Archives an app registration. Archived registrations cannot authenticate. + + Args: + id (str): + client (Client): instance of the API client + + 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( + id=id, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + id: str, + *, + client: Client, +) -> Response[Any]: + """Archive app registration + + Archives an app registration. Archived registrations cannot authenticate. + + Args: + id (str): + client (Client): instance of the API client + + 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( + id=id, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) diff --git a/cirro_api_client/v1/api/app_registrations/create_app_registration.py b/cirro_api_client/v1/api/app_registrations/create_app_registration.py new file mode 100644 index 0000000..11df20e --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/create_app_registration.py @@ -0,0 +1,172 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import Client +from ...models.app_registration_input import AppRegistrationInput +from ...models.app_registration_secret_response import AppRegistrationSecretResponse +from ...types import Response + + +def _get_kwargs( + *, + body: AppRegistrationInput, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/app-registrations", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> AppRegistrationSecretResponse | None: + if response.status_code == 201: + response_201 = AppRegistrationSecretResponse.from_dict(response.json()) + + return response_201 + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[AppRegistrationSecretResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Client, + body: AppRegistrationInput, +) -> Response[AppRegistrationSecretResponse]: + """Create app registration + + Creates a new OAuth client app registration. Returns the client secret which is only shown once. + + Args: + body (AppRegistrationInput): + client (Client): instance of the API client + + 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[AppRegistrationSecretResponse] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Client, + body: AppRegistrationInput, +) -> AppRegistrationSecretResponse | None: + """Create app registration + + Creates a new OAuth client app registration. Returns the client secret which is only shown once. + + Args: + body (AppRegistrationInput): + client (Client): instance of the API client + + 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: + AppRegistrationSecretResponse + """ + + try: + return sync_detailed( + client=client, + body=body, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + *, + client: Client, + body: AppRegistrationInput, +) -> Response[AppRegistrationSecretResponse]: + """Create app registration + + Creates a new OAuth client app registration. Returns the client secret which is only shown once. + + Args: + body (AppRegistrationInput): + client (Client): instance of the API client + + 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[AppRegistrationSecretResponse] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Client, + body: AppRegistrationInput, +) -> AppRegistrationSecretResponse | None: + """Create app registration + + Creates a new OAuth client app registration. Returns the client secret which is only shown once. + + Args: + body (AppRegistrationInput): + client (Client): instance of the API client + + 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: + AppRegistrationSecretResponse + """ + + try: + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/api/app_registrations/get_app_registration.py b/cirro_api_client/v1/api/app_registrations/get_app_registration.py new file mode 100644 index 0000000..dc5458c --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/get_app_registration.py @@ -0,0 +1,166 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import Client +from ...models.app_registration_detail import AppRegistrationDetail +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/app-registrations/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> AppRegistrationDetail | None: + if response.status_code == 200: + response_200 = AppRegistrationDetail.from_dict(response.json()) + + return response_200 + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[AppRegistrationDetail]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Client, +) -> Response[AppRegistrationDetail]: + """Get app registration + + Gets detailed information about an app registration. + + Args: + id (str): + client (Client): instance of the API client + + 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[AppRegistrationDetail] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Client, +) -> AppRegistrationDetail | None: + """Get app registration + + Gets detailed information about an app registration. + + Args: + id (str): + client (Client): instance of the API client + + 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: + AppRegistrationDetail + """ + + try: + return sync_detailed( + id=id, + client=client, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + id: str, + *, + client: Client, +) -> Response[AppRegistrationDetail]: + """Get app registration + + Gets detailed information about an app registration. + + Args: + id (str): + client (Client): instance of the API client + + 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[AppRegistrationDetail] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Client, +) -> AppRegistrationDetail | None: + """Get app registration + + Gets detailed information about an app registration. + + Args: + id (str): + client (Client): instance of the API client + + 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: + AppRegistrationDetail + """ + + try: + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/api/app_registrations/list_app_registrations.py b/cirro_api_client/v1/api/app_registrations/list_app_registrations.py new file mode 100644 index 0000000..894418a --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/list_app_registrations.py @@ -0,0 +1,186 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import Client +from ...models.paginated_response_app_registration_dto import PaginatedResponseAppRegistrationDto +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: int | Unset = 100, + next_token: str | Unset = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["limit"] = limit + + params["nextToken"] = next_token + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/app-registrations", + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> PaginatedResponseAppRegistrationDto | None: + if response.status_code == 200: + response_200 = PaginatedResponseAppRegistrationDto.from_dict(response.json()) + + return response_200 + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[PaginatedResponseAppRegistrationDto]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Client, + limit: int | Unset = 100, + next_token: str | Unset = UNSET, +) -> Response[PaginatedResponseAppRegistrationDto]: + """List app registrations + + Lists all app registrations in the system. + + Args: + limit (int | Unset): Default: 100. + next_token (str | Unset): + client (Client): instance of the API client + + 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[PaginatedResponseAppRegistrationDto] + """ + + kwargs = _get_kwargs( + limit=limit, + next_token=next_token, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Client, + limit: int | Unset = 100, + next_token: str | Unset = UNSET, +) -> PaginatedResponseAppRegistrationDto | None: + """List app registrations + + Lists all app registrations in the system. + + Args: + limit (int | Unset): Default: 100. + next_token (str | Unset): + client (Client): instance of the API client + + 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: + PaginatedResponseAppRegistrationDto + """ + + try: + return sync_detailed( + client=client, + limit=limit, + next_token=next_token, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + *, + client: Client, + limit: int | Unset = 100, + next_token: str | Unset = UNSET, +) -> Response[PaginatedResponseAppRegistrationDto]: + """List app registrations + + Lists all app registrations in the system. + + Args: + limit (int | Unset): Default: 100. + next_token (str | Unset): + client (Client): instance of the API client + + 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[PaginatedResponseAppRegistrationDto] + """ + + kwargs = _get_kwargs( + limit=limit, + next_token=next_token, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Client, + limit: int | Unset = 100, + next_token: str | Unset = UNSET, +) -> PaginatedResponseAppRegistrationDto | None: + """List app registrations + + Lists all app registrations in the system. + + Args: + limit (int | Unset): Default: 100. + next_token (str | Unset): + client (Client): instance of the API client + + 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: + PaginatedResponseAppRegistrationDto + """ + + try: + return ( + await asyncio_detailed( + client=client, + limit=limit, + next_token=next_token, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/api/app_registrations/list_my_app_registrations.py b/cirro_api_client/v1/api/app_registrations/list_my_app_registrations.py new file mode 100644 index 0000000..e55bd1e --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/list_my_app_registrations.py @@ -0,0 +1,140 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import Client +from ...models.app_registration import AppRegistration +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/app-registrations/mine", + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> list[AppRegistration] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = AppRegistration.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[list[AppRegistration]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Client, +) -> Response[list[AppRegistration]]: + """List my app registrations + + Lists app registrations created by the current user. + + 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[list[AppRegistration]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Client, +) -> list[AppRegistration] | None: + """List my app registrations + + Lists app registrations created by the current user. + + 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: + list[AppRegistration] + """ + + try: + return sync_detailed( + client=client, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + *, + client: Client, +) -> Response[list[AppRegistration]]: + """List my app registrations + + Lists app registrations created by the current user. + + 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[list[AppRegistration]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Client, +) -> list[AppRegistration] | None: + """List my app registrations + + Lists app registrations created by the current user. + + 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: + list[AppRegistration] + """ + + try: + return ( + await asyncio_detailed( + client=client, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/api/app_registrations/regenerate_secret.py b/cirro_api_client/v1/api/app_registrations/regenerate_secret.py new file mode 100644 index 0000000..7f87ad2 --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/regenerate_secret.py @@ -0,0 +1,166 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import Client +from ...models.app_registration_secret_response import AppRegistrationSecretResponse +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/app-registrations/{id}:regenerate-secret".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> AppRegistrationSecretResponse | None: + if response.status_code == 200: + response_200 = AppRegistrationSecretResponse.from_dict(response.json()) + + return response_200 + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[AppRegistrationSecretResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Client, +) -> Response[AppRegistrationSecretResponse]: + """Regenerate client secret + + Generates a new client secret for the app registration. The old secret is invalidated. + + Args: + id (str): + client (Client): instance of the API client + + 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[AppRegistrationSecretResponse] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Client, +) -> AppRegistrationSecretResponse | None: + """Regenerate client secret + + Generates a new client secret for the app registration. The old secret is invalidated. + + Args: + id (str): + client (Client): instance of the API client + + 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: + AppRegistrationSecretResponse + """ + + try: + return sync_detailed( + id=id, + client=client, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + id: str, + *, + client: Client, +) -> Response[AppRegistrationSecretResponse]: + """Regenerate client secret + + Generates a new client secret for the app registration. The old secret is invalidated. + + Args: + id (str): + client (Client): instance of the API client + + 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[AppRegistrationSecretResponse] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Client, +) -> AppRegistrationSecretResponse | None: + """Regenerate client secret + + Generates a new client secret for the app registration. The old secret is invalidated. + + Args: + id (str): + client (Client): instance of the API client + + 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: + AppRegistrationSecretResponse + """ + + try: + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/api/app_registrations/update_app_registration.py b/cirro_api_client/v1/api/app_registrations/update_app_registration.py new file mode 100644 index 0000000..361adf4 --- /dev/null +++ b/cirro_api_client/v1/api/app_registrations/update_app_registration.py @@ -0,0 +1,188 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import Client +from ...models.app_registration_detail import AppRegistrationDetail +from ...models.app_registration_input import AppRegistrationInput +from ...types import Response + + +def _get_kwargs( + id: str, + *, + body: AppRegistrationInput, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "put", + "url": "/app-registrations/{id}".format( + id=quote(str(id), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> AppRegistrationDetail | None: + if response.status_code == 200: + response_200 = AppRegistrationDetail.from_dict(response.json()) + + return response_200 + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[AppRegistrationDetail]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: Client, + body: AppRegistrationInput, +) -> Response[AppRegistrationDetail]: + """Update app registration + + Updates an existing app registration. + + Args: + id (str): + body (AppRegistrationInput): + client (Client): instance of the API client + + 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[AppRegistrationDetail] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: Client, + body: AppRegistrationInput, +) -> AppRegistrationDetail | None: + """Update app registration + + Updates an existing app registration. + + Args: + id (str): + body (AppRegistrationInput): + client (Client): instance of the API client + + 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: + AppRegistrationDetail + """ + + try: + return sync_detailed( + id=id, + client=client, + body=body, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + id: str, + *, + client: Client, + body: AppRegistrationInput, +) -> Response[AppRegistrationDetail]: + """Update app registration + + Updates an existing app registration. + + Args: + id (str): + body (AppRegistrationInput): + client (Client): instance of the API client + + 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[AppRegistrationDetail] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: Client, + body: AppRegistrationInput, +) -> AppRegistrationDetail | None: + """Update app registration + + Updates an existing app registration. + + Args: + id (str): + body (AppRegistrationInput): + client (Client): instance of the API client + + 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: + AppRegistrationDetail + """ + + try: + return ( + await asyncio_detailed( + id=id, + client=client, + body=body, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/api/execution/get_task.py b/cirro_api_client/v1/api/execution/get_task.py new file mode 100644 index 0000000..d93966b --- /dev/null +++ b/cirro_api_client/v1/api/execution/get_task.py @@ -0,0 +1,215 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import Client +from ...models.task import Task +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + project_id: str, + dataset_id: str, + task_id: str, + *, + force_live: bool | Unset = False, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["forceLive"] = force_live + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/projects/{project_id}/execution/{dataset_id}/tasks/{task_id}".format( + project_id=quote(str(project_id), safe=""), + dataset_id=quote(str(dataset_id), safe=""), + task_id=quote(str(task_id), safe=""), + ), + "params": params, + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> Task | None: + if response.status_code == 200: + response_200 = Task.from_dict(response.json()) + + return response_200 + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[Task]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + project_id: str, + dataset_id: str, + task_id: str, + *, + client: Client, + force_live: bool | Unset = False, +) -> Response[Task]: + """Get task + + Gets detailed information on the individual task + + Args: + project_id (str): + dataset_id (str): + task_id (str): + force_live (bool | Unset): Default: False. + client (Client): instance of the API client + + 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[Task] + """ + + kwargs = _get_kwargs( + project_id=project_id, + dataset_id=dataset_id, + task_id=task_id, + force_live=force_live, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + project_id: str, + dataset_id: str, + task_id: str, + *, + client: Client, + force_live: bool | Unset = False, +) -> Task | None: + """Get task + + Gets detailed information on the individual task + + Args: + project_id (str): + dataset_id (str): + task_id (str): + force_live (bool | Unset): Default: False. + client (Client): instance of the API client + + 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: + Task + """ + + try: + return sync_detailed( + project_id=project_id, + dataset_id=dataset_id, + task_id=task_id, + client=client, + force_live=force_live, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + project_id: str, + dataset_id: str, + task_id: str, + *, + client: Client, + force_live: bool | Unset = False, +) -> Response[Task]: + """Get task + + Gets detailed information on the individual task + + Args: + project_id (str): + dataset_id (str): + task_id (str): + force_live (bool | Unset): Default: False. + client (Client): instance of the API client + + 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[Task] + """ + + kwargs = _get_kwargs( + project_id=project_id, + dataset_id=dataset_id, + task_id=task_id, + force_live=force_live, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + project_id: str, + dataset_id: str, + task_id: str, + *, + client: Client, + force_live: bool | Unset = False, +) -> Task | None: + """Get task + + Gets detailed information on the individual task + + Args: + project_id (str): + dataset_id (str): + task_id (str): + force_live (bool | Unset): Default: False. + client (Client): instance of the API client + + 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: + Task + """ + + try: + return ( + await asyncio_detailed( + project_id=project_id, + dataset_id=dataset_id, + task_id=task_id, + client=client, + force_live=force_live, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/api/workspaces/get_workspace_logs.py b/cirro_api_client/v1/api/workspaces/get_workspace_logs.py new file mode 100644 index 0000000..f9677e0 --- /dev/null +++ b/cirro_api_client/v1/api/workspaces/get_workspace_logs.py @@ -0,0 +1,185 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import Client +from ...models.log_entry import LogEntry +from ...types import Response + + +def _get_kwargs( + project_id: str, + workspace_id: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/projects/{project_id}/workspaces/{workspace_id}/logs".format( + project_id=quote(str(project_id), safe=""), + workspace_id=quote(str(workspace_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> list[LogEntry] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = LogEntry.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + errors.handle_error_response(response, client.raise_on_unexpected_status) + + +def _build_response(*, client: Client, response: httpx.Response) -> Response[list[LogEntry]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + project_id: str, + workspace_id: str, + *, + client: Client, +) -> Response[list[LogEntry]]: + """Get workspace logs + + Retrieves logs from the main workspace container + + Args: + project_id (str): + workspace_id (str): + client (Client): instance of the API client + + 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[list[LogEntry]] + """ + + kwargs = _get_kwargs( + project_id=project_id, + workspace_id=workspace_id, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + project_id: str, + workspace_id: str, + *, + client: Client, +) -> list[LogEntry] | None: + """Get workspace logs + + Retrieves logs from the main workspace container + + Args: + project_id (str): + workspace_id (str): + client (Client): instance of the API client + + 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: + list[LogEntry] + """ + + try: + return sync_detailed( + project_id=project_id, + workspace_id=workspace_id, + client=client, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + project_id: str, + workspace_id: str, + *, + client: Client, +) -> Response[list[LogEntry]]: + """Get workspace logs + + Retrieves logs from the main workspace container + + Args: + project_id (str): + workspace_id (str): + client (Client): instance of the API client + + 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[list[LogEntry]] + """ + + kwargs = _get_kwargs( + project_id=project_id, + workspace_id=workspace_id, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + project_id: str, + workspace_id: str, + *, + client: Client, +) -> list[LogEntry] | None: + """Get workspace logs + + Retrieves logs from the main workspace container + + Args: + project_id (str): + workspace_id (str): + client (Client): instance of the API client + + 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: + list[LogEntry] + """ + + try: + return ( + await asyncio_detailed( + project_id=project_id, + workspace_id=workspace_id, + client=client, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/models/__init__.py b/cirro_api_client/v1/models/__init__.py index 7464e45..9ea8ac9 100644 --- a/cirro_api_client/v1/models/__init__.py +++ b/cirro_api_client/v1/models/__init__.py @@ -12,6 +12,12 @@ from .agent_status import AgentStatus from .agent_tags import AgentTags from .allowed_data_type import AllowedDataType +from .app_client_type import AppClientType +from .app_registration import AppRegistration +from .app_registration_detail import AppRegistrationDetail +from .app_registration_input import AppRegistrationInput +from .app_registration_secret_response import AppRegistrationSecretResponse +from .app_type import AppType from .approve_project_access_request import ApproveProjectAccessRequest from .artifact import Artifact from .artifact_type import ArtifactType @@ -117,15 +123,18 @@ from .notebook_instance import NotebookInstance from .notebook_instance_status_response import NotebookInstanceStatusResponse from .open_notebook_instance_response import OpenNotebookInstanceResponse +from .paginated_response_app_registration_dto import PaginatedResponseAppRegistrationDto from .paginated_response_dataset_list_dto import PaginatedResponseDatasetListDto from .paginated_response_discussion import PaginatedResponseDiscussion from .paginated_response_message import PaginatedResponseMessage from .paginated_response_sample_dto import PaginatedResponseSampleDto from .paginated_response_user_dto import PaginatedResponseUserDto +from .permission import Permission from .pipeline_code import PipelineCode from .pipeline_cost import PipelineCost from .portal_error_response import PortalErrorResponse from .postpone_workspace_autostop_input import PostponeWorkspaceAutostopInput +from .principal_type import PrincipalType from .process import Process from .process_detail import ProcessDetail from .process_documentation import ProcessDocumentation @@ -137,6 +146,7 @@ from .project_file_access_request import ProjectFileAccessRequest from .project_input import ProjectInput from .project_metrics import ProjectMetrics +from .project_permission_set import ProjectPermissionSet from .project_request import ProjectRequest from .project_requirement import ProjectRequirement from .project_role import ProjectRole @@ -208,7 +218,13 @@ "AgentStatus", "AgentTags", "AllowedDataType", + "AppClientType", + "AppRegistration", + "AppRegistrationDetail", + "AppRegistrationInput", + "AppRegistrationSecretResponse", "ApproveProjectAccessRequest", + "AppType", "Artifact", "ArtifactType", "AuditEvent", @@ -313,15 +329,18 @@ "NotebookInstance", "NotebookInstanceStatusResponse", "OpenNotebookInstanceResponse", + "PaginatedResponseAppRegistrationDto", "PaginatedResponseDatasetListDto", "PaginatedResponseDiscussion", "PaginatedResponseMessage", "PaginatedResponseSampleDto", "PaginatedResponseUserDto", + "Permission", "PipelineCode", "PipelineCost", "PortalErrorResponse", "PostponeWorkspaceAutostopInput", + "PrincipalType", "Process", "ProcessDetail", "ProcessDocumentation", @@ -333,6 +352,7 @@ "ProjectFileAccessRequest", "ProjectInput", "ProjectMetrics", + "ProjectPermissionSet", "ProjectRequest", "ProjectRequirement", "ProjectRole", diff --git a/cirro_api_client/v1/models/app_client_type.py b/cirro_api_client/v1/models/app_client_type.py new file mode 100644 index 0000000..f16c336 --- /dev/null +++ b/cirro_api_client/v1/models/app_client_type.py @@ -0,0 +1,15 @@ +from enum import Enum + + +class AppClientType(str, Enum): + CONFIDENTIAL_CLIENT = "CONFIDENTIAL_CLIENT" + PUBLIC_CLIENT = "PUBLIC_CLIENT" + UNKNOWN = "UNKNOWN" + """ This is a fallback value for when the value is not known, do not use this value when making requests """ + + def __str__(self) -> str: + return str(self.value) + + @classmethod + def _missing_(cls, number): + return cls(cls.UNKNOWN) diff --git a/cirro_api_client/v1/models/app_registration.py b/cirro_api_client/v1/models/app_registration.py new file mode 100644 index 0000000..3eefeed --- /dev/null +++ b/cirro_api_client/v1/models/app_registration.py @@ -0,0 +1,186 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.app_client_type import AppClientType +from ..models.app_type import AppType +from ..models.principal_type import PrincipalType +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AppRegistration") + + +@_attrs_define +class AppRegistration: + """ + Attributes: + id (str): + client_id (str): + name (str): + description (str): + principal_type (PrincipalType): + type_ (AppType): + client_type (AppClientType): + is_archived (bool): + requires_admin_consent (bool): + updated_at (datetime.datetime): + created_at (datetime.datetime): + created_by (str): + secret_expires_at (datetime.datetime | None | Unset): + """ + + id: str + client_id: str + name: str + description: str + principal_type: PrincipalType + type_: AppType + client_type: AppClientType + is_archived: bool + requires_admin_consent: bool + updated_at: datetime.datetime + created_at: datetime.datetime + created_by: str + secret_expires_at: datetime.datetime | None | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + client_id = self.client_id + + name = self.name + + description = self.description + + principal_type = self.principal_type.value + + type_ = self.type_.value + + client_type = self.client_type.value + + is_archived = self.is_archived + + requires_admin_consent = self.requires_admin_consent + + updated_at = self.updated_at.isoformat() + + created_at = self.created_at.isoformat() + + created_by = self.created_by + + secret_expires_at: None | str | Unset + if isinstance(self.secret_expires_at, Unset): + secret_expires_at = UNSET + elif isinstance(self.secret_expires_at, datetime.datetime): + secret_expires_at = self.secret_expires_at.isoformat() + else: + secret_expires_at = self.secret_expires_at + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "clientId": client_id, + "name": name, + "description": description, + "principalType": principal_type, + "type": type_, + "clientType": client_type, + "isArchived": is_archived, + "requiresAdminConsent": requires_admin_consent, + "updatedAt": updated_at, + "createdAt": created_at, + "createdBy": created_by, + } + ) + if secret_expires_at is not UNSET: + field_dict["secretExpiresAt"] = secret_expires_at + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id") + + client_id = d.pop("clientId") + + name = d.pop("name") + + description = d.pop("description") + + principal_type = PrincipalType(d.pop("principalType")) + + type_ = AppType(d.pop("type")) + + client_type = AppClientType(d.pop("clientType")) + + is_archived = d.pop("isArchived") + + requires_admin_consent = d.pop("requiresAdminConsent") + + updated_at = isoparse(d.pop("updatedAt")) + + created_at = isoparse(d.pop("createdAt")) + + created_by = d.pop("createdBy") + + def _parse_secret_expires_at(data: object) -> datetime.datetime | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + secret_expires_at_type_0 = isoparse(data) + + return secret_expires_at_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(datetime.datetime | None | Unset, data) + + secret_expires_at = _parse_secret_expires_at(d.pop("secretExpiresAt", UNSET)) + + app_registration = cls( + id=id, + client_id=client_id, + name=name, + description=description, + principal_type=principal_type, + type_=type_, + client_type=client_type, + is_archived=is_archived, + requires_admin_consent=requires_admin_consent, + updated_at=updated_at, + created_at=created_at, + created_by=created_by, + secret_expires_at=secret_expires_at, + ) + + app_registration.additional_properties = d + return app_registration + + @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/cirro_api_client/v1/models/app_registration_detail.py b/cirro_api_client/v1/models/app_registration_detail.py new file mode 100644 index 0000000..aa979f4 --- /dev/null +++ b/cirro_api_client/v1/models/app_registration_detail.py @@ -0,0 +1,387 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.app_client_type import AppClientType +from ..models.app_type import AppType +from ..models.permission import Permission +from ..models.principal_type import PrincipalType +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.project_permission_set import ProjectPermissionSet + + +T = TypeVar("T", bound="AppRegistrationDetail") + + +@_attrs_define +class AppRegistrationDetail: + """ + Attributes: + id (str): + client_id (str): + name (str): + description (str): + principal_type (PrincipalType): + type_ (AppType): + client_type (AppClientType): + project_permissions (list[ProjectPermissionSet]): + global_permissions (list[Permission]): + is_archived (bool): + requires_admin_consent (bool): + created_at (datetime.datetime): + updated_at (datetime.datetime): + created_by (str): + allowed_ips (list[str] | None | Unset): + redirect_uris (list[str] | None | Unset): + secret_expires_at (datetime.datetime | None | Unset): + secret_generated_at (datetime.datetime | None | Unset): + secret_generated_by (None | str | Unset): + approved_at (datetime.datetime | None | Unset): + approved_by (None | str | Unset): + """ + + id: str + client_id: str + name: str + description: str + principal_type: PrincipalType + type_: AppType + client_type: AppClientType + project_permissions: list[ProjectPermissionSet] + global_permissions: list[Permission] + is_archived: bool + requires_admin_consent: bool + created_at: datetime.datetime + updated_at: datetime.datetime + created_by: str + allowed_ips: list[str] | None | Unset = UNSET + redirect_uris: list[str] | None | Unset = UNSET + secret_expires_at: datetime.datetime | None | Unset = UNSET + secret_generated_at: datetime.datetime | None | Unset = UNSET + secret_generated_by: None | str | Unset = UNSET + approved_at: datetime.datetime | None | Unset = UNSET + approved_by: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + client_id = self.client_id + + name = self.name + + description = self.description + + principal_type = self.principal_type.value + + type_ = self.type_.value + + client_type = self.client_type.value + + project_permissions = [] + for project_permissions_item_data in self.project_permissions: + project_permissions_item = project_permissions_item_data.to_dict() + project_permissions.append(project_permissions_item) + + global_permissions = [] + for global_permissions_item_data in self.global_permissions: + global_permissions_item = global_permissions_item_data.value + global_permissions.append(global_permissions_item) + + is_archived = self.is_archived + + requires_admin_consent = self.requires_admin_consent + + created_at = self.created_at.isoformat() + + updated_at = self.updated_at.isoformat() + + created_by = self.created_by + + allowed_ips: list[str] | None | Unset + if isinstance(self.allowed_ips, Unset): + allowed_ips = UNSET + elif isinstance(self.allowed_ips, list): + allowed_ips = self.allowed_ips + + else: + allowed_ips = self.allowed_ips + + redirect_uris: list[str] | None | Unset + if isinstance(self.redirect_uris, Unset): + redirect_uris = UNSET + elif isinstance(self.redirect_uris, list): + redirect_uris = self.redirect_uris + + else: + redirect_uris = self.redirect_uris + + secret_expires_at: None | str | Unset + if isinstance(self.secret_expires_at, Unset): + secret_expires_at = UNSET + elif isinstance(self.secret_expires_at, datetime.datetime): + secret_expires_at = self.secret_expires_at.isoformat() + else: + secret_expires_at = self.secret_expires_at + + secret_generated_at: None | str | Unset + if isinstance(self.secret_generated_at, Unset): + secret_generated_at = UNSET + elif isinstance(self.secret_generated_at, datetime.datetime): + secret_generated_at = self.secret_generated_at.isoformat() + else: + secret_generated_at = self.secret_generated_at + + secret_generated_by: None | str | Unset + if isinstance(self.secret_generated_by, Unset): + secret_generated_by = UNSET + else: + secret_generated_by = self.secret_generated_by + + approved_at: None | str | Unset + if isinstance(self.approved_at, Unset): + approved_at = UNSET + elif isinstance(self.approved_at, datetime.datetime): + approved_at = self.approved_at.isoformat() + else: + approved_at = self.approved_at + + approved_by: None | str | Unset + if isinstance(self.approved_by, Unset): + approved_by = UNSET + else: + approved_by = self.approved_by + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "clientId": client_id, + "name": name, + "description": description, + "principalType": principal_type, + "type": type_, + "clientType": client_type, + "projectPermissions": project_permissions, + "globalPermissions": global_permissions, + "isArchived": is_archived, + "requiresAdminConsent": requires_admin_consent, + "createdAt": created_at, + "updatedAt": updated_at, + "createdBy": created_by, + } + ) + if allowed_ips is not UNSET: + field_dict["allowedIps"] = allowed_ips + if redirect_uris is not UNSET: + field_dict["redirectUris"] = redirect_uris + if secret_expires_at is not UNSET: + field_dict["secretExpiresAt"] = secret_expires_at + if secret_generated_at is not UNSET: + field_dict["secretGeneratedAt"] = secret_generated_at + if secret_generated_by is not UNSET: + field_dict["secretGeneratedBy"] = secret_generated_by + if approved_at is not UNSET: + field_dict["approvedAt"] = approved_at + if approved_by is not UNSET: + field_dict["approvedBy"] = approved_by + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.project_permission_set import ProjectPermissionSet + + d = dict(src_dict) + id = d.pop("id") + + client_id = d.pop("clientId") + + name = d.pop("name") + + description = d.pop("description") + + principal_type = PrincipalType(d.pop("principalType")) + + type_ = AppType(d.pop("type")) + + client_type = AppClientType(d.pop("clientType")) + + project_permissions = [] + _project_permissions = d.pop("projectPermissions") + for project_permissions_item_data in _project_permissions: + project_permissions_item = ProjectPermissionSet.from_dict(project_permissions_item_data) + + project_permissions.append(project_permissions_item) + + global_permissions = [] + _global_permissions = d.pop("globalPermissions") + for global_permissions_item_data in _global_permissions: + global_permissions_item = Permission(global_permissions_item_data) + + global_permissions.append(global_permissions_item) + + is_archived = d.pop("isArchived") + + requires_admin_consent = d.pop("requiresAdminConsent") + + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) + + created_by = d.pop("createdBy") + + def _parse_allowed_ips(data: object) -> list[str] | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + allowed_ips_type_0 = cast(list[str], data) + + return allowed_ips_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(list[str] | None | Unset, data) + + allowed_ips = _parse_allowed_ips(d.pop("allowedIps", UNSET)) + + def _parse_redirect_uris(data: object) -> list[str] | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + redirect_uris_type_0 = cast(list[str], data) + + return redirect_uris_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(list[str] | None | Unset, data) + + redirect_uris = _parse_redirect_uris(d.pop("redirectUris", UNSET)) + + def _parse_secret_expires_at(data: object) -> datetime.datetime | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + secret_expires_at_type_0 = isoparse(data) + + return secret_expires_at_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(datetime.datetime | None | Unset, data) + + secret_expires_at = _parse_secret_expires_at(d.pop("secretExpiresAt", UNSET)) + + def _parse_secret_generated_at(data: object) -> datetime.datetime | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + secret_generated_at_type_0 = isoparse(data) + + return secret_generated_at_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(datetime.datetime | None | Unset, data) + + secret_generated_at = _parse_secret_generated_at(d.pop("secretGeneratedAt", UNSET)) + + def _parse_secret_generated_by(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + secret_generated_by = _parse_secret_generated_by(d.pop("secretGeneratedBy", UNSET)) + + def _parse_approved_at(data: object) -> datetime.datetime | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + approved_at_type_0 = isoparse(data) + + return approved_at_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(datetime.datetime | None | Unset, data) + + approved_at = _parse_approved_at(d.pop("approvedAt", UNSET)) + + def _parse_approved_by(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + approved_by = _parse_approved_by(d.pop("approvedBy", UNSET)) + + app_registration_detail = cls( + id=id, + client_id=client_id, + name=name, + description=description, + principal_type=principal_type, + type_=type_, + client_type=client_type, + project_permissions=project_permissions, + global_permissions=global_permissions, + is_archived=is_archived, + requires_admin_consent=requires_admin_consent, + created_at=created_at, + updated_at=updated_at, + created_by=created_by, + allowed_ips=allowed_ips, + redirect_uris=redirect_uris, + secret_expires_at=secret_expires_at, + secret_generated_at=secret_generated_at, + secret_generated_by=secret_generated_by, + approved_at=approved_at, + approved_by=approved_by, + ) + + app_registration_detail.additional_properties = d + return app_registration_detail + + @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/cirro_api_client/v1/models/app_registration_input.py b/cirro_api_client/v1/models/app_registration_input.py new file mode 100644 index 0000000..f544e19 --- /dev/null +++ b/cirro_api_client/v1/models/app_registration_input.py @@ -0,0 +1,177 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.app_client_type import AppClientType +from ..models.permission import Permission +from ..models.principal_type import PrincipalType +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.project_permission_set import ProjectPermissionSet + + +T = TypeVar("T", bound="AppRegistrationInput") + + +@_attrs_define +class AppRegistrationInput: + """ + Attributes: + name (str): Name of app registration + description (str): + principal_type (PrincipalType): + client_type (AppClientType): + allowed_ips (list[str]): These IP address ranges are allowed to use this app (will be used later) + redirect_uris (list[str]): A list of allowed redirect URIs for authentication. HTTPS is required except for + localhost and app callback URLs are supported + project_permissions (list[ProjectPermissionSet]): Permissions that this app has on the project + global_permissions (list[Permission]): Permissions that this app has globally + secret_expires_at (datetime.datetime | None | Unset): Optional expiry date of secret + """ + + name: str + description: str + principal_type: PrincipalType + client_type: AppClientType + allowed_ips: list[str] + redirect_uris: list[str] + project_permissions: list[ProjectPermissionSet] + global_permissions: list[Permission] + secret_expires_at: datetime.datetime | None | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + description = self.description + + principal_type = self.principal_type.value + + client_type = self.client_type.value + + allowed_ips = self.allowed_ips + + redirect_uris = self.redirect_uris + + project_permissions = [] + for project_permissions_item_data in self.project_permissions: + project_permissions_item = project_permissions_item_data.to_dict() + project_permissions.append(project_permissions_item) + + global_permissions = [] + for global_permissions_item_data in self.global_permissions: + global_permissions_item = global_permissions_item_data.value + global_permissions.append(global_permissions_item) + + secret_expires_at: None | str | Unset + if isinstance(self.secret_expires_at, Unset): + secret_expires_at = UNSET + elif isinstance(self.secret_expires_at, datetime.datetime): + secret_expires_at = self.secret_expires_at.isoformat() + else: + secret_expires_at = self.secret_expires_at + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "name": name, + "description": description, + "principalType": principal_type, + "clientType": client_type, + "allowedIps": allowed_ips, + "redirectUris": redirect_uris, + "projectPermissions": project_permissions, + "globalPermissions": global_permissions, + } + ) + if secret_expires_at is not UNSET: + field_dict["secretExpiresAt"] = secret_expires_at + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.project_permission_set import ProjectPermissionSet + + d = dict(src_dict) + name = d.pop("name") + + description = d.pop("description") + + principal_type = PrincipalType(d.pop("principalType")) + + client_type = AppClientType(d.pop("clientType")) + + allowed_ips = cast(list[str], d.pop("allowedIps")) + + redirect_uris = cast(list[str], d.pop("redirectUris")) + + project_permissions = [] + _project_permissions = d.pop("projectPermissions") + for project_permissions_item_data in _project_permissions: + project_permissions_item = ProjectPermissionSet.from_dict(project_permissions_item_data) + + project_permissions.append(project_permissions_item) + + global_permissions = [] + _global_permissions = d.pop("globalPermissions") + for global_permissions_item_data in _global_permissions: + global_permissions_item = Permission(global_permissions_item_data) + + global_permissions.append(global_permissions_item) + + def _parse_secret_expires_at(data: object) -> datetime.datetime | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + secret_expires_at_type_0 = isoparse(data) + + return secret_expires_at_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(datetime.datetime | None | Unset, data) + + secret_expires_at = _parse_secret_expires_at(d.pop("secretExpiresAt", UNSET)) + + app_registration_input = cls( + name=name, + description=description, + principal_type=principal_type, + client_type=client_type, + allowed_ips=allowed_ips, + redirect_uris=redirect_uris, + project_permissions=project_permissions, + global_permissions=global_permissions, + secret_expires_at=secret_expires_at, + ) + + app_registration_input.additional_properties = d + return app_registration_input + + @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/cirro_api_client/v1/models/app_registration_secret_response.py b/cirro_api_client/v1/models/app_registration_secret_response.py new file mode 100644 index 0000000..bb17a4c --- /dev/null +++ b/cirro_api_client/v1/models/app_registration_secret_response.py @@ -0,0 +1,87 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +T = TypeVar("T", bound="AppRegistrationSecretResponse") + + +@_attrs_define +class AppRegistrationSecretResponse: + """ + Attributes: + id (str): + client_id (str): The oauth client ID. + client_secret (str): The oauth client secret. This is only returned once. + secret_generated_at (datetime.datetime): + """ + + id: str + client_id: str + client_secret: str + secret_generated_at: datetime.datetime + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + client_id = self.client_id + + client_secret = self.client_secret + + secret_generated_at = self.secret_generated_at.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "clientId": client_id, + "clientSecret": client_secret, + "secretGeneratedAt": secret_generated_at, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id") + + client_id = d.pop("clientId") + + client_secret = d.pop("clientSecret") + + secret_generated_at = isoparse(d.pop("secretGeneratedAt")) + + app_registration_secret_response = cls( + id=id, + client_id=client_id, + client_secret=client_secret, + secret_generated_at=secret_generated_at, + ) + + app_registration_secret_response.additional_properties = d + return app_registration_secret_response + + @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/cirro_api_client/v1/models/app_type.py b/cirro_api_client/v1/models/app_type.py new file mode 100644 index 0000000..5658068 --- /dev/null +++ b/cirro_api_client/v1/models/app_type.py @@ -0,0 +1,15 @@ +from enum import Enum + + +class AppType(str, Enum): + MACHINE_TO_MACHINE = "MACHINE_TO_MACHINE" + PUBLIC_APP = "PUBLIC_APP" + TRADITIONAL = "TRADITIONAL" + UNKNOWN = "UNKNOWN" + + def __str__(self) -> str: + return str(self.value) + + @classmethod + def _missing_(cls, number): + return cls(cls.UNKNOWN) diff --git a/cirro_api_client/v1/models/feature_flags.py b/cirro_api_client/v1/models/feature_flags.py index cedc731..2f0bf3a 100644 --- a/cirro_api_client/v1/models/feature_flags.py +++ b/cirro_api_client/v1/models/feature_flags.py @@ -18,6 +18,7 @@ class FeatureFlags: project_requests_enabled (bool): workspaces_enabled (bool): drive_enabled (bool): + app_registrations_enabled (bool): """ sftp_enabled: bool @@ -25,6 +26,7 @@ class FeatureFlags: project_requests_enabled: bool workspaces_enabled: bool drive_enabled: bool + app_registrations_enabled: bool additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -38,6 +40,8 @@ def to_dict(self) -> dict[str, Any]: drive_enabled = self.drive_enabled + app_registrations_enabled = self.app_registrations_enabled + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -47,6 +51,7 @@ def to_dict(self) -> dict[str, Any]: "projectRequestsEnabled": project_requests_enabled, "workspacesEnabled": workspaces_enabled, "driveEnabled": drive_enabled, + "appRegistrationsEnabled": app_registrations_enabled, } ) @@ -65,12 +70,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: drive_enabled = d.pop("driveEnabled") + app_registrations_enabled = d.pop("appRegistrationsEnabled") + feature_flags = cls( sftp_enabled=sftp_enabled, governance_enabled=governance_enabled, project_requests_enabled=project_requests_enabled, workspaces_enabled=workspaces_enabled, drive_enabled=drive_enabled, + app_registrations_enabled=app_registrations_enabled, ) feature_flags.additional_properties = d diff --git a/cirro_api_client/v1/models/paginated_response_app_registration_dto.py b/cirro_api_client/v1/models/paginated_response_app_registration_dto.py new file mode 100644 index 0000000..197f094 --- /dev/null +++ b/cirro_api_client/v1/models/paginated_response_app_registration_dto.py @@ -0,0 +1,83 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.app_registration import AppRegistration + + +T = TypeVar("T", bound="PaginatedResponseAppRegistrationDto") + + +@_attrs_define +class PaginatedResponseAppRegistrationDto: + """ + Attributes: + data (list[AppRegistration]): + next_token (str): + """ + + data: list[AppRegistration] + next_token: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + data = [] + for data_item_data in self.data: + data_item = data_item_data.to_dict() + data.append(data_item) + + next_token = self.next_token + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "data": data, + "nextToken": next_token, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.app_registration import AppRegistration + + d = dict(src_dict) + data = [] + _data = d.pop("data") + for data_item_data in _data: + data_item = AppRegistration.from_dict(data_item_data) + + data.append(data_item) + + next_token = d.pop("nextToken") + + paginated_response_app_registration_dto = cls( + data=data, + next_token=next_token, + ) + + paginated_response_app_registration_dto.additional_properties = d + return paginated_response_app_registration_dto + + @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/cirro_api_client/v1/models/permission.py b/cirro_api_client/v1/models/permission.py new file mode 100644 index 0000000..c825505 --- /dev/null +++ b/cirro_api_client/v1/models/permission.py @@ -0,0 +1,71 @@ +from enum import Enum + + +class Permission(str, Enum): + CONTROL_NOTEBOOK_INSTANCE = "CONTROL_NOTEBOOK_INSTANCE" + CONTROL_WORKSPACE = "CONTROL_WORKSPACE" + CREATE_BILLING_ACCOUNT = "CREATE_BILLING_ACCOUNT" + CREATE_BYOA_PROJECT = "CREATE_BYOA_PROJECT" + CREATE_CUSTOM_PIPELINE = "CREATE_CUSTOM_PIPELINE" + CREATE_CUSTOM_PIPELINE_TENANT = "CREATE_CUSTOM_PIPELINE_TENANT" + CREATE_CUSTOM_WORKSPACE = "CREATE_CUSTOM_WORKSPACE" + CREATE_DASHBOARD = "CREATE_DASHBOARD" + CREATE_DATASET = "CREATE_DATASET" + CREATE_DISCUSSION = "CREATE_DISCUSSION" + CREATE_HOSTED_PROJECT = "CREATE_HOSTED_PROJECT" + CREATE_NOTEBOOK_INSTANCE = "CREATE_NOTEBOOK_INSTANCE" + CREATE_WORKSPACE = "CREATE_WORKSPACE" + DELETE_DATASET = "DELETE_DATASET" + DELETE_NOTEBOOK_INSTANCE = "DELETE_NOTEBOOK_INSTANCE" + DELETE_PROJECT = "DELETE_PROJECT" + DELETE_WORKSPACE = "DELETE_WORKSPACE" + EDIT_DASHBOARD = "EDIT_DASHBOARD" + EDIT_DATASET = "EDIT_DATASET" + EDIT_PROJECT = "EDIT_PROJECT" + EDIT_PROJECT_MEMBERS = "EDIT_PROJECT_MEMBERS" + EDIT_PROJECT_METADATA = "EDIT_PROJECT_METADATA" + EDIT_PROJECT_REFERENCES = "EDIT_PROJECT_REFERENCES" + GENERATE_DOWNLOAD_TOKEN = "GENERATE_DOWNLOAD_TOKEN" + INVITE_MEMBER = "INVITE_MEMBER" + MANAGE_AGENTS = "MANAGE_AGENTS" + MANAGE_ALL_APP_REGISTRATIONS = "MANAGE_ALL_APP_REGISTRATIONS" + MANAGE_BILLING_ACCOUNTS = "MANAGE_BILLING_ACCOUNTS" + MANAGE_DISCUSSIONS = "MANAGE_DISCUSSIONS" + MANAGE_GOVERNANCE = "MANAGE_GOVERNANCE" + MANAGE_MEMBERS = "MANAGE_MEMBERS" + MANAGE_OWN_APP_REGISTRATIONS = "MANAGE_OWN_APP_REGISTRATIONS" + MANAGE_PROJECT_SHARES = "MANAGE_PROJECT_SHARES" + OPEN_NOTEBOOK_INSTANCE = "OPEN_NOTEBOOK_INSTANCE" + OPEN_WORKSPACE = "OPEN_WORKSPACE" + REQUEST_PROJECT = "REQUEST_PROJECT" + RUN_ANALYSIS = "RUN_ANALYSIS" + SEARCH_MEMBERS = "SEARCH_MEMBERS" + STOP_ANALYSIS = "STOP_ANALYSIS" + SYS_ADMIN_OPERATIONS = "SYS_ADMIN_OPERATIONS" + VIEW_ALL_DATA = "VIEW_ALL_DATA" + VIEW_AUDIT_EVENTS = "VIEW_AUDIT_EVENTS" + VIEW_CLASSIFICATIONS = "VIEW_CLASSIFICATIONS" + VIEW_CONTACTS = "VIEW_CONTACTS" + VIEW_DASHBOARD = "VIEW_DASHBOARD" + VIEW_DATASET = "VIEW_DATASET" + VIEW_DATASET_LOGS = "VIEW_DATASET_LOGS" + VIEW_DISCUSSION = "VIEW_DISCUSSION" + VIEW_METRICS = "VIEW_METRICS" + VIEW_PROCESS = "VIEW_PROCESS" + VIEW_PROJECT = "VIEW_PROJECT" + VIEW_PROJECT_COSTS = "VIEW_PROJECT_COSTS" + VIEW_PROJECT_MEMBERS = "VIEW_PROJECT_MEMBERS" + VIEW_PROJECT_METADATA = "VIEW_PROJECT_METADATA" + VIEW_PROJECT_REFERENCES = "VIEW_PROJECT_REFERENCES" + VIEW_PROJECT_SHARES = "VIEW_PROJECT_SHARES" + VIEW_SERVICE_CONNECTIONS = "VIEW_SERVICE_CONNECTIONS" + VIEW_WORKSPACE_ENVIRONMENTS = "VIEW_WORKSPACE_ENVIRONMENTS" + UNKNOWN = "UNKNOWN" + """ This is a fallback value for when the value is not known, do not use this value when making requests """ + + def __str__(self) -> str: + return str(self.value) + + @classmethod + def _missing_(cls, number): + return cls(cls.UNKNOWN) diff --git a/cirro_api_client/v1/models/principal_type.py b/cirro_api_client/v1/models/principal_type.py new file mode 100644 index 0000000..57f5a2c --- /dev/null +++ b/cirro_api_client/v1/models/principal_type.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class PrincipalType(str, Enum): + DELEGATED = "DELEGATED" + SYSTEM = "SYSTEM" + USER = "USER" + UNKNOWN = "UNKNOWN" + """ This is a fallback value for when the value is not known, do not use this value when making requests """ + + def __str__(self) -> str: + return str(self.value) + + @classmethod + def _missing_(cls, number): + return cls(cls.UNKNOWN) diff --git a/cirro_api_client/v1/models/project_permission_set.py b/cirro_api_client/v1/models/project_permission_set.py new file mode 100644 index 0000000..8985d47 --- /dev/null +++ b/cirro_api_client/v1/models/project_permission_set.py @@ -0,0 +1,69 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ProjectPermissionSet") + + +@_attrs_define +class ProjectPermissionSet: + """ + Attributes: + project_id (str): + permissions (list[str]): + """ + + project_id: str + permissions: list[str] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + project_id = self.project_id + + permissions = self.permissions + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "projectId": project_id, + "permissions": permissions, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + project_id = d.pop("projectId") + + permissions = cast(list[str], d.pop("permissions")) + + project_permission_set = cls( + project_id=project_id, + permissions=permissions, + ) + + project_permission_set.additional_properties = d + return project_permission_set + + @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/cirro_api_client/v1/models/task.py b/cirro_api_client/v1/models/task.py index 622001a..2399324 100644 --- a/cirro_api_client/v1/models/task.py +++ b/cirro_api_client/v1/models/task.py @@ -20,6 +20,7 @@ class Task: name (str): status (str): native_job_id (None | str | Unset): Job ID on the underlying execution environment (i.e. AWS Batch ID) + status_message (None | str | Unset): requested_at (datetime.datetime | None | Unset): started_at (datetime.datetime | None | Unset): stopped_at (datetime.datetime | None | Unset): @@ -31,6 +32,7 @@ class Task: name: str status: str native_job_id: None | str | Unset = UNSET + status_message: None | str | Unset = UNSET requested_at: datetime.datetime | None | Unset = UNSET started_at: datetime.datetime | None | Unset = UNSET stopped_at: datetime.datetime | None | Unset = UNSET @@ -50,6 +52,12 @@ def to_dict(self) -> dict[str, Any]: else: native_job_id = self.native_job_id + status_message: None | str | Unset + if isinstance(self.status_message, Unset): + status_message = UNSET + else: + status_message = self.status_message + requested_at: None | str | Unset if isinstance(self.requested_at, Unset): requested_at = UNSET @@ -102,6 +110,8 @@ def to_dict(self) -> dict[str, Any]: ) if native_job_id is not UNSET: field_dict["nativeJobId"] = native_job_id + if status_message is not UNSET: + field_dict["statusMessage"] = status_message if requested_at is not UNSET: field_dict["requestedAt"] = requested_at if started_at is not UNSET: @@ -133,6 +143,15 @@ def _parse_native_job_id(data: object) -> None | str | Unset: native_job_id = _parse_native_job_id(d.pop("nativeJobId", UNSET)) + def _parse_status_message(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + status_message = _parse_status_message(d.pop("statusMessage", UNSET)) + def _parse_requested_at(data: object) -> datetime.datetime | None | Unset: if data is None: return data @@ -215,6 +234,7 @@ def _parse_log_location(data: object) -> None | str | Unset: name=name, status=status, native_job_id=native_job_id, + status_message=status_message, requested_at=requested_at, started_at=started_at, stopped_at=stopped_at, diff --git a/cirro_api_client/v1/models/update_user_request.py b/cirro_api_client/v1/models/update_user_request.py index 9cd10e9..e6584b0 100644 --- a/cirro_api_client/v1/models/update_user_request.py +++ b/cirro_api_client/v1/models/update_user_request.py @@ -26,7 +26,9 @@ class UpdateUserRequest: job_title (str | Unset): Job title or role of the user organization (str | Unset): The organization the user belongs to, only editable by administrators settings (None | Unset | UserSettings): - groups (list[str] | Unset): Groups the user belongs to, only editable by administrators + global_roles (list[str] | None | Unset): Global roles the user belongs to, only editable by administrators + groups (list[str] | None | Unset): Groups the user belongs to, only editable by administrators. Replaced by + global roles """ name: str @@ -36,7 +38,8 @@ class UpdateUserRequest: job_title: str | Unset = UNSET organization: str | Unset = UNSET settings: None | Unset | UserSettings = UNSET - groups: list[str] | Unset = UNSET + global_roles: list[str] | None | Unset = UNSET + groups: list[str] | None | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -62,8 +65,22 @@ def to_dict(self) -> dict[str, Any]: else: settings = self.settings - groups: list[str] | Unset = UNSET - if not isinstance(self.groups, Unset): + global_roles: list[str] | None | Unset + if isinstance(self.global_roles, Unset): + global_roles = UNSET + elif isinstance(self.global_roles, list): + global_roles = self.global_roles + + else: + global_roles = self.global_roles + + groups: list[str] | None | Unset + if isinstance(self.groups, Unset): + groups = UNSET + elif isinstance(self.groups, list): + groups = self.groups + + else: groups = self.groups field_dict: dict[str, Any] = {} @@ -84,6 +101,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["organization"] = organization if settings is not UNSET: field_dict["settings"] = settings + if global_roles is not UNSET: + field_dict["globalRoles"] = global_roles if groups is not UNSET: field_dict["groups"] = groups @@ -123,7 +142,39 @@ def _parse_settings(data: object) -> None | Unset | UserSettings: settings = _parse_settings(d.pop("settings", UNSET)) - groups = cast(list[str], d.pop("groups", UNSET)) + def _parse_global_roles(data: object) -> list[str] | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + global_roles_type_0 = cast(list[str], data) + + return global_roles_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(list[str] | None | Unset, data) + + global_roles = _parse_global_roles(d.pop("globalRoles", UNSET)) + + def _parse_groups(data: object) -> list[str] | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + groups_type_0 = cast(list[str], data) + + return groups_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(list[str] | None | Unset, data) + + groups = _parse_groups(d.pop("groups", UNSET)) update_user_request = cls( name=name, @@ -133,6 +184,7 @@ def _parse_settings(data: object) -> None | Unset | UserSettings: job_title=job_title, organization=organization, settings=settings, + global_roles=global_roles, groups=groups, ) diff --git a/cirro_api_client/v1/models/user.py b/cirro_api_client/v1/models/user.py index 7ee1f24..212900f 100644 --- a/cirro_api_client/v1/models/user.py +++ b/cirro_api_client/v1/models/user.py @@ -1,7 +1,7 @@ from __future__ import annotations from collections.abc import Mapping -from typing import Any, TypeVar +from typing import Any, TypeVar, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,6 +18,7 @@ class User: organization (str): department (str): job_title (str): + global_roles (list[str]): """ name: str @@ -25,6 +26,7 @@ class User: organization: str department: str job_title: str + global_roles: list[str] additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -38,6 +40,8 @@ def to_dict(self) -> dict[str, Any]: job_title = self.job_title + global_roles = self.global_roles + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -47,6 +51,7 @@ def to_dict(self) -> dict[str, Any]: "organization": organization, "department": department, "jobTitle": job_title, + "globalRoles": global_roles, } ) @@ -65,12 +70,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: job_title = d.pop("jobTitle") + global_roles = cast(list[str], d.pop("globalRoles")) + user = cls( name=name, username=username, organization=organization, department=department, job_title=job_title, + global_roles=global_roles, ) user.additional_properties = d diff --git a/cirro_api_client/v1/models/user_detail.py b/cirro_api_client/v1/models/user_detail.py index f7d2f59..1a7f095 100644 --- a/cirro_api_client/v1/models/user_detail.py +++ b/cirro_api_client/v1/models/user_detail.py @@ -31,10 +31,11 @@ class UserDetail: department (str): invited_by (str): project_assignments (list[UserProjectAssignment]): - groups (list[str]): + global_roles (list[str]): settings (UserSettings): Additional settings for the user sign_up_time (datetime.datetime | None | Unset): last_signed_in (datetime.datetime | None | Unset): + groups (list[str] | None | Unset): Replaced by globalRoles. """ username: str @@ -46,10 +47,11 @@ class UserDetail: department: str invited_by: str project_assignments: list[UserProjectAssignment] - groups: list[str] + global_roles: list[str] settings: UserSettings sign_up_time: datetime.datetime | None | Unset = UNSET last_signed_in: datetime.datetime | None | Unset = UNSET + groups: list[str] | None | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -74,7 +76,7 @@ def to_dict(self) -> dict[str, Any]: project_assignments_item = project_assignments_item_data.to_dict() project_assignments.append(project_assignments_item) - groups = self.groups + global_roles = self.global_roles settings = self.settings.to_dict() @@ -94,6 +96,15 @@ def to_dict(self) -> dict[str, Any]: else: last_signed_in = self.last_signed_in + groups: list[str] | None | Unset + if isinstance(self.groups, Unset): + groups = UNSET + elif isinstance(self.groups, list): + groups = self.groups + + else: + groups = self.groups + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -107,7 +118,7 @@ def to_dict(self) -> dict[str, Any]: "department": department, "invitedBy": invited_by, "projectAssignments": project_assignments, - "groups": groups, + "globalRoles": global_roles, "settings": settings, } ) @@ -115,6 +126,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["signUpTime"] = sign_up_time if last_signed_in is not UNSET: field_dict["lastSignedIn"] = last_signed_in + if groups is not UNSET: + field_dict["groups"] = groups return field_dict @@ -147,7 +160,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: project_assignments.append(project_assignments_item) - groups = cast(list[str], d.pop("groups")) + global_roles = cast(list[str], d.pop("globalRoles")) settings = UserSettings.from_dict(d.pop("settings")) @@ -185,6 +198,23 @@ def _parse_last_signed_in(data: object) -> datetime.datetime | None | Unset: last_signed_in = _parse_last_signed_in(d.pop("lastSignedIn", UNSET)) + def _parse_groups(data: object) -> list[str] | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + groups_type_0 = cast(list[str], data) + + return groups_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(list[str] | None | Unset, data) + + groups = _parse_groups(d.pop("groups", UNSET)) + user_detail = cls( username=username, name=name, @@ -195,10 +225,11 @@ def _parse_last_signed_in(data: object) -> datetime.datetime | None | Unset: department=department, invited_by=invited_by, project_assignments=project_assignments, - groups=groups, + global_roles=global_roles, settings=settings, sign_up_time=sign_up_time, last_signed_in=last_signed_in, + groups=groups, ) user_detail.additional_properties = d diff --git a/cirro_api_client/v1/models/workspace_compute_config.py b/cirro_api_client/v1/models/workspace_compute_config.py index f6df53c..18340a1 100644 --- a/cirro_api_client/v1/models/workspace_compute_config.py +++ b/cirro_api_client/v1/models/workspace_compute_config.py @@ -25,6 +25,8 @@ class WorkspaceComputeConfig: memory_gi_b (int | Unset): Memory allocated to the workspace container in GiB. Example: 8. volume_size_gi_b (int | Unset): Persistent storage volume size allocated to the workspace in GiB. Example: 50. gpu (int | Unset): Number of GPUs allocated to the workspace Example: 1. + gpu_model (None | str | Unset): NVIDIA GPU model. When null, AWS selects from any available GPU instance family. + Example: T4. environment_variables (None | Unset | WorkspaceComputeConfigEnvironmentVariables): Map of environment variables injected into the container at runtime. Keys must be non-blank. Example: {'ENV_MODE': 'production', 'LOG_LEVEL': 'debug'}. @@ -36,6 +38,7 @@ class WorkspaceComputeConfig: memory_gi_b: int | Unset = UNSET volume_size_gi_b: int | Unset = UNSET gpu: int | Unset = UNSET + gpu_model: None | str | Unset = UNSET environment_variables: None | Unset | WorkspaceComputeConfigEnvironmentVariables = UNSET local_port: int | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -53,6 +56,12 @@ def to_dict(self) -> dict[str, Any]: gpu = self.gpu + gpu_model: None | str | Unset + if isinstance(self.gpu_model, Unset): + gpu_model = UNSET + else: + gpu_model = self.gpu_model + environment_variables: dict[str, Any] | None | Unset if isinstance(self.environment_variables, Unset): environment_variables = UNSET @@ -78,6 +87,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["volumeSizeGiB"] = volume_size_gi_b if gpu is not UNSET: field_dict["gpu"] = gpu + if gpu_model is not UNSET: + field_dict["gpuModel"] = gpu_model if environment_variables is not UNSET: field_dict["environmentVariables"] = environment_variables if local_port is not UNSET: @@ -100,6 +111,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: gpu = d.pop("gpu", UNSET) + def _parse_gpu_model(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + gpu_model = _parse_gpu_model(d.pop("gpuModel", UNSET)) + def _parse_environment_variables(data: object) -> None | Unset | WorkspaceComputeConfigEnvironmentVariables: if data is None: return data @@ -125,6 +145,7 @@ def _parse_environment_variables(data: object) -> None | Unset | WorkspaceComput memory_gi_b=memory_gi_b, volume_size_gi_b=volume_size_gi_b, gpu=gpu, + gpu_model=gpu_model, environment_variables=environment_variables, local_port=local_port, ) diff --git a/pyproject.toml b/pyproject.toml index 8bb9445..bd7c683 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cirro_api_client" -version = "1.3.1" +version = "1.3.2" description = "A client library for accessing Cirro" authors = ["Cirro "] license = "MIT" diff --git a/tests/test_client.py b/tests/test_client.py index 6261312..ad7eac5 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -20,28 +20,36 @@ def _generate_mock_client(response_data: dict): class TestClient(unittest.TestCase): def test_client_set_up(self): from cirro_api_client import CirroApiClient, TokenAuth + client = CirroApiClient(auth_method=TokenAuth(token=""), base_url="https://api.cirro.bio") self.assertIsNotNone(client) def test_import_models(self): from cirro_api_client.v1.models import InviteUserRequest + req = InviteUserRequest(name="Test User", organization="test", email="test") self.assertEqual(req.name, "Test User") - self.assertIn('name', req.to_dict()) + self.assertIn("name", req.to_dict()) self.assertEqual(len(req.additional_properties.keys()), 0) def test_import_api_methods(self): from cirro_api_client.v1.api.users import list_users - mock_client = _generate_mock_client({ - 'data': [{ - 'name': 'Test User', - 'username': 'testuser', - 'organization': 'test-org', - 'department': 'test-dept', - 'jobTitle': 'test-title' - }], - 'nextToken': None - }) + + mock_client = _generate_mock_client( + { + "data": [ + { + "name": "Test User", + "username": "testuser", + "organization": "test-org", + "department": "test-dept", + "jobTitle": "test-title", + "globalRoles": [] + } + ], + "nextToken": None, + } + ) response = list_users.sync(client=mock_client, limit=1) self.assertIsNotNone(response)