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
216 changes: 216 additions & 0 deletions nuon/api/apps/create_app_kubernetes_contexts_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
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_app_kubernetes_contexts_config import AppAppKubernetesContextsConfig
from ...models.service_create_app_kubernetes_contexts_config_request import (
ServiceCreateAppKubernetesContextsConfigRequest,
)
from ...models.stderr_err_response import StderrErrResponse
from ...types import Response


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

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v1/apps/{app_id}/kubernetes-contexts-configs".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
) -> AppAppKubernetesContextsConfig | StderrErrResponse | None:
if response.status_code == 201:
response_201 = AppAppKubernetesContextsConfig.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[AppAppKubernetesContextsConfig | 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: ServiceCreateAppKubernetesContextsConfigRequest,
) -> Response[AppAppKubernetesContextsConfig | StderrErrResponse]:
"""create a kubernetes contexts config

Create the named kubernetes_context bindings for an app config version. Each context names a peer
terraform_module or pulumi component that emits cluster connection details as outputs.

Args:
app_id (str):
body (ServiceCreateAppKubernetesContextsConfigRequest):

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[AppAppKubernetesContextsConfig | 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: ServiceCreateAppKubernetesContextsConfigRequest,
) -> AppAppKubernetesContextsConfig | StderrErrResponse | None:
"""create a kubernetes contexts config

Create the named kubernetes_context bindings for an app config version. Each context names a peer
terraform_module or pulumi component that emits cluster connection details as outputs.

Args:
app_id (str):
body (ServiceCreateAppKubernetesContextsConfigRequest):

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

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


async def asyncio_detailed(
app_id: str,
*,
client: AuthenticatedClient,
body: ServiceCreateAppKubernetesContextsConfigRequest,
) -> Response[AppAppKubernetesContextsConfig | StderrErrResponse]:
"""create a kubernetes contexts config

Create the named kubernetes_context bindings for an app config version. Each context names a peer
terraform_module or pulumi component that emits cluster connection details as outputs.

Args:
app_id (str):
body (ServiceCreateAppKubernetesContextsConfigRequest):

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[AppAppKubernetesContextsConfig | 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: ServiceCreateAppKubernetesContextsConfigRequest,
) -> AppAppKubernetesContextsConfig | StderrErrResponse | None:
"""create a kubernetes contexts config

Create the named kubernetes_context bindings for an app config version. Each context names a peer
terraform_module or pulumi component that emits cluster connection details as outputs.

Args:
app_id (str):
body (ServiceCreateAppKubernetesContextsConfigRequest):

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

return (
await asyncio_detailed(
app_id=app_id,
client=client,
body=body,
)
).parsed
8 changes: 8 additions & 0 deletions nuon/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from .app_app_input_config import AppAppInputConfig
from .app_app_input_group import AppAppInputGroup
from .app_app_input_source import AppAppInputSource
from .app_app_kubernetes_context_config import AppAppKubernetesContextConfig
from .app_app_kubernetes_contexts_config import AppAppKubernetesContextsConfig
from .app_app_links import AppAppLinks
from .app_app_operation_role_config import AppAppOperationRoleConfig
from .app_app_operation_role_rule import AppAppOperationRoleRule
Expand Down Expand Up @@ -416,6 +418,7 @@
from .service_app_config_template_type import ServiceAppConfigTemplateType
from .service_app_group_request import ServiceAppGroupRequest
from .service_app_input_request import ServiceAppInputRequest
from .service_app_kubernetes_context import ServiceAppKubernetesContext
from .service_app_policy_config import ServiceAppPolicyConfig
from .service_app_secret_config import ServiceAppSecretConfig
from .service_auth_me_identity import ServiceAuthMeIdentity
Expand Down Expand Up @@ -466,6 +469,7 @@
from .service_create_app_input_config_request import ServiceCreateAppInputConfigRequest
from .service_create_app_input_config_request_groups import ServiceCreateAppInputConfigRequestGroups
from .service_create_app_input_config_request_inputs import ServiceCreateAppInputConfigRequestInputs
from .service_create_app_kubernetes_contexts_config_request import ServiceCreateAppKubernetesContextsConfigRequest
from .service_create_app_operation_role_config_request import ServiceCreateAppOperationRoleConfigRequest
from .service_create_app_permissions_config_request import ServiceCreateAppPermissionsConfigRequest
from .service_create_app_policies_config_request import ServiceCreateAppPoliciesConfigRequest
Expand Down Expand Up @@ -749,6 +753,8 @@
"AppAppInputConfig",
"AppAppInputGroup",
"AppAppInputSource",
"AppAppKubernetesContextConfig",
"AppAppKubernetesContextsConfig",
"AppAppLinks",
"AppAppOperationRoleConfig",
"AppAppOperationRoleRule",
Expand Down Expand Up @@ -1136,6 +1142,7 @@
"ServiceAppConfigTemplateType",
"ServiceAppGroupRequest",
"ServiceAppInputRequest",
"ServiceAppKubernetesContext",
"ServiceAppPolicyConfig",
"ServiceAppSecretConfig",
"ServiceAuthMeIdentity",
Expand Down Expand Up @@ -1182,6 +1189,7 @@
"ServiceCreateAppInputConfigRequest",
"ServiceCreateAppInputConfigRequestGroups",
"ServiceCreateAppInputConfigRequestInputs",
"ServiceCreateAppKubernetesContextsConfigRequest",
"ServiceCreateAppOperationRoleConfigRequest",
"ServiceCreateAppPermissionsConfigRequest",
"ServiceCreateAppPoliciesConfigRequest",
Expand Down
12 changes: 12 additions & 0 deletions nuon/models/app_action_workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class AppActionWorkflowConfig:
created_by_id (str | Unset):
enable_kube_config (SqlNullBool | Unset):
id (str | Unset):
kubernetes_context_name (str | Unset): KubernetesContextName is the name of an AppKubernetesContextConfig on
the same AppConfig. Empty means fall back to the implicit sandbox
default. Stored as a name (not an FK) so it remains stable across
AppConfig versions.
references (list[str] | Unset):
refs (list[RefsRef] | Unset):
role (str | Unset):
Expand All @@ -50,6 +54,7 @@ class AppActionWorkflowConfig:
created_by_id: str | Unset = UNSET
enable_kube_config: SqlNullBool | Unset = UNSET
id: str | Unset = UNSET
kubernetes_context_name: str | Unset = UNSET
references: list[str] | Unset = UNSET
refs: list[RefsRef] | Unset = UNSET
role: str | Unset = UNSET
Expand Down Expand Up @@ -82,6 +87,8 @@ def to_dict(self) -> dict[str, Any]:

