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
15 changes: 15 additions & 0 deletions nuon/api/installs/get_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def _get_kwargs(
finished: bool | Unset = UNSET,
created_at_gte: str | Unset = UNSET,
created_at_lte: str | Unset = UNSET,
search: str | Unset = UNSET,
) -> dict[str, Any]:

params: dict[str, Any] = {}
Expand All @@ -42,6 +43,8 @@ def _get_kwargs(

params["created_at_lte"] = created_at_lte

params["search"] = search

params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

_kwargs: dict[str, Any] = {
Expand Down Expand Up @@ -122,6 +125,7 @@ def sync_detailed(
finished: bool | Unset = UNSET,
created_at_gte: str | Unset = UNSET,
created_at_lte: str | Unset = UNSET,
search: str | Unset = UNSET,
) -> Response[StderrErrResponse | list[AppWorkflow]]:
"""get workflows

Expand All @@ -137,6 +141,7 @@ def sync_detailed(
finished (bool | Unset):
created_at_gte (str | Unset):
created_at_lte (str | Unset):
search (str | Unset):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
Expand All @@ -156,6 +161,7 @@ def sync_detailed(
finished=finished,
created_at_gte=created_at_gte,
created_at_lte=created_at_lte,
search=search,
)

response = client.get_httpx_client().request(
Expand All @@ -177,6 +183,7 @@ def sync(
finished: bool | Unset = UNSET,
created_at_gte: str | Unset = UNSET,
created_at_lte: str | Unset = UNSET,
search: str | Unset = UNSET,
) -> StderrErrResponse | list[AppWorkflow] | None:
"""get workflows

Expand All @@ -192,6 +199,7 @@ def sync(
finished (bool | Unset):
created_at_gte (str | Unset):
created_at_lte (str | Unset):
search (str | Unset):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
Expand All @@ -212,6 +220,7 @@ def sync(
finished=finished,
created_at_gte=created_at_gte,
created_at_lte=created_at_lte,
search=search,
).parsed


Expand All @@ -227,6 +236,7 @@ async def asyncio_detailed(
finished: bool | Unset = UNSET,
created_at_gte: str | Unset = UNSET,
created_at_lte: str | Unset = UNSET,
search: str | Unset = UNSET,
) -> Response[StderrErrResponse | list[AppWorkflow]]:
"""get workflows

Expand All @@ -242,6 +252,7 @@ async def asyncio_detailed(
finished (bool | Unset):
created_at_gte (str | Unset):
created_at_lte (str | Unset):
search (str | Unset):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
Expand All @@ -261,6 +272,7 @@ async def asyncio_detailed(
finished=finished,
created_at_gte=created_at_gte,
created_at_lte=created_at_lte,
search=search,
)

response = await client.get_async_httpx_client().request(**kwargs)
Expand All @@ -280,6 +292,7 @@ async def asyncio(
finished: bool | Unset = UNSET,
created_at_gte: str | Unset = UNSET,
created_at_lte: str | Unset = UNSET,
search: str | Unset = UNSET,
) -> StderrErrResponse | list[AppWorkflow] | None:
"""get workflows

Expand All @@ -295,6 +308,7 @@ async def asyncio(
finished (bool | Unset):
created_at_gte (str | Unset):
created_at_lte (str | Unset):
search (str | Unset):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
Expand All @@ -316,5 +330,6 @@ async def asyncio(
finished=finished,
created_at_gte=created_at_gte,
created_at_lte=created_at_lte,
search=search,
)
).parsed
1 change: 1 addition & 0 deletions nuon/api/runbooks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
202 changes: 202 additions & 0 deletions nuon/api/runbooks/create_runbook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
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.app_runbook import AppRunbook
from ...models.service_create_runbook_request import ServiceCreateRunbookRequest
from ...models.stderr_err_response import StderrErrResponse
from ...types import Response


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

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v1/apps/{app_id}/runbooks".format(
app_id=quote(str(app_id), safe=""),
),
}

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

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

_kwargs["headers"] = headers
return _kwargs


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

return response_201

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

return response_400

if response.status_code == 401:
response_401 = StderrErrResponse.from_dict(response.json())

return response_401

if response.status_code == 403:
response_403 = StderrErrResponse.from_dict(response.json())

return response_403

if response.status_code == 404:
response_404 = StderrErrResponse.from_dict(response.json())

return response_404

if response.status_code == 500:
response_500 = StderrErrResponse.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[AppRunbook | StderrErrResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
app_id: str,
*,
client: AuthenticatedClient,
body: ServiceCreateRunbookRequest,
) -> Response[AppRunbook | StderrErrResponse]:
"""create a runbook for an app

Args:
app_id (str):
body (ServiceCreateRunbookRequest):

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[AppRunbook | StderrErrResponse]
"""

kwargs = _get_kwargs(
app_id=app_id,
body=body,
)

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

return _build_response(client=client, response=response)


def sync(
app_id: str,
*,
client: AuthenticatedClient,
body: ServiceCreateRunbookRequest,
) -> AppRunbook | StderrErrResponse | None:
"""create a runbook for an app

Args:
app_id (str):
body (ServiceCreateRunbookRequest):

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:
AppRunbook | StderrErrResponse
"""

return sync_detailed(
app_id=app_id,
client=client,
body=body,
).parsed


async def asyncio_detailed(
app_id: str,
*,
client: AuthenticatedClient,
body: ServiceCreateRunbookRequest,
) -> Response[AppRunbook | StderrErrResponse]:
"""create a runbook for an app

Args:
app_id (str):
body (ServiceCreateRunbookRequest):

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[AppRunbook | StderrErrResponse]
"""

kwargs = _get_kwargs(
app_id=app_id,
body=body,
)

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

return _build_response(client=client, response=response)


async def asyncio(
app_id: str,
*,
client: AuthenticatedClient,
body: ServiceCreateRunbookRequest,
) -> AppRunbook | StderrErrResponse | None:
"""create a runbook for an app

Args:
app_id (str):
body (ServiceCreateRunbookRequest):

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:
AppRunbook | StderrErrResponse
"""

return (
await asyncio_detailed(
app_id=app_id,
client=client,
body=body,
)
).parsed
Loading
Loading