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
190 changes: 190 additions & 0 deletions robosystems_client/api/ledger/create_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
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.create_report_request import CreateReportRequest
from ...models.http_validation_error import HTTPValidationError
from ...models.report_response import ReportResponse
from ...types import Response


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

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v1/ledger/{graph_id}/reports".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 | ReportResponse | None:
if response.status_code == 201:
response_201 = ReportResponse.from_dict(response.json())

return response_201

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 | ReportResponse]:
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: CreateReportRequest,
) -> Response[HTTPValidationError | ReportResponse]:
"""Create Report

Create a report definition, generate facts for all mapped elements.

Args:
graph_id (str):
body (CreateReportRequest):

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 | ReportResponse]
"""

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: CreateReportRequest,
) -> HTTPValidationError | ReportResponse | None:
"""Create Report

Create a report definition, generate facts for all mapped elements.

Args:
graph_id (str):
body (CreateReportRequest):

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 | ReportResponse
"""

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


async def asyncio_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
body: CreateReportRequest,
) -> Response[HTTPValidationError | ReportResponse]:
"""Create Report

Create a report definition, generate facts for all mapped elements.

Args:
graph_id (str):
body (CreateReportRequest):

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 | ReportResponse]
"""

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: CreateReportRequest,
) -> HTTPValidationError | ReportResponse | None:
"""Create Report

Create a report definition, generate facts for all mapped elements.

Args:
graph_id (str):
body (CreateReportRequest):

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 | ReportResponse
"""

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


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

return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Any | HTTPValidationError | None:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204

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[Any | HTTPValidationError]:
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,
report_id: str,
*,
client: AuthenticatedClient,
) -> Response[Any | HTTPValidationError]:
"""Delete Report

Delete a report definition and its generated facts.

Args:
graph_id (str):
report_id (str): Report definition ID

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

kwargs = _get_kwargs(
graph_id=graph_id,
report_id=report_id,
)

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

return _build_response(client=client, response=response)


def sync(
graph_id: str,
report_id: str,
*,
client: AuthenticatedClient,
) -> Any | HTTPValidationError | None:
"""Delete Report

Delete a report definition and its generated facts.

Args:
graph_id (str):
report_id (str): Report definition ID

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

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


async def asyncio_detailed(
graph_id: str,
report_id: str,
*,
client: AuthenticatedClient,
) -> Response[Any | HTTPValidationError]:
"""Delete Report

Delete a report definition and its generated facts.

Args:
graph_id (str):
report_id (str): Report definition ID

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

kwargs = _get_kwargs(
graph_id=graph_id,
report_id=report_id,
)

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

return _build_response(client=client, response=response)


async def asyncio(
graph_id: str,
report_id: str,
*,
client: AuthenticatedClient,
) -> Any | HTTPValidationError | None:
"""Delete Report

Delete a report definition and its generated facts.

Args:
graph_id (str):
report_id (str): Report definition ID

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

return (
await asyncio_detailed(
graph_id=graph_id,
report_id=report_id,
client=client,
)
).parsed
Loading
Loading