id = self.id

kubernetes_context_name = self.kubernetes_context_name

references: list[str] | Unset = UNSET
if not isinstance(self.references, Unset):
references = self.references
Expand Down Expand Up @@ -134,6 +141,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict["enable_kube_config"] = enable_kube_config
if id is not UNSET:
field_dict["id"] = id
if kubernetes_context_name is not UNSET:
field_dict["kubernetes_context_name"] = kubernetes_context_name
if references is not UNSET:
field_dict["references"] = references
if refs is not UNSET:
Expand Down Expand Up @@ -182,6 +191,8 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:

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

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

references = cast(list[str], d.pop("references", UNSET))

_refs = d.pop("refs", UNSET)
Expand Down Expand Up @@ -227,6 +238,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
created_by_id=created_by_id,
enable_kube_config=enable_kube_config,
id=id,
kubernetes_context_name=kubernetes_context_name,
references=references,
refs=refs,
role=role,
Expand Down
18 changes: 18 additions & 0 deletions nuon/models/app_app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ..models.app_app_branch import AppAppBranch
from ..models.app_app_break_glass_config import AppAppBreakGlassConfig
from ..models.app_app_input_config import AppAppInputConfig
from ..models.app_app_kubernetes_contexts_config import AppAppKubernetesContextsConfig
from ..models.app_app_operation_role_config import AppAppOperationRoleConfig
from ..models.app_app_permissions_config import AppAppPermissionsConfig
from ..models.app_app_policies_config import AppAppPoliciesConfig
Expand Down Expand Up @@ -49,6 +50,7 @@ class AppAppConfig:
id (str | Unset):
input_ (AppAppInputConfig | Unset):
intermediate_config (BlobstoreBlob | Unset):
kubernetes_contexts (AppAppKubernetesContextsConfig | Unset):
operation_role_config (AppAppOperationRoleConfig | Unset):
org_id (str | Unset):
permissions (AppAppPermissionsConfig | Unset):
Expand Down Expand Up @@ -82,6 +84,7 @@ class AppAppConfig:
id: str | Unset = UNSET
input_: AppAppInputConfig | Unset = UNSET
intermediate_config: BlobstoreBlob | Unset = UNSET
kubernetes_contexts: AppAppKubernetesContextsConfig | Unset = UNSET
operation_role_config: AppAppOperationRoleConfig | Unset = UNSET
org_id: str | Unset = UNSET
permissions: AppAppPermissionsConfig | Unset = UNSET
Expand Down Expand Up @@ -153,6 +156,10 @@ def to_dict(self) -> dict[str, Any]:
if not isinstance(self.intermediate_config, Unset):
intermediate_config = self.intermediate_config.to_dict()

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

operation_role_config: dict[str, Any] | Unset = UNSET
if not isinstance(self.operation_role_config, Unset):
operation_role_config = self.operation_role_config.to_dict()
Expand Down Expand Up @@ -238,6 +245,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict["input"] = input_
if intermediate_config is not UNSET:
field_dict["intermediate_config"] = intermediate_config
if kubernetes_contexts is not UNSET:
field_dict["kubernetes_contexts"] = kubernetes_contexts
if operation_role_config is not UNSET:
field_dict["operation_role_config"] = operation_role_config
if org_id is not UNSET:
Expand Down Expand Up @@ -279,6 +288,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.app_app_branch import AppAppBranch
from ..models.app_app_break_glass_config import AppAppBreakGlassConfig
from ..models.app_app_input_config import AppAppInputConfig
from ..models.app_app_kubernetes_contexts_config import AppAppKubernetesContextsConfig
from ..models.app_app_operation_role_config import AppAppOperationRoleConfig
from ..models.app_app_permissions_config import AppAppPermissionsConfig
from ..models.app_app_policies_config import AppAppPoliciesConfig
Expand Down Expand Up @@ -358,6 +368,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
else:
intermediate_config = BlobstoreBlob.from_dict(_intermediate_config)

_kubernetes_contexts = d.pop("kubernetes_contexts", UNSET)
kubernetes_contexts: AppAppKubernetesContextsConfig | Unset
if isinstance(_kubernetes_contexts, Unset):
kubernetes_contexts = UNSET
else:
kubernetes_contexts = AppAppKubernetesContextsConfig.from_dict(_kubernetes_contexts)

_operation_role_config = d.pop("operation_role_config", UNSET)
operation_role_config: AppAppOperationRoleConfig | Unset
if isinstance(_operation_role_config, Unset):
Expand Down Expand Up @@ -456,6 +473,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
id=id,
input_=input_,
intermediate_config=intermediate_config,
kubernetes_contexts=kubernetes_contexts,
operation_role_config=operation_role_config,
org_id=org_id,
permissions=permissions,
Expand Down
Loading
Loading