diff --git a/cirro_api_client/v1/api/processes/get_process_documentation.py b/cirro_api_client/v1/api/processes/get_process_documentation.py new file mode 100644 index 0000000..f4ed429 --- /dev/null +++ b/cirro_api_client/v1/api/processes/get_process_documentation.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.process_documentation import ProcessDocumentation +from ...types import Response + + +def _get_kwargs( + process_id: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/processes/{process_id}/documentation".format( + process_id=quote(str(process_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: Client, response: httpx.Response) -> ProcessDocumentation | None: + if response.status_code == 200: + response_200 = ProcessDocumentation.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[ProcessDocumentation]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + process_id: str, + *, + client: Client, +) -> Response[ProcessDocumentation]: + """Get process documentation + + Retrieves documentation for a given pipeline or data type (if available). + + Args: + process_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[ProcessDocumentation] + """ + + kwargs = _get_kwargs( + process_id=process_id, + ) + + response = client.get_httpx_client().request( + auth=client.get_auth(), + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + process_id: str, + *, + client: Client, +) -> ProcessDocumentation | None: + """Get process documentation + + Retrieves documentation for a given pipeline or data type (if available). + + Args: + process_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: + ProcessDocumentation + """ + + try: + return sync_detailed( + process_id=process_id, + client=client, + ).parsed + except errors.NotFoundException: + return None + + +async def asyncio_detailed( + process_id: str, + *, + client: Client, +) -> Response[ProcessDocumentation]: + """Get process documentation + + Retrieves documentation for a given pipeline or data type (if available). + + Args: + process_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[ProcessDocumentation] + """ + + kwargs = _get_kwargs( + process_id=process_id, + ) + + response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + process_id: str, + *, + client: Client, +) -> ProcessDocumentation | None: + """Get process documentation + + Retrieves documentation for a given pipeline or data type (if available). + + Args: + process_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: + ProcessDocumentation + """ + + try: + return ( + await asyncio_detailed( + process_id=process_id, + client=client, + ) + ).parsed + except errors.NotFoundException: + return None diff --git a/cirro_api_client/v1/client.py b/cirro_api_client/v1/client.py index 167d4ca..dfc0f3d 100644 --- a/cirro_api_client/v1/client.py +++ b/cirro_api_client/v1/client.py @@ -76,7 +76,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "Client": return evolve(self, timeout=timeout) def set_httpx_client(self, client: httpx.Client) -> "Client": - """Manually the underlying httpx.Client + """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. """ diff --git a/cirro_api_client/v1/models/__init__.py b/cirro_api_client/v1/models/__init__.py index 2d10db2..7464e45 100644 --- a/cirro_api_client/v1/models/__init__.py +++ b/cirro_api_client/v1/models/__init__.py @@ -128,6 +128,7 @@ from .postpone_workspace_autostop_input import PostponeWorkspaceAutostopInput from .process import Process from .process_detail import ProcessDetail +from .process_documentation import ProcessDocumentation from .project import Project from .project_access_request import ProjectAccessRequest from .project_access_type import ProjectAccessType @@ -323,6 +324,7 @@ "PostponeWorkspaceAutostopInput", "Process", "ProcessDetail", + "ProcessDocumentation", "Project", "ProjectAccessRequest", "ProjectAccessType", diff --git a/cirro_api_client/v1/models/mounted_dataset.py b/cirro_api_client/v1/models/mounted_dataset.py index 9505e7f..f7e88bf 100644 --- a/cirro_api_client/v1/models/mounted_dataset.py +++ b/cirro_api_client/v1/models/mounted_dataset.py @@ -1,11 +1,13 @@ 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 +from ..types import UNSET, Unset + T = TypeVar("T", bound="MountedDataset") @@ -15,26 +17,41 @@ class MountedDataset: Attributes: name (str): Folder name that appears in the workspace - uri (str): Full S3 prefix to the data + dataset_id (None | str | Unset): ID of the dataset to mount + custom_uri (None | str | Unset): Full S3 URI to mounted data (if mounting custom path) """ name: str - uri: str + dataset_id: None | str | Unset = UNSET + custom_uri: None | str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: name = self.name - uri = self.uri + dataset_id: None | str | Unset + if isinstance(self.dataset_id, Unset): + dataset_id = UNSET + else: + dataset_id = self.dataset_id + + custom_uri: None | str | Unset + if isinstance(self.custom_uri, Unset): + custom_uri = UNSET + else: + custom_uri = self.custom_uri field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { "name": name, - "uri": uri, } ) + if dataset_id is not UNSET: + field_dict["datasetId"] = dataset_id + if custom_uri is not UNSET: + field_dict["customUri"] = custom_uri return field_dict @@ -43,11 +60,28 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) name = d.pop("name") - uri = d.pop("uri") + def _parse_dataset_id(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + dataset_id = _parse_dataset_id(d.pop("datasetId", UNSET)) + + def _parse_custom_uri(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + custom_uri = _parse_custom_uri(d.pop("customUri", UNSET)) mounted_dataset = cls( name=name, - uri=uri, + dataset_id=dataset_id, + custom_uri=custom_uri, ) mounted_dataset.additional_properties = d diff --git a/cirro_api_client/v1/models/process_documentation.py b/cirro_api_client/v1/models/process_documentation.py new file mode 100644 index 0000000..c608bf0 --- /dev/null +++ b/cirro_api_client/v1/models/process_documentation.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +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 ..types import UNSET, Unset + +T = TypeVar("T", bound="ProcessDocumentation") + + +@_attrs_define +class ProcessDocumentation: + """ + Attributes: + docs_uri (str | Unset): Full URI to documentation + partial_uri (str | Unset): URI of process documentation (partial) + content (str | Unset): Documentation content + """ + + docs_uri: str | Unset = UNSET + partial_uri: str | Unset = UNSET + content: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + docs_uri = self.docs_uri + + partial_uri = self.partial_uri + + content = self.content + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if docs_uri is not UNSET: + field_dict["docsUri"] = docs_uri + if partial_uri is not UNSET: + field_dict["partialUri"] = partial_uri + if content is not UNSET: + field_dict["content"] = content + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + docs_uri = d.pop("docsUri", UNSET) + + partial_uri = d.pop("partialUri", UNSET) + + content = d.pop("content", UNSET) + + process_documentation = cls( + docs_uri=docs_uri, + partial_uri=partial_uri, + content=content, + ) + + process_documentation.additional_properties = d + return process_documentation + + @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/sharing_type.py b/cirro_api_client/v1/models/sharing_type.py index 091ce0b..e287e9e 100644 --- a/cirro_api_client/v1/models/sharing_type.py +++ b/cirro_api_client/v1/models/sharing_type.py @@ -4,6 +4,7 @@ class SharingType(str, Enum): PRIVATE = "PRIVATE" READ_WRITE = "READ_WRITE" + READ_WRITE_CONTROL = "READ_WRITE_CONTROL" UNKNOWN = "UNKNOWN" """ This is a fallback value for when the value is not known, do not use this value when making requests """ diff --git a/cirro_api_client/v1/models/status.py b/cirro_api_client/v1/models/status.py index 565db14..b2baee8 100644 --- a/cirro_api_client/v1/models/status.py +++ b/cirro_api_client/v1/models/status.py @@ -10,6 +10,8 @@ class Status(str, Enum): FAILED = "FAILED" PENDING = "PENDING" RUNNING = "RUNNING" + STARTING = "STARTING" + STOPPING = "STOPPING" SUSPENDED = "SUSPENDED" UNKNOWN = "UNKNOWN" diff --git a/cirro_api_client/v1/models/task.py b/cirro_api_client/v1/models/task.py index 3dc46dc..622001a 100644 --- a/cirro_api_client/v1/models/task.py +++ b/cirro_api_client/v1/models/task.py @@ -19,7 +19,7 @@ class Task: Attributes: name (str): status (str): - native_job_id (None | str | Unset): + native_job_id (None | str | Unset): Job ID on the underlying execution environment (i.e. AWS Batch ID) requested_at (datetime.datetime | None | Unset): started_at (datetime.datetime | None | Unset): stopped_at (datetime.datetime | None | Unset): diff --git a/pyproject.toml b/pyproject.toml index b46a3c6..8bb9445 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cirro_api_client" -version = "1.3.0" +version = "1.3.1" description = "A client library for accessing Cirro" authors = ["Cirro "] license = "MIT"