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
189 changes: 189 additions & 0 deletions robosystems_client/api/auth/get_invitation_preview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
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.error_response import ErrorResponse
from ...models.http_validation_error import HTTPValidationError
from ...models.invitation_preview_response import InvitationPreviewResponse
from ...types import Response


def _get_kwargs(
token: str,
) -> dict[str, Any]:

_kwargs: dict[str, Any] = {
"method": "get",
"url": "/v1/auth/invitations/{token}".format(
token=quote(str(token), safe=""),
),
}

return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> ErrorResponse | HTTPValidationError | InvitationPreviewResponse | None:
if response.status_code == 200:
response_200 = InvitationPreviewResponse.from_dict(response.json())

return response_200

if response.status_code == 400:
response_400 = ErrorResponse.from_dict(response.json())

return response_400

if response.status_code == 422:
response_422 = HTTPValidationError.from_dict(response.json())

return response_422

if response.status_code == 429:
response_429 = ErrorResponse.from_dict(response.json())

return response_429

if response.status_code == 500:
response_500 = ErrorResponse.from_dict(response.json())

return response_500

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 | HTTPValidationError | InvitationPreviewResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
token: str,
*,
client: AuthenticatedClient | Client,
) -> Response[ErrorResponse | HTTPValidationError | InvitationPreviewResponse]:
"""Preview Invitation

Look up a pending org invitation by its token so the registration page can show what is being
joined. Returns 404 for unknown, expired, revoked, or accepted tokens.

Args:
token (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[ErrorResponse | HTTPValidationError | InvitationPreviewResponse]
"""

kwargs = _get_kwargs(
token=token,
)

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

return _build_response(client=client, response=response)


def sync(
token: str,
*,
client: AuthenticatedClient | Client,
) -> ErrorResponse | HTTPValidationError | InvitationPreviewResponse | None:
"""Preview Invitation

Look up a pending org invitation by its token so the registration page can show what is being
joined. Returns 404 for unknown, expired, revoked, or accepted tokens.

Args:
token (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:
ErrorResponse | HTTPValidationError | InvitationPreviewResponse
"""

return sync_detailed(
token=token,
client=client,
).parsed


async def asyncio_detailed(
token: str,
*,
client: AuthenticatedClient | Client,
) -> Response[ErrorResponse | HTTPValidationError | InvitationPreviewResponse]:
"""Preview Invitation

Look up a pending org invitation by its token so the registration page can show what is being
joined. Returns 404 for unknown, expired, revoked, or accepted tokens.

Args:
token (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[ErrorResponse | HTTPValidationError | InvitationPreviewResponse]
"""

kwargs = _get_kwargs(
token=token,
)

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

return _build_response(client=client, response=response)


async def asyncio(
token: str,
*,
client: AuthenticatedClient | Client,
) -> ErrorResponse | HTTPValidationError | InvitationPreviewResponse | None:
"""Preview Invitation

Look up a pending org invitation by its token so the registration page can show what is being
joined. Returns 404 for unknown, expired, revoked, or accepted tokens.

Args:
token (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:
ErrorResponse | HTTPValidationError | InvitationPreviewResponse
"""

return (
await asyncio_detailed(
token=token,
client=client,
)
).parsed
1 change: 1 addition & 0 deletions robosystems_client/api/graph_members/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
Loading