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
177 changes: 177 additions & 0 deletions nuon/api/installs/generate_terraform_installer_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
from http import HTTPStatus
from io import BytesIO
from typing import Any

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.stderr_err_response import StderrErrResponse
from ...types import File, Response


def _get_kwargs(
install_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/v1/installs/{install_id}/generate-terraform-installer-config",
}

return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> File | StderrErrResponse | None:
if response.status_code == 200:
response_200 = File(payload=BytesIO(response.content))

return response_200

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

return response_400

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

return response_401

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

return response_403

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

return response_404

if response.status_code == 500:
response_500 = StderrErrResponse.from_dict(response.content)

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[File | 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,
) -> Response[File | StderrErrResponse]:
"""generate a Terraform installer config

Args:
install_id (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[File | StderrErrResponse]
"""

kwargs = _get_kwargs(
install_id=install_id,
)

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

return _build_response(client=client, response=response)


def sync(
install_id: str,
*,
client: AuthenticatedClient,
) -> File | StderrErrResponse | None:
"""generate a Terraform installer config

Args:
install_id (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:
File | StderrErrResponse
"""

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


async def asyncio_detailed(
install_id: str,
*,
client: AuthenticatedClient,
) -> Response[File | StderrErrResponse]:
"""generate a Terraform installer config

Args:
install_id (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[File | StderrErrResponse]
"""

kwargs = _get_kwargs(
install_id=install_id,
)

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

return _build_response(client=client, response=response)


async def asyncio(
install_id: str,
*,
client: AuthenticatedClient,
) -> File | StderrErrResponse | None:
"""generate a Terraform installer config

Args:
install_id (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:
File | StderrErrResponse
"""

return (
await asyncio_detailed(
install_id=install_id,
client=client,
)
).parsed
6 changes: 6 additions & 0 deletions nuon/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from .app_helm_config import AppHelmConfig
from .app_helm_config_values import AppHelmConfigValues
from .app_helm_release import AppHelmRelease
from .app_helm_repo_config import AppHelmRepoConfig
from .app_install import AppInstall
from .app_install_action_workflow import AppInstallActionWorkflow
from .app_install_action_workflow_run import AppInstallActionWorkflowRun
Expand Down Expand Up @@ -192,6 +193,7 @@
from .app_workflow_step_response_type import AppWorkflowStepResponseType
from .app_workflow_type import AppWorkflowType
from .config_app_policy_type import ConfigAppPolicyType
from .config_helm_repo_config import ConfigHelmRepoConfig
from .configs_oci_registry_auth import ConfigsOCIRegistryAuth
from .configs_oci_registry_repository import ConfigsOCIRegistryRepository
from .configs_oci_registry_type import ConfigsOCIRegistryType
Expand Down Expand Up @@ -376,6 +378,7 @@
from .service_force_shutdown_request import ServiceForceShutdownRequest
from .service_forget_install_request import ServiceForgetInstallRequest
from .service_graceful_shutdown_request import ServiceGracefulShutdownRequest
from .service_helm_repo_config_request import ServiceHelmRepoConfigRequest
from .service_install_phone_home_request import ServiceInstallPhoneHomeRequest
from .service_latest_runner_heart_beats import ServiceLatestRunnerHeartBeats
from .service_mng_shut_down_request import ServiceMngShutDownRequest
Expand Down Expand Up @@ -507,6 +510,7 @@
"AppHelmConfig",
"AppHelmConfigValues",
"AppHelmRelease",
"AppHelmRepoConfig",
"AppInstall",
"AppInstallActionWorkflow",
"AppInstallActionWorkflowRun",
Expand Down Expand Up @@ -632,6 +636,7 @@
"AppWorkflowStepResponseType",
"AppWorkflowType",
"ConfigAppPolicyType",
"ConfigHelmRepoConfig",
"ConfigsOCIRegistryAuth",
"ConfigsOCIRegistryRepository",
"ConfigsOCIRegistryType",
Expand Down Expand Up @@ -792,6 +797,7 @@
"ServiceForceShutdownRequest",
"ServiceForgetInstallRequest",
"ServiceGracefulShutdownRequest",
"ServiceHelmRepoConfigRequest",
"ServiceInstallPhoneHomeRequest",
"ServiceLatestRunnerHeartBeats",
"ServiceMngShutDownRequest",
Expand Down
18 changes: 18 additions & 0 deletions nuon/models/app_helm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

