diff --git a/nuon/api/installs/get_workflow_queue_position.py b/nuon/api/installs/get_workflow_queue_position.py new file mode 100644 index 00000000..6a18e8e0 --- /dev/null +++ b/nuon/api/installs/get_workflow_queue_position.py @@ -0,0 +1,189 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.service_workflow_queue_position_response import ServiceWorkflowQueuePositionResponse +from ...models.stderr_err_response import StderrErrResponse +from ...types import Response + + +def _get_kwargs( + workflow_id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v1/workflows/{workflow_id}/queue-position".format( + workflow_id=quote(str(workflow_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ServiceWorkflowQueuePositionResponse | StderrErrResponse | None: + if response.status_code == 200: + response_200 = ServiceWorkflowQueuePositionResponse.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = StderrErrResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = StderrErrResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = StderrErrResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = StderrErrResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = StderrErrResponse.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ServiceWorkflowQueuePositionResponse | StderrErrResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + workflow_id: str, + *, + client: AuthenticatedClient, +) -> Response[ServiceWorkflowQueuePositionResponse | StderrErrResponse]: + """get queue position for a workflow + + Returns the queue position and workflows ahead when a workflow is pending. + + Args: + workflow_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ServiceWorkflowQueuePositionResponse | StderrErrResponse] + """ + + kwargs = _get_kwargs( + workflow_id=workflow_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + workflow_id: str, + *, + client: AuthenticatedClient, +) -> ServiceWorkflowQueuePositionResponse | StderrErrResponse | None: + """get queue position for a workflow + + Returns the queue position and workflows ahead when a workflow is pending. + + Args: + workflow_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ServiceWorkflowQueuePositionResponse | StderrErrResponse + """ + + return sync_detailed( + workflow_id=workflow_id, + client=client, + ).parsed + + +async def asyncio_detailed( + workflow_id: str, + *, + client: AuthenticatedClient, +) -> Response[ServiceWorkflowQueuePositionResponse | StderrErrResponse]: + """get queue position for a workflow + + Returns the queue position and workflows ahead when a workflow is pending. + + Args: + workflow_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ServiceWorkflowQueuePositionResponse | StderrErrResponse] + """ + + kwargs = _get_kwargs( + workflow_id=workflow_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + workflow_id: str, + *, + client: AuthenticatedClient, +) -> ServiceWorkflowQueuePositionResponse | StderrErrResponse | None: + """get queue position for a workflow + + Returns the queue position and workflows ahead when a workflow is pending. + + Args: + workflow_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ServiceWorkflowQueuePositionResponse | StderrErrResponse + """ + + return ( + await asyncio_detailed( + workflow_id=workflow_id, + client=client, + ) + ).parsed diff --git a/nuon/api/orgs/revoke_org_invite.py b/nuon/api/orgs/revoke_org_invite.py new file mode 100644 index 00000000..f796d72c --- /dev/null +++ b/nuon/api/orgs/revoke_org_invite.py @@ -0,0 +1,201 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.app_org_invite import AppOrgInvite +from ...models.stderr_err_response import StderrErrResponse +from ...types import Response + + +def _get_kwargs( + invite_id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v1/orgs/current/invites/{invite_id}/revoke".format( + invite_id=quote(str(invite_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> AppOrgInvite | StderrErrResponse | None: + if response.status_code == 200: + response_200 = AppOrgInvite.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = StderrErrResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = StderrErrResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 403: + response_403 = StderrErrResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = StderrErrResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = StderrErrResponse.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[AppOrgInvite | StderrErrResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + invite_id: str, + *, + client: AuthenticatedClient, +) -> Response[AppOrgInvite | StderrErrResponse]: + r"""Revoke an org invite + + Revoke a pending org invite. The invite status is set to \"revoked\" and the record is soft-deleted, + freeing the unique constraint so the same email can be re-invited. + + Only org admins can revoke invites. Only pending invites can be revoked. + + Args: + invite_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[AppOrgInvite | StderrErrResponse] + """ + + kwargs = _get_kwargs( + invite_id=invite_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + invite_id: str, + *, + client: AuthenticatedClient, +) -> AppOrgInvite | StderrErrResponse | None: + r"""Revoke an org invite + + Revoke a pending org invite. The invite status is set to \"revoked\" and the record is soft-deleted, + freeing the unique constraint so the same email can be re-invited. + + Only org admins can revoke invites. Only pending invites can be revoked. + + Args: + invite_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + AppOrgInvite | StderrErrResponse + """ + + return sync_detailed( + invite_id=invite_id, + client=client, + ).parsed + + +async def asyncio_detailed( + invite_id: str, + *, + client: AuthenticatedClient, +) -> Response[AppOrgInvite | StderrErrResponse]: + r"""Revoke an org invite + + Revoke a pending org invite. The invite status is set to \"revoked\" and the record is soft-deleted, + freeing the unique constraint so the same email can be re-invited. + + Only org admins can revoke invites. Only pending invites can be revoked. + + Args: + invite_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[AppOrgInvite | StderrErrResponse] + """ + + kwargs = _get_kwargs( + invite_id=invite_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + invite_id: str, + *, + client: AuthenticatedClient, +) -> AppOrgInvite | StderrErrResponse | None: + r"""Revoke an org invite + + Revoke a pending org invite. The invite status is set to \"revoked\" and the record is soft-deleted, + freeing the unique constraint so the same email can be re-invited. + + Only org admins can revoke invites. Only pending invites can be revoked. + + Args: + invite_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + AppOrgInvite | StderrErrResponse + """ + + return ( + await asyncio_detailed( + invite_id=invite_id, + client=client, + ) + ).parsed diff --git a/nuon/models/__init__.py b/nuon/models/__init__.py index 71ba9407..c75172cc 100644 --- a/nuon/models/__init__.py +++ b/nuon/models/__init__.py @@ -622,6 +622,9 @@ from .service_vcs_connection_status_response import ServiceVCSConnectionStatusResponse from .service_vcs_connection_status_response_permissions import ServiceVCSConnectionStatusResponsePermissions from .service_waitlist_request import ServiceWaitlistRequest +from .service_workflow_queue_item import ServiceWorkflowQueueItem +from .service_workflow_queue_item_metadata import ServiceWorkflowQueueItemMetadata +from .service_workflow_queue_position_response import ServiceWorkflowQueuePositionResponse from .signaldb_signal_data import SignaldbSignalData from .signaldb_workflow_ref import SignaldbWorkflowRef from .slack_events_body import SlackEventsBody @@ -1241,6 +1244,9 @@ "ServiceVCSConnectionStatusResponse", "ServiceVCSConnectionStatusResponsePermissions", "ServiceWaitlistRequest", + "ServiceWorkflowQueueItem", + "ServiceWorkflowQueueItemMetadata", + "ServiceWorkflowQueuePositionResponse", "SignaldbSignalData", "SignaldbWorkflowRef", "SlackEventsBody", diff --git a/nuon/models/app_org_invite_status.py b/nuon/models/app_org_invite_status.py index d5f8de3d..b76b1fe3 100644 --- a/nuon/models/app_org_invite_status.py +++ b/nuon/models/app_org_invite_status.py @@ -4,6 +4,7 @@ class AppOrgInviteStatus(str, Enum): ACCEPTED = "accepted" PENDING = "pending" + REVOKED = "revoked" def __str__(self) -> str: return str(self.value) diff --git a/nuon/models/service_workflow_queue_item.py b/nuon/models/service_workflow_queue_item.py new file mode 100644 index 00000000..a633f24a --- /dev/null +++ b/nuon/models/service_workflow_queue_item.py @@ -0,0 +1,126 @@ +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 + +from ..models.app_status import AppStatus +from ..models.app_workflow_type import AppWorkflowType +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.service_workflow_queue_item_metadata import ServiceWorkflowQueueItemMetadata + + +T = TypeVar("T", bound="ServiceWorkflowQueueItem") + + +@_attrs_define +class ServiceWorkflowQueueItem: + """ + Attributes: + created_at (str | Unset): + metadata (ServiceWorkflowQueueItemMetadata | Unset): + status (AppStatus | Unset): + workflow_id (str | Unset): + workflow_type (AppWorkflowType | Unset): + """ + + created_at: str | Unset = UNSET + metadata: ServiceWorkflowQueueItemMetadata | Unset = UNSET + status: AppStatus | Unset = UNSET + workflow_id: str | Unset = UNSET + workflow_type: AppWorkflowType | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + created_at = self.created_at + + metadata: dict[str, Any] | Unset = UNSET + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + status: str | Unset = UNSET + if not isinstance(self.status, Unset): + status = self.status.value + + workflow_id = self.workflow_id + + workflow_type: str | Unset = UNSET + if not isinstance(self.workflow_type, Unset): + workflow_type = self.workflow_type.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if created_at is not UNSET: + field_dict["created_at"] = created_at + if metadata is not UNSET: + field_dict["metadata"] = metadata + if status is not UNSET: + field_dict["status"] = status + if workflow_id is not UNSET: + field_dict["workflow_id"] = workflow_id + if workflow_type is not UNSET: + field_dict["workflow_type"] = workflow_type + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.service_workflow_queue_item_metadata import ServiceWorkflowQueueItemMetadata + + d = dict(src_dict) + created_at = d.pop("created_at", UNSET) + + _metadata = d.pop("metadata", UNSET) + metadata: ServiceWorkflowQueueItemMetadata | Unset + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = ServiceWorkflowQueueItemMetadata.from_dict(_metadata) + + _status = d.pop("status", UNSET) + status: AppStatus | Unset + if isinstance(_status, Unset): + status = UNSET + else: + status = AppStatus(_status) + + workflow_id = d.pop("workflow_id", UNSET) + + _workflow_type = d.pop("workflow_type", UNSET) + workflow_type: AppWorkflowType | Unset + if isinstance(_workflow_type, Unset): + workflow_type = UNSET + else: + workflow_type = AppWorkflowType(_workflow_type) + + service_workflow_queue_item = cls( + created_at=created_at, + metadata=metadata, + status=status, + workflow_id=workflow_id, + workflow_type=workflow_type, + ) + + service_workflow_queue_item.additional_properties = d + return service_workflow_queue_item + + @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/nuon/models/service_workflow_queue_item_metadata.py b/nuon/models/service_workflow_queue_item_metadata.py new file mode 100644 index 00000000..f8615f1f --- /dev/null +++ b/nuon/models/service_workflow_queue_item_metadata.py @@ -0,0 +1,47 @@ +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 + +T = TypeVar("T", bound="ServiceWorkflowQueueItemMetadata") + + +@_attrs_define +class ServiceWorkflowQueueItemMetadata: + """ """ + + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + service_workflow_queue_item_metadata = cls() + + service_workflow_queue_item_metadata.additional_properties = d + return service_workflow_queue_item_metadata + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> str: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: str) -> 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/nuon/models/service_workflow_queue_position_response.py b/nuon/models/service_workflow_queue_position_response.py new file mode 100644 index 00000000..383d00b2 --- /dev/null +++ b/nuon/models/service_workflow_queue_position_response.py @@ -0,0 +1,98 @@ +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 + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.service_workflow_queue_item import ServiceWorkflowQueueItem + + +T = TypeVar("T", bound="ServiceWorkflowQueuePositionResponse") + + +@_attrs_define +class ServiceWorkflowQueuePositionResponse: + """ + Attributes: + position (int | Unset): Position is the 1-based queue position (1 = next to execute). + queue_depth (int | Unset): QueueDepth is the total number of signals waiting in the queue. + signals_ahead (list[ServiceWorkflowQueueItem] | Unset): SignalsAhead are the workflows ahead in the queue, + ordered from front to back. + """ + + position: int | Unset = UNSET + queue_depth: int | Unset = UNSET + signals_ahead: list[ServiceWorkflowQueueItem] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + position = self.position + + queue_depth = self.queue_depth + + signals_ahead: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.signals_ahead, Unset): + signals_ahead = [] + for signals_ahead_item_data in self.signals_ahead: + signals_ahead_item = signals_ahead_item_data.to_dict() + signals_ahead.append(signals_ahead_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if position is not UNSET: + field_dict["position"] = position + if queue_depth is not UNSET: + field_dict["queue_depth"] = queue_depth + if signals_ahead is not UNSET: + field_dict["signals_ahead"] = signals_ahead + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.service_workflow_queue_item import ServiceWorkflowQueueItem + + d = dict(src_dict) + position = d.pop("position", UNSET) + + queue_depth = d.pop("queue_depth", UNSET) + + _signals_ahead = d.pop("signals_ahead", UNSET) + signals_ahead: list[ServiceWorkflowQueueItem] | Unset = UNSET + if _signals_ahead is not UNSET: + signals_ahead = [] + for signals_ahead_item_data in _signals_ahead: + signals_ahead_item = ServiceWorkflowQueueItem.from_dict(signals_ahead_item_data) + + signals_ahead.append(signals_ahead_item) + + service_workflow_queue_position_response = cls( + position=position, + queue_depth=queue_depth, + signals_ahead=signals_ahead, + ) + + service_workflow_queue_position_response.additional_properties = d + return service_workflow_queue_position_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/pyproject.toml b/pyproject.toml index a9a97814..1f7b3a32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nuon" -version = "0.19.970" +version = "0.19.971" description = "A client library for accessing Nuon" authors = [] requires-python = ">=3.10" diff --git a/version.txt b/version.txt index 6174320b..9dbcf364 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.19.970 +0.19.971