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
59 changes: 42 additions & 17 deletions cirro_api_client/v1/api/audit/list_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from ... import errors
from ...client import Client
from ...models.audit_event import AuditEvent
from ...models.list_events_entity_type import ListEventsEntityType
from ...models.paginated_response_audit_event_dto import PaginatedResponseAuditEventDto
from ...types import UNSET, Response, Unset


Expand All @@ -15,6 +15,8 @@ def _get_kwargs(
username: str | Unset = UNSET,
entity_type: ListEventsEntityType | Unset = UNSET,
entity_id: str | Unset = UNSET,
limit: int | Unset = 5000,
next_token: str | Unset = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}

Expand All @@ -28,6 +30,10 @@ def _get_kwargs(

params["entityId"] = entity_id

params["limit"] = limit

params["nextToken"] = next_token

params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

_kwargs: dict[str, Any] = {
Expand All @@ -39,21 +45,16 @@ def _get_kwargs(
return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> list[AuditEvent] | None:
def _parse_response(*, client: Client, response: httpx.Response) -> PaginatedResponseAuditEventDto | None:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = AuditEvent.from_dict(response_200_item_data)

response_200.append(response_200_item)
response_200 = PaginatedResponseAuditEventDto.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[list[AuditEvent]]:
def _build_response(*, client: Client, response: httpx.Response) -> Response[PaginatedResponseAuditEventDto]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -68,7 +69,9 @@ def sync_detailed(
username: str | Unset = UNSET,
entity_type: ListEventsEntityType | Unset = UNSET,
entity_id: str | Unset = UNSET,
) -> Response[list[AuditEvent]]:
limit: int | Unset = 5000,
next_token: str | Unset = UNSET,
) -> Response[PaginatedResponseAuditEventDto]:
"""List audit events

Gets a list of audit events
Expand All @@ -77,20 +80,24 @@ def sync_detailed(
username (str | Unset):
entity_type (ListEventsEntityType | Unset):
entity_id (str | Unset):
limit (int | Unset): Default: 5000.
next_token (str | Unset):
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[list[AuditEvent]]
Response[PaginatedResponseAuditEventDto]
"""

kwargs = _get_kwargs(
username=username,
entity_type=entity_type,
entity_id=entity_id,
limit=limit,
next_token=next_token,
)

response = client.get_httpx_client().request(
Expand All @@ -107,7 +114,9 @@ def sync(
username: str | Unset = UNSET,
entity_type: ListEventsEntityType | Unset = UNSET,
entity_id: str | Unset = UNSET,
) -> list[AuditEvent] | None:
limit: int | Unset = 5000,
next_token: str | Unset = UNSET,
) -> PaginatedResponseAuditEventDto | None:
"""List audit events

Gets a list of audit events
Expand All @@ -116,14 +125,16 @@ def sync(
username (str | Unset):
entity_type (ListEventsEntityType | Unset):
entity_id (str | Unset):
limit (int | Unset): Default: 5000.
next_token (str | Unset):
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:
list[AuditEvent]
PaginatedResponseAuditEventDto
"""

try:
Expand All @@ -132,6 +143,8 @@ def sync(
username=username,
entity_type=entity_type,
entity_id=entity_id,
limit=limit,
next_token=next_token,
).parsed
except errors.NotFoundException:
return None
Expand All @@ -143,7 +156,9 @@ async def asyncio_detailed(
username: str | Unset = UNSET,
entity_type: ListEventsEntityType | Unset = UNSET,
entity_id: str | Unset = UNSET,
) -> Response[list[AuditEvent]]:
limit: int | Unset = 5000,
next_token: str | Unset = UNSET,
) -> Response[PaginatedResponseAuditEventDto]:
"""List audit events

Gets a list of audit events
Expand All @@ -152,20 +167,24 @@ async def asyncio_detailed(
username (str | Unset):
entity_type (ListEventsEntityType | Unset):
entity_id (str | Unset):
limit (int | Unset): Default: 5000.
next_token (str | Unset):
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[list[AuditEvent]]
Response[PaginatedResponseAuditEventDto]
"""

kwargs = _get_kwargs(
username=username,
entity_type=entity_type,
entity_id=entity_id,
limit=limit,
next_token=next_token,
)

response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs)
Expand All @@ -179,7 +198,9 @@ async def asyncio(
username: str | Unset = UNSET,
entity_type: ListEventsEntityType | Unset = UNSET,
entity_id: str | Unset = UNSET,
) -> list[AuditEvent] | None:
limit: int | Unset = 5000,
next_token: str | Unset = UNSET,
) -> PaginatedResponseAuditEventDto | None:
"""List audit events

Gets a list of audit events
Expand All @@ -188,14 +209,16 @@ async def asyncio(
username (str | Unset):
entity_type (ListEventsEntityType | Unset):
entity_id (str | Unset):
limit (int | Unset): Default: 5000.
next_token (str | Unset):
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:
list[AuditEvent]
PaginatedResponseAuditEventDto
"""

try:
Expand All @@ -205,6 +228,8 @@ async def asyncio(
username=username,
entity_type=entity_type,
entity_id=entity_id,
limit=limit,
next_token=next_token,
)
).parsed
except errors.NotFoundException:
Expand Down
180 changes: 180 additions & 0 deletions cirro_api_client/v1/api/file/get_project_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
from http import HTTPStatus
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors
from ...client import Client
from ...models.project_file import ProjectFile
from ...types import Response


def _get_kwargs(
project_id: str,
dataset_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/projects/{project_id}/files/{dataset_id}/path".format(
project_id=quote(str(project_id), safe=""),
dataset_id=quote(str(dataset_id), safe=""),
),
}

return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> ProjectFile | None:
if response.status_code == 200:
response_200 = ProjectFile.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[ProjectFile]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
project_id: str,
dataset_id: str,
*,
client: Client,
) -> Response[ProjectFile]:
"""Get a project file

Fetches details on a single file given its dataset ID and relative path.

Args:
project_id (str):
dataset_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[ProjectFile]
"""

kwargs = _get_kwargs(
project_id=project_id,
dataset_id=dataset_id,
)

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

return _build_response(client=client, response=response)


def sync(
project_id: str,
dataset_id: str,
*,
client: Client,
) -> ProjectFile | None:
"""Get a project file

Fetches details on a single file given its dataset ID and relative path.

Args:
project_id (str):
dataset_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:
ProjectFile
"""

try:
return sync_detailed(
project_id=project_id,
dataset_id=dataset_id,
client=client,
).parsed
except errors.NotFoundException:
return None


async def asyncio_detailed(
project_id: str,
dataset_id: str,
*,
client: Client,
) -> Response[ProjectFile]:
"""Get a project file

Fetches details on a single file given its dataset ID and relative path.

Args:
project_id (str):
dataset_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[ProjectFile]
"""

kwargs = _get_kwargs(
project_id=project_id,
dataset_id=dataset_id,
)

response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs)

return _build_response(client=client, response=response)


async def asyncio(
project_id: str,
dataset_id: str,
*,
client: Client,
) -> ProjectFile | None:
"""Get a project file

Fetches details on a single file given its dataset ID and relative path.

Args:
project_id (str):
dataset_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:
ProjectFile
"""

try:
return (
await asyncio_detailed(
project_id=project_id,
dataset_id=dataset_id,
client=client,
)
).parsed
except errors.NotFoundException:
return None
Loading
Loading