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
101 changes: 101 additions & 0 deletions cirro_api_client/v1/api/projects/backfill_entities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from http import HTTPStatus
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors
from ...client import Client
from ...types import Response


def _get_kwargs(
project_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "put",
"url": "/projects/{project_id}:backfill-entities".format(
project_id=quote(str(project_id), safe=""),
),
}

return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> Any | None:
if response.status_code == 202:
return None

errors.handle_error_response(response, client.raise_on_unexpected_status)


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
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,
*,
client: Client,
) -> Response[Any]:
"""Backfill entities

Populates the project's dataset and file entity tables from its datasets

Args:
project_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[Any]
"""

kwargs = _get_kwargs(
project_id=project_id,
)

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

return _build_response(client=client, response=response)


async def asyncio_detailed(
project_id: str,
*,
client: Client,
) -> Response[Any]:
"""Backfill entities

Populates the project's dataset and file entity tables from its datasets

Args:
project_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[Any]
"""

kwargs = _get_kwargs(
project_id=project_id,
)

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

return _build_response(client=client, response=response)
126 changes: 126 additions & 0 deletions cirro_api_client/v1/api/sheets/delete_sheet_mapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
from http import HTTPStatus
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors
from ...client import Client
from ...models.entity_type import EntityType
from ...types import Response


def _get_kwargs(
project_id: str,
sheet_id: str,
target_type: EntityType,
target_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": "/projects/{project_id}/sheets/{sheet_id}/mappings/{target_type}/{target_id}".format(
project_id=quote(str(project_id), safe=""),
sheet_id=quote(str(sheet_id), safe=""),
target_type=quote(str(target_type), safe=""),
target_id=quote(str(target_id), safe=""),
),
}

return _kwargs


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

errors.handle_error_response(response, client.raise_on_unexpected_status)


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
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,
sheet_id: str,
target_type: EntityType,
target_id: str,
*,
client: Client,
) -> Response[Any]:
"""Delete column mapping

Removes the saved column mapping from a sheet to a target

Args:
project_id (str):
sheet_id (str):
target_type (EntityType):
target_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[Any]
"""

kwargs = _get_kwargs(
project_id=project_id,
sheet_id=sheet_id,
target_type=target_type,
target_id=target_id,
)

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

return _build_response(client=client, response=response)


async def asyncio_detailed(
project_id: str,
sheet_id: str,
target_type: EntityType,
target_id: str,
*,
client: Client,
) -> Response[Any]:
"""Delete column mapping

Removes the saved column mapping from a sheet to a target

Args:
project_id (str):
sheet_id (str):
target_type (EntityType):
target_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[Any]
"""

kwargs = _get_kwargs(
project_id=project_id,
sheet_id=sheet_id,
target_type=target_type,
target_id=target_id,
)

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

return _build_response(client=client, response=response)
Loading
Loading