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
227 changes: 227 additions & 0 deletions nuon/api/installs/refresh_install_health_cluster_access.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
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.service_refresh_install_health_cluster_access_request import (
ServiceRefreshInstallHealthClusterAccessRequest,
)
from ...models.service_refresh_install_health_cluster_access_response import (
ServiceRefreshInstallHealthClusterAccessResponse,
)
from ...models.stderr_err_response import StderrErrResponse
from ...types import UNSET, Response, Unset


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

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v1/installs/{install_id}/health/cluster-access".format(
install_id=quote(str(install_id), safe=""),
),
}

if not isinstance(body, Unset):
_kwargs["json"] = body.to_dict()

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

_kwargs["headers"] = headers
return _kwargs


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

return response_200

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[ServiceRefreshInstallHealthClusterAccessResponse | 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: ServiceRefreshInstallHealthClusterAccessRequest | Unset = UNSET,
) -> Response[ServiceRefreshInstallHealthClusterAccessResponse | StderrErrResponse]:
"""refresh the cluster access component health reads through

Derives the install's cluster access from its current stack outputs and the chosen role, then stores
it for the runner's health engine. Use when health reports unknown because the install has not been
deployed since component health was enabled, or after the cluster's endpoint or role changed. The
runner picks the refreshed access up within a minute. Requires the component-health feature.

Args:
install_id (str):
body (ServiceRefreshInstallHealthClusterAccessRequest | Unset):

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[ServiceRefreshInstallHealthClusterAccessResponse | 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: ServiceRefreshInstallHealthClusterAccessRequest | Unset = UNSET,
) -> ServiceRefreshInstallHealthClusterAccessResponse | StderrErrResponse | None:
"""refresh the cluster access component health reads through

Derives the install's cluster access from its current stack outputs and the chosen role, then stores
it for the runner's health engine. Use when health reports unknown because the install has not been
deployed since component health was enabled, or after the cluster's endpoint or role changed. The
runner picks the refreshed access up within a minute. Requires the component-health feature.

Args:
install_id (str):
body (ServiceRefreshInstallHealthClusterAccessRequest | Unset):

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

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


async def asyncio_detailed(
install_id: str,
*,
client: AuthenticatedClient,
body: ServiceRefreshInstallHealthClusterAccessRequest | Unset = UNSET,
) -> Response[ServiceRefreshInstallHealthClusterAccessResponse | StderrErrResponse]:
"""refresh the cluster access component health reads through

Derives the install's cluster access from its current stack outputs and the chosen role, then stores
it for the runner's health engine. Use when health reports unknown because the install has not been
deployed since component health was enabled, or after the cluster's endpoint or role changed. The
runner picks the refreshed access up within a minute. Requires the component-health feature.

Args:
install_id (str):
body (ServiceRefreshInstallHealthClusterAccessRequest | Unset):

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[ServiceRefreshInstallHealthClusterAccessResponse | 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: ServiceRefreshInstallHealthClusterAccessRequest | Unset = UNSET,
) -> ServiceRefreshInstallHealthClusterAccessResponse | StderrErrResponse | None:
"""refresh the cluster access component health reads through

Derives the install's cluster access from its current stack outputs and the chosen role, then stores
it for the runner's health engine. Use when health reports unknown because the install has not been
deployed since component health was enabled, or after the cluster's endpoint or role changed. The
runner picks the refreshed access up within a minute. Requires the component-health feature.

Args:
install_id (str):
body (ServiceRefreshInstallHealthClusterAccessRequest | Unset):

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

