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
214 changes: 214 additions & 0 deletions nuon/api/installs/reprovision_install_stack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
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_workflow_response import AppWorkflowResponse
from ...models.service_reprovision_install_stack_request import ServiceReprovisionInstallStackRequest
from ...models.stderr_err_response import StderrErrResponse
from ...types import Response


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

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v1/installs/{install_id}/reprovision-stack".format(
install_id=quote(str(install_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
) -> AppWorkflowResponse | StderrErrResponse | None:
if response.status_code == 201:
response_201 = AppWorkflowResponse.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[AppWorkflowResponse | 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(
install_id: str,
*,
client: AuthenticatedClient,
body: ServiceReprovisionInstallStackRequest,
) -> Response[AppWorkflowResponse | StderrErrResponse]:
"""reprovision an install stack

Reprovision an install stack, recreating the runner and its infrastructure. Set `skip_components` to
avoid redeploying components on top of the new stack.

Args:
install_id (str):
body (ServiceReprovisionInstallStackRequest):

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

kwargs = _get_kwargs(
install_id=install_id,
body=body,
)

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

return _build_response(client=client, response=response)


def sync(
install_id: str,
*,
client: AuthenticatedClient,
body: ServiceReprovisionInstallStackRequest,
) -> AppWorkflowResponse | StderrErrResponse | None:
"""reprovision an install stack

Reprovision an install stack, recreating the runner and its infrastructure. Set `skip_components` to
avoid redeploying components on top of the new stack.

Args:
install_id (str):
body (ServiceReprovisionInstallStackRequest):

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

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


async def asyncio_detailed(
install_id: str,
*,
client: AuthenticatedClient,
body: ServiceReprovisionInstallStackRequest,
) -> Response[AppWorkflowResponse | StderrErrResponse]:
"""reprovision an install stack

Reprovision an install stack, recreating the runner and its infrastructure. Set `skip_components` to
avoid redeploying components on top of the new stack.

Args:
install_id (str):
body (ServiceReprovisionInstallStackRequest):

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

kwargs = _get_kwargs(
install_id=install_id,
body=body,
)

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

return _build_response(client=client, response=response)


async def asyncio(
install_id: str,
*,
client: AuthenticatedClient,
body: ServiceReprovisionInstallStackRequest,
) -> AppWorkflowResponse | StderrErrResponse | None:
"""reprovision an install stack

Reprovision an install stack, recreating the runner and its infrastructure. Set `skip_components` to
avoid redeploying components on top of the new stack.

Args:
install_id (str):
body (ServiceReprovisionInstallStackRequest):

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

return (
await asyncio_detailed(
install_id=install_id,
client=client,
body=body,
)
).parsed
2 changes: 2 additions & 0 deletions nuon/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@
from .service_reorder_cells_request import ServiceReorderCellsRequest
from .service_reprovision_install_request import ServiceReprovisionInstallRequest
from .service_reprovision_install_sandbox_request import ServiceReprovisionInstallSandboxRequest
from .service_reprovision_install_stack_request import ServiceReprovisionInstallStackRequest
from .service_reset_install_health_baseline_response import ServiceResetInstallHealthBaselineResponse
from .service_retry_workflow_request import ServiceRetryWorkflowRequest
from .service_retry_workflow_response import ServiceRetryWorkflowResponse
Expand Down Expand Up @@ -1453,6 +1454,7 @@
"ServiceReorderCellsRequest",
"ServiceReprovisionInstallRequest",
"ServiceReprovisionInstallSandboxRequest",
"ServiceReprovisionInstallStackRequest",
"ServiceResetInstallHealthBaselineResponse",
"ServiceRetryWorkflowRequest",
"ServiceRetryWorkflowResponse",
Expand Down
1 change: 1 addition & 0 deletions nuon/models/app_workflow_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AppWorkflowType(str, Enum):
PROVISION = "provision"
REPROVISION = "reprovision"
REPROVISION_SANDBOX = "reprovision_sandbox"
REPROVISION_STACK = "reprovision_stack"
RUNBOOK_RUN = "runbook_run"
SYNC_SECRETS = "sync_secrets"
TEARDOWN_COMPONENT = "teardown_component"
Expand Down
79 changes: 79 additions & 0 deletions nuon/models/service_reprovision_install_stack_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

T = TypeVar("T", bound="ServiceReprovisionInstallStackRequest")


@_attrs_define
class ServiceReprovisionInstallStackRequest:
"""
Attributes:
plan_only (bool | Unset):
role (str | Unset):
skip_components (bool | Unset):
"""

plan_only: bool | Unset = UNSET
role: str | Unset = UNSET
skip_components: bool | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> dict[str, Any]:
plan_only = self.plan_only

role = self.role

skip_components = self.skip_components

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if plan_only is not UNSET:
field_dict["plan_only"] = plan_only
if role is not UNSET:
field_dict["role"] = role
if skip_components is not UNSET:
field_dict["skip_components"] = skip_components

return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
plan_only = d.pop("plan_only", UNSET)

role = d.pop("role", UNSET)

skip_components = d.pop("skip_components", UNSET)

service_reprovision_install_stack_request = cls(
plan_only=plan_only,
role=role,
skip_components=skip_components,
)

service_reprovision_install_stack_request.additional_properties = d
return service_reprovision_install_stack_request

@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())

def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]

def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value

def __delitem__(self, key: str) -> None:
del self.additional_properties[key]

def __contains__(self, key: str) -> bool:
return key in self.additional_properties
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "nuon"
version = "0.19.1103"
version = "0.19.1104"
description = "A client library for accessing Nuon"
authors = []
requires-python = ">=3.11"
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.19.1103
0.19.1104
Loading