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 cirro_api_client/v1/api/app_registrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
101 changes: 101 additions & 0 deletions cirro_api_client/v1/api/app_registrations/approve_app.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(
id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/app-registrations/{id}:approve".format(
id=quote(str(id), safe=""),
),
}

return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> Any | None:
if response.status_code == 200:
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(
id: str,
*,
client: Client,
) -> Response[Any]:
"""Approve application

Mark application as approved by an administrator.

Args:
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(
id=id,
)

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

return _build_response(client=client, response=response)


async def asyncio_detailed(
id: str,
*,
client: Client,
) -> Response[Any]:
"""Approve application

Mark application as approved by an administrator.

Args:
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(
id=id,
)

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

return _build_response(client=client, response=response)
101 changes: 101 additions & 0 deletions cirro_api_client/v1/api/app_registrations/archive_app_registration.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(
id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": "/app-registrations/{id}".format(
id=quote(str(id), safe=""),
),
}

return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> Any | None:
if response.status_code == 200:
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(
id: str,
*,
client: Client,
) -> Response[Any]:
"""Archive app registration

Archives an app registration. Archived registrations cannot authenticate.

Args:
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(
id=id,
)

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

return _build_response(client=client, response=response)


async def asyncio_detailed(
id: str,
*,
client: Client,
) -> Response[Any]:
"""Archive app registration

Archives an app registration. Archived registrations cannot authenticate.

Args:
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(
id=id,
)

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

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

import httpx

from ... import errors
from ...client import Client
from ...models.app_registration_input import AppRegistrationInput
from ...models.app_registration_secret_response import AppRegistrationSecretResponse
from ...types import Response


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

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/app-registrations",
}

_kwargs["json"] = body.to_dict()

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

_kwargs["headers"] = headers
return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> AppRegistrationSecretResponse | None:
if response.status_code == 201:
response_201 = AppRegistrationSecretResponse.from_dict(response.json())

return response_201

errors.handle_error_response(response, client.raise_on_unexpected_status)


def _build_response(*, client: Client, response: httpx.Response) -> Response[AppRegistrationSecretResponse]:
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: AppRegistrationInput,
) -> Response[AppRegistrationSecretResponse]:
"""Create app registration

Creates a new OAuth client app registration. Returns the client secret which is only shown once.

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

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: AppRegistrationInput,
) -> AppRegistrationSecretResponse | None:
"""Create app registration

Creates a new OAuth client app registration. Returns the client secret which is only shown once.

Args:
body (AppRegistrationInput):
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:
AppRegistrationSecretResponse
"""

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


async def asyncio_detailed(
*,
client: Client,
body: AppRegistrationInput,
) -> Response[AppRegistrationSecretResponse]:
"""Create app registration

Creates a new OAuth client app registration. Returns the client secret which is only shown once.

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

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: AppRegistrationInput,
) -> AppRegistrationSecretResponse | None:
"""Create app registration

Creates a new OAuth client app registration. Returns the client secret which is only shown once.

Args:
body (AppRegistrationInput):
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:
AppRegistrationSecretResponse
"""

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