if TYPE_CHECKING:
from ..models.app_helm_config_values import AppHelmConfigValues
from ..models.app_helm_repo_config import AppHelmRepoConfig


T = TypeVar("T", bound="AppHelmConfig")
Expand All @@ -20,6 +21,7 @@ class AppHelmConfig:
"""
Attributes:
chart_name (str | Unset):
helm_repo_config (AppHelmRepoConfig | Unset):
namespace (str | Unset):
storage_driver (str | Unset):
take_ownership (bool | Unset): Newer fields that we don't need to store as columns in the database
Expand All @@ -28,6 +30,7 @@ class AppHelmConfig:
"""

chart_name: str | Unset = UNSET
helm_repo_config: AppHelmRepoConfig | Unset = UNSET
namespace: str | Unset = UNSET
storage_driver: str | Unset = UNSET
take_ownership: bool | Unset = UNSET
Expand All @@ -38,6 +41,10 @@ class AppHelmConfig:
def to_dict(self) -> dict[str, Any]:
chart_name = self.chart_name

helm_repo_config: dict[str, Any] | Unset = UNSET
if not isinstance(self.helm_repo_config, Unset):
helm_repo_config = self.helm_repo_config.to_dict()

namespace = self.namespace

storage_driver = self.storage_driver
Expand All @@ -57,6 +64,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict.update({})
if chart_name is not UNSET:
field_dict["chart_name"] = chart_name
if helm_repo_config is not UNSET:
field_dict["helm_repo_config"] = helm_repo_config
if namespace is not UNSET:
field_dict["namespace"] = namespace
if storage_driver is not UNSET:
Expand All @@ -73,10 +82,18 @@ def to_dict(self) -> dict[str, Any]:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.app_helm_config_values import AppHelmConfigValues
from ..models.app_helm_repo_config import AppHelmRepoConfig

d = dict(src_dict)
chart_name = d.pop("chart_name", UNSET)

_helm_repo_config = d.pop("helm_repo_config", UNSET)
helm_repo_config: AppHelmRepoConfig | Unset
if isinstance(_helm_repo_config, Unset):
helm_repo_config = UNSET
else:
helm_repo_config = AppHelmRepoConfig.from_dict(_helm_repo_config)

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

storage_driver = d.pop("storage_driver", UNSET)
Expand All @@ -94,6 +111,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:

app_helm_config = cls(
chart_name=chart_name,
helm_repo_config=helm_repo_config,
namespace=namespace,
storage_driver=storage_driver,
take_ownership=take_ownership,
Expand Down
79 changes: 79 additions & 0 deletions nuon/models/app_helm_repo_config.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="AppHelmRepoConfig")


@_attrs_define
class AppHelmRepoConfig:
"""
Attributes:
chart (str | Unset):
repo_url (str | Unset):
version (str | Unset):
"""

chart: str | Unset = UNSET
repo_url: str | Unset = UNSET
version: str | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

repo_url = self.repo_url

version = self.version

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if chart is not UNSET:
field_dict["chart"] = chart
if repo_url is not UNSET:
field_dict["repo_url"] = repo_url
if version is not UNSET:
field_dict["version"] = version

return field_dict

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

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

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

app_helm_repo_config = cls(
chart=chart,
repo_url=repo_url,
version=version,
)

app_helm_repo_config.additional_properties = d
return app_helm_repo_config

@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
Loading
Loading