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
168 changes: 168 additions & 0 deletions robosystems_client/api/ledger/get_ledger_entity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
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.http_validation_error import HTTPValidationError
from ...models.ledger_entity_response import LedgerEntityResponse
from ...types import Response


def _get_kwargs(
graph_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/v1/ledger/{graph_id}/entity".format(
graph_id=quote(str(graph_id), safe=""),
),
}

return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> HTTPValidationError | LedgerEntityResponse | None:
if response.status_code == 200:
response_200 = LedgerEntityResponse.from_dict(response.json())

return response_200

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

return response_422

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[HTTPValidationError | LedgerEntityResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
) -> Response[HTTPValidationError | LedgerEntityResponse]:
"""Get Entity

Get the entity for this ledger graph.

Args:
graph_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[HTTPValidationError | LedgerEntityResponse]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
)

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

return _build_response(client=client, response=response)


def sync(
graph_id: str,
*,
client: AuthenticatedClient,
) -> HTTPValidationError | LedgerEntityResponse | None:
"""Get Entity

Get the entity for this ledger graph.

Args:
graph_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:
HTTPValidationError | LedgerEntityResponse
"""

return sync_detailed(
graph_id=graph_id,
client=client,
).parsed


async def asyncio_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
) -> Response[HTTPValidationError | LedgerEntityResponse]:
"""Get Entity

Get the entity for this ledger graph.

Args:
graph_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[HTTPValidationError | LedgerEntityResponse]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
)

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

return _build_response(client=client, response=response)


async def asyncio(
graph_id: str,
*,
client: AuthenticatedClient,
) -> HTTPValidationError | LedgerEntityResponse | None:
"""Get Entity

Get the entity for this ledger graph.

Args:
graph_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:
HTTPValidationError | LedgerEntityResponse
"""

return (
await asyncio_detailed(
graph_id=graph_id,
client=client,
)
).parsed
194 changes: 194 additions & 0 deletions robosystems_client/api/ledger/update_ledger_entity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
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.http_validation_error import HTTPValidationError
from ...models.ledger_entity_response import LedgerEntityResponse
from ...models.update_entity_request import UpdateEntityRequest
from ...types import Response


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

_kwargs: dict[str, Any] = {
"method": "put",
"url": "/v1/ledger/{graph_id}/entity".format(
graph_id=quote(str(graph_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
) -> HTTPValidationError | LedgerEntityResponse | None:
if response.status_code == 200:
response_200 = LedgerEntityResponse.from_dict(response.json())

return response_200

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

return response_422

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[HTTPValidationError | LedgerEntityResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
body: UpdateEntityRequest,
) -> Response[HTTPValidationError | LedgerEntityResponse]:
"""Update Entity

Update entity details. Only provided (non-null) fields are updated.

Args:
graph_id (str):
body (UpdateEntityRequest): Request to update entity details. Only provided fields are
updated.

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[HTTPValidationError | LedgerEntityResponse]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
body=body,
)

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

return _build_response(client=client, response=response)


def sync(
graph_id: str,
*,
client: AuthenticatedClient,
body: UpdateEntityRequest,
) -> HTTPValidationError | LedgerEntityResponse | None:
"""Update Entity

Update entity details. Only provided (non-null) fields are updated.

Args:
graph_id (str):
body (UpdateEntityRequest): Request to update entity details. Only provided fields are
updated.

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:
HTTPValidationError | LedgerEntityResponse
"""

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


async def asyncio_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
body: UpdateEntityRequest,
) -> Response[HTTPValidationError | LedgerEntityResponse]:
"""Update Entity

Update entity details. Only provided (non-null) fields are updated.

Args:
graph_id (str):
body (UpdateEntityRequest): Request to update entity details. Only provided fields are
updated.

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[HTTPValidationError | LedgerEntityResponse]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
body=body,
)

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

return _build_response(client=client, response=response)


async def asyncio(
graph_id: str,
*,
client: AuthenticatedClient,
body: UpdateEntityRequest,
) -> HTTPValidationError | LedgerEntityResponse | None:
"""Update Entity

Update entity details. Only provided (non-null) fields are updated.

Args:
graph_id (str):
body (UpdateEntityRequest): Request to update entity details. Only provided fields are
updated.

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:
HTTPValidationError | LedgerEntityResponse
"""

return (
await asyncio_detailed(
graph_id=graph_id,
client=client,
body=body,
)
).parsed
4 changes: 4 additions & 0 deletions robosystems_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
from .invoice import Invoice
from .invoice_line_item import InvoiceLineItem
from .invoices_response import InvoicesResponse
from .ledger_entity_response import LedgerEntityResponse
from .ledger_entry_response import LedgerEntryResponse
from .ledger_line_item_response import LedgerLineItemResponse
from .ledger_summary_response import LedgerSummaryResponse
Expand Down Expand Up @@ -290,6 +291,7 @@
from .trial_balance_row import TrialBalanceRow
from .upcoming_invoice import UpcomingInvoice
from .update_api_key_request import UpdateAPIKeyRequest
from .update_entity_request import UpdateEntityRequest
from .update_file_response_updatefile import UpdateFileResponseUpdatefile
from .update_member_role_request import UpdateMemberRoleRequest
from .update_org_request import UpdateOrgRequest
Expand Down Expand Up @@ -441,6 +443,7 @@
"Invoice",
"InvoiceLineItem",
"InvoicesResponse",
"LedgerEntityResponse",
"LedgerEntryResponse",
"LedgerLineItemResponse",
"LedgerSummaryResponse",
Expand Down Expand Up @@ -552,6 +555,7 @@
"TrialBalanceRow",
"UpcomingInvoice",
"UpdateAPIKeyRequest",
"UpdateEntityRequest",
"UpdateFileResponseUpdatefile",
"UpdateMemberRoleRequest",
"UpdateOrgRequest",
Expand Down
Loading
Loading