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
8 changes: 3 additions & 5 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v2
Expand All @@ -32,9 +33,6 @@ jobs:
run: |
poetry build

- name: Publish python package
- name: Publish package distributions to PyPI
if: github.event_name == 'release'
run: |
poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/cef2210
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,38 @@

from ... import errors
from ...client import Client
from ...models.notebook_instance_status_response import NotebookInstanceStatusResponse
from ...models.cloud_quota import CloudQuota
from ...types import Response


def _get_kwargs(
project_id: str,
notebook_instance_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/projects/{project_id}/notebook-instances/{notebook_instance_id}:status".format(
"url": "/projects/{project_id}/cloud-quotas".format(
project_id=quote(str(project_id), safe=""),
notebook_instance_id=quote(str(notebook_instance_id), safe=""),
),
}

return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> NotebookInstanceStatusResponse | None:
def _parse_response(*, client: Client, response: httpx.Response) -> list[CloudQuota] | None:
if response.status_code == 200:
response_200 = NotebookInstanceStatusResponse.from_dict(response.json())
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = CloudQuota.from_dict(response_200_item_data)

response_200.append(response_200_item)

return response_200

errors.handle_error_response(response, client.raise_on_unexpected_status)


def _build_response(*, client: Client, response: httpx.Response) -> Response[NotebookInstanceStatusResponse]:
def _build_response(*, client: Client, response: httpx.Response) -> Response[list[CloudQuota]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -45,30 +48,27 @@ def _build_response(*, client: Client, response: httpx.Response) -> Response[Not

def sync_detailed(
project_id: str,
notebook_instance_id: str,
*,
client: Client,
) -> Response[NotebookInstanceStatusResponse]:
"""Get notebook instance status
) -> Response[list[CloudQuota]]:
"""Get cloud quotas

Retrieves the status of the instance
Retrieves a list of relevant cloud service quotas for project

Args:
project_id (str):
notebook_instance_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[NotebookInstanceStatusResponse]
Response[list[CloudQuota]]
"""

kwargs = _get_kwargs(
project_id=project_id,
notebook_instance_id=notebook_instance_id,
)

response = client.get_httpx_client().request(
Expand All @@ -81,31 +81,28 @@ def sync_detailed(

def sync(
project_id: str,
notebook_instance_id: str,
*,
client: Client,
) -> NotebookInstanceStatusResponse | None:
"""Get notebook instance status
) -> list[CloudQuota] | None:
"""Get cloud quotas

Retrieves the status of the instance
Retrieves a list of relevant cloud service quotas for project

Args:
project_id (str):
notebook_instance_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:
NotebookInstanceStatusResponse
list[CloudQuota]
"""

try:
return sync_detailed(
project_id=project_id,
notebook_instance_id=notebook_instance_id,
client=client,
).parsed
except errors.NotFoundException:
Expand All @@ -114,30 +111,27 @@ def sync(

async def asyncio_detailed(
project_id: str,
notebook_instance_id: str,
*,
client: Client,
) -> Response[NotebookInstanceStatusResponse]:
"""Get notebook instance status
) -> Response[list[CloudQuota]]:
"""Get cloud quotas

Retrieves the status of the instance
Retrieves a list of relevant cloud service quotas for project

Args:
project_id (str):
notebook_instance_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[NotebookInstanceStatusResponse]
Response[list[CloudQuota]]
"""

kwargs = _get_kwargs(
project_id=project_id,
notebook_instance_id=notebook_instance_id,
)

response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs)
Expand All @@ -147,32 +141,29 @@ async def asyncio_detailed(

async def asyncio(
project_id: str,
notebook_instance_id: str,
*,
client: Client,
) -> NotebookInstanceStatusResponse | None:
"""Get notebook instance status
) -> list[CloudQuota] | None:
"""Get cloud quotas

Retrieves the status of the instance
Retrieves a list of relevant cloud service quotas for project

Args:
project_id (str):
notebook_instance_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:
NotebookInstanceStatusResponse
list[CloudQuota]
"""

try:
return (
await asyncio_detailed(
project_id=project_id,
notebook_instance_id=notebook_instance_id,
client=client,
)
).parsed
Expand Down
188 changes: 188 additions & 0 deletions cirro_api_client/v1/api/projects/request_quota_increase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
from http import HTTPStatus
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors
from ...client import Client
from ...models.request_quota_increase_command import RequestQuotaIncreaseCommand
from ...models.request_quota_increase_response import RequestQuotaIncreaseResponse
from ...types import Response


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

_kwargs: dict[str, Any] = {
"method": "put",
"url": "/projects/{project_id}/cloud-quotas".format(
project_id=quote(str(project_id), safe=""),
),
}

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

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

_kwargs["headers"] = headers
return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> RequestQuotaIncreaseResponse | None:
if response.status_code == 200:
response_200 = RequestQuotaIncreaseResponse.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[RequestQuotaIncreaseResponse]:
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,
*,
client: Client,
body: RequestQuotaIncreaseCommand,
) -> Response[RequestQuotaIncreaseResponse]:
"""Request quota increase

Request a service quota increase for a project's cloud account

Args:
project_id (str):
body (RequestQuotaIncreaseCommand):
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[RequestQuotaIncreaseResponse]
"""

kwargs = _get_kwargs(
project_id=project_id,
body=body,
)

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

return _build_response(client=client, response=response)


def sync(
project_id: str,
*,
client: Client,
body: RequestQuotaIncreaseCommand,
) -> RequestQuotaIncreaseResponse | None:
"""Request quota increase

Request a service quota increase for a project's cloud account

Args:
project_id (str):
body (RequestQuotaIncreaseCommand):
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:
RequestQuotaIncreaseResponse
"""

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


async def asyncio_detailed(
project_id: str,
*,
client: Client,
body: RequestQuotaIncreaseCommand,
) -> Response[RequestQuotaIncreaseResponse]:
"""Request quota increase

Request a service quota increase for a project's cloud account

Args:
project_id (str):
body (RequestQuotaIncreaseCommand):
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[RequestQuotaIncreaseResponse]
"""

kwargs = _get_kwargs(
project_id=project_id,
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(
project_id: str,
*,
client: Client,
body: RequestQuotaIncreaseCommand,
) -> RequestQuotaIncreaseResponse | None:
"""Request quota increase

Request a service quota increase for a project's cloud account

Args:
project_id (str):
body (RequestQuotaIncreaseCommand):
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:
RequestQuotaIncreaseResponse
"""

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