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
1 change: 1 addition & 0 deletions robosystems_client/api/documents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
180 changes: 180 additions & 0 deletions robosystems_client/api/documents/delete_document.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,
document_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": "/v1/graphs/{graph_id}/documents/{document_id}".format(
graph_id=quote(str(graph_id), safe=""),
document_id=quote(str(document_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,
document_id: str,
*,
client: AuthenticatedClient,
) -> Response[Any | HTTPValidationError]:
"""Delete Document

Delete a document and all its sections.

Args:
graph_id (str):
document_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[Any | HTTPValidationError]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
document_id=document_id,
)

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

return _build_response(client=client, response=response)


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

Delete a document and all its sections.

Args:
graph_id (str):
document_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:
Any | HTTPValidationError
"""

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


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

Delete a document and all its sections.

Args:
graph_id (str):
document_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[Any | HTTPValidationError]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
document_id=document_id,
)

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

return _build_response(client=client, response=response)


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

Delete a document and all its sections.

Args:
graph_id (str):
document_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:
Any | HTTPValidationError
"""

return (
await asyncio_detailed(
graph_id=graph_id,
document_id=document_id,
client=client,
)
).parsed
194 changes: 194 additions & 0 deletions robosystems_client/api/documents/list_documents.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.document_list_response import DocumentListResponse
from ...models.http_validation_error import HTTPValidationError
from ...types import UNSET, Response, Unset


def _get_kwargs(
graph_id: str,
*,
source_type: None | str | Unset = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}

json_source_type: None | str | Unset
if isinstance(source_type, Unset):
json_source_type = UNSET
else:
json_source_type = source_type
params["source_type"] = json_source_type

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

_kwargs: dict[str, Any] = {
"method": "get",
"url": "/v1/graphs/{graph_id}/documents".format(
graph_id=quote(str(graph_id), safe=""),
),
"params": params,
}

return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> DocumentListResponse | HTTPValidationError | None:
if response.status_code == 200:
response_200 = DocumentListResponse.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[DocumentListResponse | 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,
*,
client: AuthenticatedClient,
source_type: None | str | Unset = UNSET,
) -> Response[DocumentListResponse | HTTPValidationError]:
"""List Documents

List indexed documents for a graph.

Args:
graph_id (str):
source_type (None | str | Unset):

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

kwargs = _get_kwargs(
graph_id=graph_id,
source_type=source_type,
)

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

return _build_response(client=client, response=response)


def sync(
graph_id: str,
*,
client: AuthenticatedClient,
source_type: None | str | Unset = UNSET,
) -> DocumentListResponse | HTTPValidationError | None:
"""List Documents

List indexed documents for a graph.

Args:
graph_id (str):
source_type (None | str | Unset):

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

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


async def asyncio_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
source_type: None | str | Unset = UNSET,
) -> Response[DocumentListResponse | HTTPValidationError]:
"""List Documents

List indexed documents for a graph.

Args:
graph_id (str):
source_type (None | str | Unset):

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

kwargs = _get_kwargs(
graph_id=graph_id,
source_type=source_type,
)

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

return _build_response(client=client, response=response)


async def asyncio(
graph_id: str,
*,
client: AuthenticatedClient,
source_type: None | str | Unset = UNSET,
) -> DocumentListResponse | HTTPValidationError | None:
"""List Documents

List indexed documents for a graph.

Args:
graph_id (str):
source_type (None | str | Unset):

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

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