Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
263 changes: 263 additions & 0 deletions robosystems_client/api/operations/resume_operation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error_response import ErrorResponse
from ...models.http_validation_error import HTTPValidationError
from ...models.operation_resume_request import OperationResumeRequest
from ...models.resume_operation_response_resumeoperation import (
ResumeOperationResponseResumeoperation,
)
from ...types import Response


def _get_kwargs(
operation_id: str,
*,
body: OperationResumeRequest,
) -> dict[str, Any]:
headers: dict[str, Any] = {}

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v1/operations/{operation_id}/resume".format(
operation_id=quote(str(operation_id), safe=""),
),
}

_kwargs["json"] = body.to_dict()

headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> (
Any
| ErrorResponse
| HTTPValidationError
| ResumeOperationResponseResumeoperation
| None
):
if response.status_code == 202:
response_202 = ResumeOperationResponseResumeoperation.from_dict(response.json())

return response_202

if response.status_code == 400:
response_400 = ErrorResponse.from_dict(response.json())

return response_400

if response.status_code == 401:
response_401 = ErrorResponse.from_dict(response.json())

return response_401

if response.status_code == 403:
response_403 = ErrorResponse.from_dict(response.json())

return response_403

if response.status_code == 404:
response_404 = ErrorResponse.from_dict(response.json())

return response_404

if response.status_code == 409:
response_409 = cast(Any, None)
return response_409

if response.status_code == 422:
response_422 = HTTPValidationError.from_dict(response.json())

return response_422

if response.status_code == 429:
response_429 = ErrorResponse.from_dict(response.json())

return response_429

if response.status_code == 500:
response_500 = ErrorResponse.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[
Any | ErrorResponse | HTTPValidationError | ResumeOperationResponseResumeoperation
]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
operation_id: str,
*,
client: AuthenticatedClient,
body: OperationResumeRequest,
) -> Response[
Any | ErrorResponse | HTTPValidationError | ResumeOperationResponseResumeoperation
]:
"""Resume Operation

Answers an operation that paused at a checkpoint (status `awaiting_input`) and puts it back on the
worker queue with the answer. The operation keeps its id, so the stream, status and cancel links
stay valid; reconnect to `/stream` to follow the resumed run. Consumes no credits.

Args:
operation_id (str): Operation identifier
body (OperationResumeRequest): Answer for an operation paused at a checkpoint
(`awaiting_input`).

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 | ErrorResponse | HTTPValidationError | ResumeOperationResponseResumeoperation]
"""

kwargs = _get_kwargs(
operation_id=operation_id,
body=body,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
operation_id: str,
*,
client: AuthenticatedClient,
body: OperationResumeRequest,
) -> (
Any
| ErrorResponse
| HTTPValidationError
| ResumeOperationResponseResumeoperation
| None
):
"""Resume Operation

Answers an operation that paused at a checkpoint (status `awaiting_input`) and puts it back on the
worker queue with the answer. The operation keeps its id, so the stream, status and cancel links
stay valid; reconnect to `/stream` to follow the resumed run. Consumes no credits.

Args:
operation_id (str): Operation identifier
body (OperationResumeRequest): Answer for an operation paused at a checkpoint
(`awaiting_input`).

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:
Any | ErrorResponse | HTTPValidationError | ResumeOperationResponseResumeoperation
"""

return sync_detailed(
operation_id=operation_id,
client=client,
body=body,
).parsed


async def asyncio_detailed(
operation_id: str,
*,
client: AuthenticatedClient,
body: OperationResumeRequest,
) -> Response[
Any | ErrorResponse | HTTPValidationError | ResumeOperationResponseResumeoperation
]:
"""Resume Operation

Answers an operation that paused at a checkpoint (status `awaiting_input`) and puts it back on the
worker queue with the answer. The operation keeps its id, so the stream, status and cancel links
stay valid; reconnect to `/stream` to follow the resumed run. Consumes no credits.

Args:
operation_id (str): Operation identifier
body (OperationResumeRequest): Answer for an operation paused at a checkpoint
(`awaiting_input`).

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 | ErrorResponse | HTTPValidationError | ResumeOperationResponseResumeoperation]
"""

kwargs = _get_kwargs(
operation_id=operation_id,
body=body,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
operation_id: str,
*,
client: AuthenticatedClient,
body: OperationResumeRequest,
) -> (
Any
| ErrorResponse
| HTTPValidationError
| ResumeOperationResponseResumeoperation
| None
):
"""Resume Operation

Answers an operation that paused at a checkpoint (status `awaiting_input`) and puts it back on the
worker queue with the answer. The operation keeps its id, so the stream, status and cancel links
stay valid; reconnect to `/stream` to follow the resumed run. Consumes no credits.

Args:
operation_id (str): Operation identifier
body (OperationResumeRequest): Answer for an operation paused at a checkpoint
(`awaiting_input`).

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:
Any | ErrorResponse | HTTPValidationError | ResumeOperationResponseResumeoperation
"""