return (
await asyncio_detailed(
install_id=install_id,
client=client,
body=body,
)
).parsed
4 changes: 4 additions & 0 deletions nuon/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@
ServicePutInstallComponentHealthCheckRequestDetails,
)
from .service_readme import ServiceReadme
from .service_refresh_install_health_cluster_access_request import ServiceRefreshInstallHealthClusterAccessRequest
from .service_refresh_install_health_cluster_access_response import ServiceRefreshInstallHealthClusterAccessResponse
from .service_remove_action_labels_request import ServiceRemoveActionLabelsRequest
from .service_remove_component_labels_request import ServiceRemoveComponentLabelsRequest
from .service_remove_install_labels_request import ServiceRemoveInstallLabelsRequest
Expand Down Expand Up @@ -1424,6 +1426,8 @@
"ServicePutInstallComponentHealthCheckRequest",
"ServicePutInstallComponentHealthCheckRequestDetails",
"ServiceReadme",
"ServiceRefreshInstallHealthClusterAccessRequest",
"ServiceRefreshInstallHealthClusterAccessResponse",
"ServiceRemoveActionLabelsRequest",
"ServiceRemoveComponentLabelsRequest",
"ServiceRemoveInstallLabelsRequest",
Expand Down
22 changes: 22 additions & 0 deletions nuon/models/app_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class AppInstall:
expected_project_id (str | Unset):
expected_subscription_id (str | Unset):
gcp_account (AppGCPAccount | Unset):
health_cluster_error (str | Unset): HealthClusterError is why component health cannot currently inspect the
install's cluster, empty when it can. Install-level because it is one
fact about the install rather than a property of any component.
id (str | Unset):
install_action_workflows (list[AppInstallActionWorkflow] | Unset):
install_components (list[AppInstallComponent] | Unset):
Expand All @@ -90,6 +93,9 @@ class AppInstall:
install_stack (AppInstallStack | Unset):
install_states (list[AppInstallState] | Unset):
labels (GithubComNuoncoNuonPkgLabelsLabels | Unset):
last_health_report_at (str | Unset): LastHealthReportAt is when a runner last reported component health. It is
how the staleness sweep finds installs that went quiet without polling
every install individually.
lifecycle_phase (AppInstallLifecyclePhase | Unset):
links (AppInstallLinks | Unset):
metadata (AppInstallMetadata | Unset):
Expand Down Expand Up @@ -138,6 +144,7 @@ class AppInstall:
expected_project_id: str | Unset = UNSET
expected_subscription_id: str | Unset = UNSET
gcp_account: AppGCPAccount | Unset = UNSET
health_cluster_error: str | Unset = UNSET
id: str | Unset = UNSET
install_action_workflows: list[AppInstallActionWorkflow] | Unset = UNSET
install_components: list[AppInstallComponent] | Unset = UNSET
Expand All @@ -150,6 +157,7 @@ class AppInstall:
install_stack: AppInstallStack | Unset = UNSET
install_states: list[AppInstallState] | Unset = UNSET
labels: GithubComNuoncoNuonPkgLabelsLabels | Unset = UNSET
last_health_report_at: str | Unset = UNSET
lifecycle_phase: AppInstallLifecyclePhase | Unset = UNSET
links: AppInstallLinks | Unset = UNSET
metadata: AppInstallMetadata | Unset = UNSET
Expand Down Expand Up @@ -247,6 +255,8 @@ def to_dict(self) -> dict[str, Any]:
if not isinstance(self.gcp_account, Unset):
gcp_account = self.gcp_account.to_dict()

health_cluster_error = self.health_cluster_error

id = self.id

install_action_workflows: list[dict[str, Any]] | Unset = UNSET
Expand Down Expand Up @@ -312,6 +322,8 @@ def to_dict(self) -> dict[str, Any]:
if not isinstance(self.labels, Unset):
labels = self.labels.to_dict()

last_health_report_at = self.last_health_report_at

lifecycle_phase: dict[str, Any] | Unset = UNSET
if not isinstance(self.lifecycle_phase, Unset):
lifecycle_phase = self.lifecycle_phase.to_dict()
Expand Down Expand Up @@ -419,6 +431,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict["expected_subscription_id"] = expected_subscription_id
if gcp_account is not UNSET:
field_dict["gcp_account"] = gcp_account
if health_cluster_error is not UNSET:
field_dict["health_cluster_error"] = health_cluster_error
if id is not UNSET:
field_dict["id"] = id
if install_action_workflows is not UNSET:
Expand All @@ -443,6 +457,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict["install_states"] = install_states
if labels is not UNSET:
field_dict["labels"] = labels
if last_health_report_at is not UNSET:
field_dict["last_health_report_at"] = last_health_report_at
if lifecycle_phase is not UNSET:
field_dict["lifecycle_phase"] = lifecycle_phase
if links is not UNSET:
Expand Down Expand Up @@ -621,6 +637,8 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
else:
gcp_account = AppGCPAccount.from_dict(_gcp_account)

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

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

_install_action_workflows = d.pop("install_action_workflows", UNSET)
Expand Down Expand Up @@ -709,6 +727,8 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
else:
labels = GithubComNuoncoNuonPkgLabelsLabels.from_dict(_labels)

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

_lifecycle_phase = d.pop("lifecycle_phase", UNSET)
lifecycle_phase: AppInstallLifecyclePhase | Unset
if isinstance(_lifecycle_phase, Unset):
Expand Down Expand Up @@ -809,6 +829,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
expected_project_id=expected_project_id,
expected_subscription_id=expected_subscription_id,
gcp_account=gcp_account,
health_cluster_error=health_cluster_error,
id=id,
install_action_workflows=install_action_workflows,
install_components=install_components,
Expand All @@ -821,6 +842,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
install_stack=install_stack,
install_states=install_states,
labels=labels,
last_health_report_at=last_health_report_at,
lifecycle_phase=lifecycle_phase,
links=links,
metadata=metadata,
Expand Down
Loading
Loading