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
176 changes: 176 additions & 0 deletions cirro_api_client/v1/api/datasets/get_sample_sheets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
from http import HTTPStatus
from typing import Any, Dict, Optional

import httpx

from ... import errors
from ...client import Client
from ...models.sample_sheets import SampleSheets
from ...types import Response


def _get_kwargs(
project_id: str,
dataset_id: str,
) -> Dict[str, Any]:
_kwargs: Dict[str, Any] = {
"method": "get",
"url": f"/projects/{project_id}/datasets/{dataset_id}/samplesheet",
}

return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> Optional[SampleSheets]:
if response.status_code == HTTPStatus.OK:
response_200 = SampleSheets.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[SampleSheets]:
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[SampleSheets]:
"""Generate sample sheets

Generates the sample sheet output for this dataset, useful for debugging the preprocess script.

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[SampleSheets]
"""

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,
) -> Optional[SampleSheets]:
"""Generate sample sheets

Generates the sample sheet output for this dataset, useful for debugging the preprocess script.

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:
SampleSheets
"""

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[SampleSheets]:
"""Generate sample sheets

Generates the sample sheet output for this dataset, useful for debugging the preprocess script.

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[SampleSheets]
"""

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,
) -> Optional[SampleSheets]:
"""Generate sample sheets

Generates the sample sheet output for this dataset, useful for debugging the preprocess script.

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:
SampleSheets
"""

try:
return (
await asyncio_detailed(
project_id=project_id,
dataset_id=dataset_id,
client=client,
)
).parsed
except errors.NotFoundException:
return None
Empty file.
173 changes: 173 additions & 0 deletions cirro_api_client/v1/api/feed/create_discussion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
from http import HTTPStatus
from typing import Any, Dict, Optional

import httpx

from ... import errors
from ...client import Client
from ...models.discussion import Discussion
from ...models.discussion_input import DiscussionInput
from ...types import Response


def _get_kwargs(
*,
body: DiscussionInput,
) -> Dict[str, Any]:
headers: Dict[str, Any] = {}

_kwargs: Dict[str, Any] = {
"method": "post",
"url": "/discussions",
}

_body = body.to_dict()

_kwargs["json"] = _body
headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
return _kwargs


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


def sync_detailed(
*,
client: Client,
body: DiscussionInput,
) -> Response[Discussion]:
"""Create a discussion

Creates a new discussion for an entity

Args:
body (DiscussionInput):
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[Discussion]
"""

kwargs = _get_kwargs(
body=body,
)

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

return _build_response(client=client, response=response)


def sync(
*,
client: Client,
body: DiscussionInput,
) -> Optional[Discussion]:
"""Create a discussion

Creates a new discussion for an entity

Args:
body (DiscussionInput):
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:
Discussion
"""

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


async def asyncio_detailed(
*,
client: Client,
body: DiscussionInput,
) -> Response[Discussion]:
"""Create a discussion

Creates a new discussion for an entity

Args:
body (DiscussionInput):
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[Discussion]
"""

kwargs = _get_kwargs(
body=body,
)

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

return _build_response(client=client, response=response)


async def asyncio(
*,
client: Client,
body: DiscussionInput,
) -> Optional[Discussion]:
"""Create a discussion

Creates a new discussion for an entity

Args:
body (DiscussionInput):
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:
Discussion
"""

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