return (
await asyncio_detailed(
operation_id=operation_id,
client=client,
body=body,
)
).parsed
40 changes: 28 additions & 12 deletions robosystems_client/api/operator/auto_select_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,16 @@ def sync_detailed(
by querying the graph; supports `quick`, `standard`, `extended`) and `mapping` (autonomous Chart of
Accounts → rs-gaap mapping; roboledger graphs only, `extended` only). `GET
/v1/graphs/{graph_id}/operator` lists what is registered. Credits are consumed by actual token
usage, not a fixed price per mode. Execution strategy (sync/SSE/async) auto-selected; override with
`?mode=sync|async`.
usage, not a fixed price per mode. The run executes on the background worker: the default answer is
202 with the operation's `_links` (stream, status, cancel); `?mode=sync` waits up to 50s and answers
200 with the result.

Args:
graph_id (str):
mode (None | ResponseMode | Unset): Override execution mode: sync, async, stream, or auto
mode (None | ResponseMode | Unset): `sync` waits up to 50s for the answer and returns 200
with it (202 with the operation links if the worker is still busy). Anything else —
`async`, `stream`, `auto` or unset — queues the run and returns 202; follow
`_links.stream` for progress and the result.
body (OperatorRequest): Request model for operator interactions.

Raises:
Expand Down Expand Up @@ -174,12 +178,16 @@ def sync(
by querying the graph; supports `quick`, `standard`, `extended`) and `mapping` (autonomous Chart of
Accounts → rs-gaap mapping; roboledger graphs only, `extended` only). `GET
/v1/graphs/{graph_id}/operator` lists what is registered. Credits are consumed by actual token
usage, not a fixed price per mode. Execution strategy (sync/SSE/async) auto-selected; override with
`?mode=sync|async`.
usage, not a fixed price per mode. The run executes on the background worker: the default answer is
202 with the operation's `_links` (stream, status, cancel); `?mode=sync` waits up to 50s and answers
200 with the result.

Args:
graph_id (str):
mode (None | ResponseMode | Unset): Override execution mode: sync, async, stream, or auto
mode (None | ResponseMode | Unset): `sync` waits up to 50s for the answer and returns 200
with it (202 with the operation links if the worker is still busy). Anything else —
`async`, `stream`, `auto` or unset — queues the run and returns 202; follow
`_links.stream` for progress and the result.
body (OperatorRequest): Request model for operator interactions.

Raises:
Expand Down Expand Up @@ -211,12 +219,16 @@ async def asyncio_detailed(
by querying the graph; supports `quick`, `standard`, `extended`) and `mapping` (autonomous Chart of
Accounts → rs-gaap mapping; roboledger graphs only, `extended` only). `GET
/v1/graphs/{graph_id}/operator` lists what is registered. Credits are consumed by actual token
usage, not a fixed price per mode. Execution strategy (sync/SSE/async) auto-selected; override with
`?mode=sync|async`.
usage, not a fixed price per mode. The run executes on the background worker: the default answer is
202 with the operation's `_links` (stream, status, cancel); `?mode=sync` waits up to 50s and answers
200 with the result.

Args:
graph_id (str):
mode (None | ResponseMode | Unset): Override execution mode: sync, async, stream, or auto
mode (None | ResponseMode | Unset): `sync` waits up to 50s for the answer and returns 200
with it (202 with the operation links if the worker is still busy). Anything else —
`async`, `stream`, `auto` or unset — queues the run and returns 202; follow
`_links.stream` for progress and the result.
body (OperatorRequest): Request model for operator interactions.

Raises:
Expand Down Expand Up @@ -251,12 +263,16 @@ async def asyncio(
by querying the graph; supports `quick`, `standard`, `extended`) and `mapping` (autonomous Chart of
Accounts → rs-gaap mapping; roboledger graphs only, `extended` only). `GET
/v1/graphs/{graph_id}/operator` lists what is registered. Credits are consumed by actual token
usage, not a fixed price per mode. Execution strategy (sync/SSE/async) auto-selected; override with
`?mode=sync|async`.
usage, not a fixed price per mode. The run executes on the background worker: the default answer is
202 with the operation's `_links` (stream, status, cancel); `?mode=sync` waits up to 50s and answers
200 with the result.

Args:
graph_id (str):
mode (None | ResponseMode | Unset): Override execution mode: sync, async, stream, or auto
mode (None | ResponseMode | Unset): `sync` waits up to 50s for the answer and returns 200
with it (202 with the operation links if the worker is still busy). Anything else —
`async`, `stream`, `auto` or unset — queues the run and returns 202; follow
`_links.stream` for progress and the result.
body (OperatorRequest): Request model for operator interactions.

Raises:
Expand Down
Loading