-
Notifications
You must be signed in to change notification settings - Fork 0
feat(tables): TablesAPI.upload for /v1/tables/upload/ #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f45816a
feat(tables): add TablesAPI.upload for the new /v1/tables/upload/ end…
jadenfix f658386
fix(generated): skip organization_id form-field when value is None
jadenfix 2b07dd7
fix(tables): pass UNSET (not None) when no organization_id is configured
jadenfix 3764aed
revert(generated): undo manual generated-file patch — fix moved to wr…
jadenfix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """ Contains endpoint functions for accessing the API """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| from http import HTTPStatus | ||
| from typing import Any, cast | ||
| from urllib.parse import quote | ||
|
|
||
| import httpx | ||
|
|
||
| from ...client import AuthenticatedClient, Client | ||
| from ...types import Response, UNSET | ||
| from ... import errors | ||
|
|
||
| from ...models.error_response import ErrorResponse | ||
| from ...models.table_upload_request import TableUploadRequest | ||
| from ...models.table_upload_response import TableUploadResponse | ||
| from typing import cast | ||
|
|
||
|
|
||
|
|
||
| def _get_kwargs( | ||
| *, | ||
| body: TableUploadRequest, | ||
|
|
||
| ) -> dict[str, Any]: | ||
| headers: dict[str, Any] = {} | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| _kwargs: dict[str, Any] = { | ||
| "method": "post", | ||
| "url": "/v1/tables/upload/", | ||
| } | ||
|
|
||
| _kwargs["files"] = body.to_multipart() | ||
|
|
||
|
|
||
|
|
||
| _kwargs["headers"] = headers | ||
| return _kwargs | ||
|
|
||
|
|
||
|
|
||
| def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> ErrorResponse | TableUploadResponse | None: | ||
| if response.status_code == 201: | ||
| response_201 = TableUploadResponse.from_dict(response.json()) | ||
|
|
||
|
|
||
|
|
||
| return response_201 | ||
|
|
||
| if response.status_code == 400: | ||
| response_400 = ErrorResponse.from_dict(response.json()) | ||
|
|
||
|
|
||
|
|
||
| return response_400 | ||
|
|
||
| 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[ErrorResponse | TableUploadResponse]: | ||
| 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: AuthenticatedClient | Client, | ||
| body: TableUploadRequest, | ||
|
|
||
| ) -> Response[ErrorResponse | TableUploadResponse]: | ||
| """ Upload a CSV as a Roe table | ||
|
|
||
| Create a Roe table in the authenticated organization from an uploaded CSV file. Organization API | ||
| keys are scoped to one organization; if organization_id is supplied, it must match that | ||
| organization. | ||
|
|
||
| Args: | ||
| body (TableUploadRequest): Serializer for public CSV table uploads. | ||
|
|
||
| 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[ErrorResponse | TableUploadResponse] | ||
| """ | ||
|
|
||
|
|
||
| kwargs = _get_kwargs( | ||
| body=body, | ||
|
|
||
| ) | ||
|
|
||
| response = client.get_httpx_client().request( | ||
| **kwargs, | ||
| ) | ||
|
|
||
| return _build_response(client=client, response=response) | ||
|
|
||
| def sync( | ||
| *, | ||
| client: AuthenticatedClient | Client, | ||
| body: TableUploadRequest, | ||
|
|
||
| ) -> ErrorResponse | TableUploadResponse | None: | ||
| """ Upload a CSV as a Roe table | ||
|
|
||
| Create a Roe table in the authenticated organization from an uploaded CSV file. Organization API | ||
| keys are scoped to one organization; if organization_id is supplied, it must match that | ||
| organization. | ||
|
|
||
| Args: | ||
| body (TableUploadRequest): Serializer for public CSV table uploads. | ||
|
|
||
| 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: | ||
| ErrorResponse | TableUploadResponse | ||
| """ | ||
|
|
||
|
|
||
| return sync_detailed( | ||
| client=client, | ||
| body=body, | ||
|
|
||
| ).parsed | ||
|
|
||
| async def asyncio_detailed( | ||
| *, | ||
| client: AuthenticatedClient | Client, | ||
| body: TableUploadRequest, | ||
|
|
||
| ) -> Response[ErrorResponse | TableUploadResponse]: | ||
| """ Upload a CSV as a Roe table | ||
|
|
||
| Create a Roe table in the authenticated organization from an uploaded CSV file. Organization API | ||
| keys are scoped to one organization; if organization_id is supplied, it must match that | ||
| organization. | ||
|
|
||
| Args: | ||
| body (TableUploadRequest): Serializer for public CSV table uploads. | ||
|
|
||
| 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[ErrorResponse | TableUploadResponse] | ||
| """ | ||
|
|
||
|
|
||
| kwargs = _get_kwargs( | ||
| body=body, | ||
|
|
||
| ) | ||
|
|
||
| response = await client.get_async_httpx_client().request( | ||
| **kwargs | ||
| ) | ||
|
|
||
| return _build_response(client=client, response=response) | ||
|
|
||
| async def asyncio( | ||
| *, | ||
| client: AuthenticatedClient | Client, | ||
| body: TableUploadRequest, | ||
|
|
||
| ) -> ErrorResponse | TableUploadResponse | None: | ||
| """ Upload a CSV as a Roe table | ||
|
|
||
| Create a Roe table in the authenticated organization from an uploaded CSV file. Organization API | ||
| keys are scoped to one organization; if organization_id is supplied, it must match that | ||
| organization. | ||
|
|
||
| Args: | ||
| body (TableUploadRequest): Serializer for public CSV table uploads. | ||
|
|
||
| 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: | ||
| ErrorResponse | TableUploadResponse | ||
| """ | ||
|
|
||
|
|
||
| return (await asyncio_detailed( | ||
| client=client, | ||
| body=body, | ||
|
|
||
| )).parsed | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.