From d34d8ee52512c18bea3f6e6683559471516ce2c2 Mon Sep 17 00:00:00 2001 From: API Engineering Date: Mon, 12 Oct 2026 11:52:07 +0000 Subject: [PATCH] [bot] Updated client based on openapi-09ff7b3/clientgen --- DO_OPENAPI_COMMIT_SHA.txt | 2 +- src/pydo/_client.py | 18 + src/pydo/aio/_client.py | 18 + src/pydo/aio/operations/__init__.py | 6 + src/pydo/aio/operations/_operations.py | 23814 ++++++++++++++-------- src/pydo/operations/__init__.py | 6 + src/pydo/operations/_operations.py | 24563 +++++++++++++++-------- 7 files changed, 31550 insertions(+), 16877 deletions(-) diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index 67d44682..f1309d29 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -97dca99 +09ff7b3 diff --git a/src/pydo/_client.py b/src/pydo/_client.py index c59a0d6d..5312165e 100644 --- a/src/pydo/_client.py +++ b/src/pydo/_client.py @@ -45,6 +45,8 @@ KubernetesOperations, LoadBalancersOperations, McpServersOperations, + MicrovmCheckpointsOperations, + MicrovmsOperations, MonitoringOperations, NfsOperations, OneClicksOperations, @@ -63,6 +65,7 @@ ReservedIPv6Operations, SecurityOperations, SessionsOperations, + SignalsOperations, SizesOperations, SnapshotsOperations, SpacesKeyOperations, @@ -160,10 +163,16 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype image_actions: pydo.operations.ImageActionsOperations :ivar insights: InsightsOperations operations :vartype insights: pydo.operations.InsightsOperations + :ivar signals: SignalsOperations operations + :vartype signals: pydo.operations.SignalsOperations :ivar kubernetes: KubernetesOperations operations :vartype kubernetes: pydo.operations.KubernetesOperations :ivar load_balancers: LoadBalancersOperations operations :vartype load_balancers: pydo.operations.LoadBalancersOperations + :ivar microvms: MicrovmsOperations operations + :vartype microvms: pydo.operations.MicrovmsOperations + :ivar microvm_checkpoints: MicrovmCheckpointsOperations operations + :vartype microvm_checkpoints: pydo.operations.MicrovmCheckpointsOperations :ivar monitoring: MonitoringOperations operations :vartype monitoring: pydo.operations.MonitoringOperations :ivar nfs: NfsOperations operations @@ -372,12 +381,21 @@ def __init__( self.insights = InsightsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.signals = SignalsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.kubernetes = KubernetesOperations( self._client, self._config, self._serialize, self._deserialize ) self.load_balancers = LoadBalancersOperations( self._client, self._config, self._serialize, self._deserialize ) + self.microvms = MicrovmsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.microvm_checkpoints = MicrovmCheckpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.monitoring = MonitoringOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/src/pydo/aio/_client.py b/src/pydo/aio/_client.py index cb653108..e74b602b 100644 --- a/src/pydo/aio/_client.py +++ b/src/pydo/aio/_client.py @@ -45,6 +45,8 @@ KubernetesOperations, LoadBalancersOperations, McpServersOperations, + MicrovmCheckpointsOperations, + MicrovmsOperations, MonitoringOperations, NfsOperations, OneClicksOperations, @@ -63,6 +65,7 @@ ReservedIPv6Operations, SecurityOperations, SessionsOperations, + SignalsOperations, SizesOperations, SnapshotsOperations, SpacesKeyOperations, @@ -160,10 +163,16 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype image_actions: pydo.aio.operations.ImageActionsOperations :ivar insights: InsightsOperations operations :vartype insights: pydo.aio.operations.InsightsOperations + :ivar signals: SignalsOperations operations + :vartype signals: pydo.aio.operations.SignalsOperations :ivar kubernetes: KubernetesOperations operations :vartype kubernetes: pydo.aio.operations.KubernetesOperations :ivar load_balancers: LoadBalancersOperations operations :vartype load_balancers: pydo.aio.operations.LoadBalancersOperations + :ivar microvms: MicrovmsOperations operations + :vartype microvms: pydo.aio.operations.MicrovmsOperations + :ivar microvm_checkpoints: MicrovmCheckpointsOperations operations + :vartype microvm_checkpoints: pydo.aio.operations.MicrovmCheckpointsOperations :ivar monitoring: MonitoringOperations operations :vartype monitoring: pydo.aio.operations.MonitoringOperations :ivar nfs: NfsOperations operations @@ -372,12 +381,21 @@ def __init__( self.insights = InsightsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.signals = SignalsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.kubernetes = KubernetesOperations( self._client, self._config, self._serialize, self._deserialize ) self.load_balancers = LoadBalancersOperations( self._client, self._config, self._serialize, self._deserialize ) + self.microvms = MicrovmsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.microvm_checkpoints = MicrovmCheckpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.monitoring = MonitoringOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/src/pydo/aio/operations/__init__.py b/src/pydo/aio/operations/__init__.py index 163af5e7..ba9e9863 100644 --- a/src/pydo/aio/operations/__init__.py +++ b/src/pydo/aio/operations/__init__.py @@ -38,8 +38,11 @@ from ._operations import ImagesOperations from ._operations import ImageActionsOperations from ._operations import InsightsOperations +from ._operations import SignalsOperations from ._operations import KubernetesOperations from ._operations import LoadBalancersOperations +from ._operations import MicrovmsOperations +from ._operations import MicrovmCheckpointsOperations from ._operations import MonitoringOperations from ._operations import NfsOperations from ._operations import OrganizationsOperations @@ -112,8 +115,11 @@ "ImagesOperations", "ImageActionsOperations", "InsightsOperations", + "SignalsOperations", "KubernetesOperations", "LoadBalancersOperations", + "MicrovmsOperations", + "MicrovmCheckpointsOperations", "MonitoringOperations", "NfsOperations", "OrganizationsOperations", diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index 3273a2ff..d339c7ea 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -337,9 +337,9 @@ build_genai_get_scenario_set_download_url_request, build_genai_get_scenario_set_request, build_genai_get_scheduled_indexing_request, - build_genai_get_simulation_journey_request, - build_genai_get_simulation_journey_trajectory_request, - build_genai_get_simulation_journey_trajectory_url_request, + build_genai_get_simulation_episode_request, + build_genai_get_simulation_episode_trajectory_request, + build_genai_get_simulation_episode_trajectory_url_request, build_genai_get_simulation_run_request, build_genai_get_workspace_request, build_genai_import_custom_model_request, @@ -376,7 +376,7 @@ build_genai_list_scenario_library_scenarios_request, build_genai_list_scenario_sets_request, build_genai_list_scenarios_request, - build_genai_list_simulation_journeys_request, + build_genai_list_simulation_episodes_request, build_genai_list_simulation_runs_request, build_genai_list_workspaces_request, build_genai_patch_cancel_simulation_run_request, @@ -442,10 +442,13 @@ build_insights_get_prom_query_range_request, build_insights_get_prom_query_request, build_insights_get_prom_series_request, + build_insights_get_trace_request, build_insights_list_alert_instances_request, build_insights_list_alert_rules_request, build_insights_list_notification_channels_request, build_insights_post_logs_search_request, + build_insights_post_spans_search_request, + build_insights_post_traces_search_request, build_insights_update_alert_rule_request, build_insights_update_notification_channel_request, build_invoices_get_by_uuid_request, @@ -499,6 +502,19 @@ build_mcp_servers_patch_request, build_mcp_servers_run_resync_request, build_mcp_servers_update_tools_request, + build_microvm_checkpoints_create_request, + build_microvm_checkpoints_delete_request, + build_microvm_checkpoints_get_request, + build_microvm_checkpoints_list_request, + build_microvms_create_request, + build_microvms_delete_request, + build_microvms_get_console_request, + build_microvms_get_options_request, + build_microvms_get_request, + build_microvms_list_request, + build_microvms_post_pause_request, + build_microvms_post_resume_request, + build_microvms_run_command_request, build_monitoring_create_alert_policy_request, build_monitoring_create_destination_request, build_monitoring_create_sink_request, @@ -680,6 +696,20 @@ build_sessions_delete_request, build_sessions_list_request, build_sessions_list_search_request, + build_signals_create_deletion_request, + build_signals_create_export_request, + build_signals_get_consent_request, + build_signals_get_deletion_request, + build_signals_get_export_download_request, + build_signals_get_export_options_request, + build_signals_get_export_request, + build_signals_list_agent_sessions_request, + build_signals_list_consents_request, + build_signals_list_deletions_request, + build_signals_list_exports_request, + build_signals_list_session_dialogues_request, + build_signals_update_consent_request, + build_signals_update_team_consent_request, build_sizes_list_request, build_snapshots_delete_request, build_snapshots_get_request, @@ -23816,7 +23846,8 @@ async def create( }, "project_id": "str" # Optional. The ID of the project the app should be assigned to. If omitted, it will be assigned to your default project. - :code:`
`:code:`
`Requires ``project:assign_resource`` scope. + :code:`
`:code:`
`Requires ``project:assign_resource`` and + ``project:update`` scopes. } # response body for status code(s): 200 @@ -40539,7 +40570,8 @@ async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: }, "project_id": "str" # Optional. The ID of the project the app should be assigned to. If omitted, it will be assigned to your default project. - :code:`
`:code:`
`Requires ``project:assign_resource`` scope. + :code:`
`:code:`
`Requires ``project:assign_resource`` and + ``project:update`` scopes. } # response body for status code(s): 200 @@ -166341,42 +166373,249 @@ async def post_logs_search( return cast(JSON, deserialized) # type: ignore + @overload + async def post_traces_search( + self, + region: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Union[JSON, str]: + # pylint: disable=line-too-long + """Search traces. -class KubernetesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. + To search traces in a region, send a POST request to + ``/v2/insights/query/{region}/traces/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + Each result is one trace, aggregated from all of its spans in the time range. A trace is + included when at least one of its spans matches ``filter``. The time range must not exceed 7 + days (\\ ``168h``\\ ). ``pagination.limit`` defaults to 100 (also used when ``limit`` is + ``0``\\ ) and must be between 0 and 1000. Results are ordered by ``started`` descending unless + ``orderBy`` is set. + JSON field names are camelCase (\\ ``timeRange``\\ , ``orderBy``\\ , ``hasMore``\\ , + ``traceId``\\ ). Unknown request properties, invalid filters, and out-of-range values are + rejected with ``400``. + Each request searches a single region; there is no multi-region search. Supported regions are + ``ams2``\\ , ``ams3``\\ , ``atl1``\\ , ``blr1``\\ , ``fra1``\\ , ``lon1``\\ , ``mem1``\\ , + ``nyc1``\\ , ``nyc2``\\ , ``nyc3``\\ , ``ric1``\\ , ``sfo1``\\ , ``sfo2``\\ , ``sfo3``\\ , + ``sgp1``\\ , ``syd1``\\ , and ``tor1``. Requests time out after 60 seconds. + Errors produced by the traces service (\\ ``400``\\ ) have a ``text/plain`` body containing a + short message. Authentication and authorization errors (\\ ``401``\\ , ``403``\\ ), rate + limiting (\\ ``429``\\ ), and routing errors (for example, ``404`` for an unknown region) come + from the API gateway and use the standard JSON error object with ``id`` and ``message``. + ``403`` is also returned for accounts that are in a trial or not in good standing. If the + regional traces backend cannot be reached, the response is ``502`` with a ``text/plain`` body. - Instead, you should access the following operations through - :class:`~pydo.aio.GeneratedClient`'s - :attr:`kubernetes` attribute. - """ + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or str + :rtype: JSON or str + :raises ~azure.core.exceptions.HttpResponseError: - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = ( - input_args.pop(0) if input_args else kwargs.pop("deserializer") - ) + Example: + .. code-block:: python - @distributed_trace_async - async def list_clusters( - self, *, per_page: int = 20, page: int = 1, **kwargs: Any - ) -> JSON: + # JSON input template you can fill out and use as your body input. + body = { + "timeRange": { + "from": { + "absolute": "str", # Optional. An absolute timestamp, either + RFC3339 (with optional fractional seconds) or a Unix epoch integer as a + decimal string. Epoch precision is inferred from magnitude: seconds, + milliseconds, microseconds, or nanoseconds. + "relative": "str" # Optional. A time relative to now. Use + ``now`` for the current time, a bare duration such as ``15m`` or ``24h`` + to look back from now, or an offset such as ``now-2h`` or ``now+30m``. + Supported units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``"" ; + decimal amounts such as ``1.5h`` are allowed. + }, + "to": { + "absolute": "str", # Optional. An absolute timestamp, either + RFC3339 (with optional fractional seconds) or a Unix epoch integer as a + decimal string. Epoch precision is inferred from magnitude: seconds, + milliseconds, microseconds, or nanoseconds. + "relative": "str" # Optional. A time relative to now. Use + ``now`` for the current time, a bare duration such as ``15m`` or ``24h`` + to look back from now, or an offset such as ``now-2h`` or ``now+30m``. + Supported units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``"" ; + decimal amounts such as ``1.5h`` are allowed. + } + }, + "filter": { + "expressions": [ + ... + ], + "field": { + "name": "str", # The field name. Without ``scope``"" , these + names (case-insensitive) resolve to built-in span columns: `traceId` + (`trace.id`, `trace_id`), `spanId` (`span.id`, `span_id`), `parentSpanId` + (`parent.span.id`, `parent_span_id`), `startTime` (`start_time`, + `timestamp`), `endTime` (`end_time`), `durationNs` (`duration`, in + nanoseconds), `name` (`span.name`), `kind` (`span.kind`), `statusCode` + (`status.code`, `status_code`), `statusMessage` (`status.message`, + `status_message`), and `serviceName` (`service.name`, `service_name`). + Any other name is looked up as a span attribute, falling back to a + resource attribute. With `scope` set, `name` is always treated as an + attribute key. Attribute keys may contain only letters, digits, and `.`, + `_`, `-`, `/`, `:`, `@`. In traces ``orderBy``"" , ``name`` must be a + trace-level sort field instead; see the ``orderBy`` field description. + Required. + "scope": "str" # Optional. Restricts the lookup to one + attribute map (case-insensitive). ``resource`` (or + ``resource.attributes``"" ) reads resource attributes; ``attribute`` (or + ``attributes``"" , ``span.attributes``"" ) reads span attributes. Omit to + use the built-in column mapping described for ``name``. Ignored in traces + ``orderBy``. Known values are: "resource", "resource.attributes", + "attribute", "attributes", and "span.attributes". + }, + "operator": "str", # Optional. The comparison operator for a + ``condition`` node. Matching is case-insensitive, and the symbol forms + ``=``"" , ``!=``"" , ``>``"" , ``>=``"" , ``<``"" , and ``<=`` are accepted + as aliases for ``eq``"" , ``neq``"" , ``gt``"" , ``gte``"" , ``lt``"" , and + ``lte``. ``exists`` matches spans where the field is present and non-empty + and ignores ``value``. ``in`` requires an array ``value`` with 1 to 100 + entries. ``neq`` on string fields also matches spans where the field is + absent. Known values are: "eq", "neq", "in", "exists", "gt", "gte", "lt", and + "lte". + "query": "str", # Optional. The search string for a ``text_search`` + node. Leading and trailing whitespace is trimmed; the trimmed string must be + non-empty. + "type": "condition", # Optional. Default value is "condition". The + node type. Matching is case-insensitive. Known values are: "condition", + "and", "or", "not", and "text_search". + "value": {} + }, + "orderBy": [ + { + "field": { + "name": "str", # The field name. Without ``scope``"" + , these names (case-insensitive) resolve to built-in span columns: + `traceId` (`trace.id`, `trace_id`), `spanId` (`span.id`, `span_id`), + `parentSpanId` (`parent.span.id`, `parent_span_id`), `startTime` + (`start_time`, `timestamp`), `endTime` (`end_time`), `durationNs` + (`duration`, in nanoseconds), `name` (`span.name`), `kind` + (`span.kind`), `statusCode` (`status.code`, `status_code`), + `statusMessage` (`status.message`, `status_message`), and + `serviceName` (`service.name`, `service_name`). Any other name is + looked up as a span attribute, falling back to a resource attribute. + With `scope` set, `name` is always treated as an attribute key. + Attribute keys may contain only letters, digits, and `.`, `_`, `-`, + `/`, `:`, `@`. In traces ``orderBy``"" , ``name`` must be a + trace-level sort field instead; see the ``orderBy`` field + description. Required. + "scope": "str" # Optional. Restricts the lookup to + one attribute map (case-insensitive). ``resource`` (or + ``resource.attributes``"" ) reads resource attributes; ``attribute`` + (or ``attributes``"" , ``span.attributes``"" ) reads span attributes. + Omit to use the built-in column mapping described for ``name``. + Ignored in traces ``orderBy``. Known values are: "resource", + "resource.attributes", "attribute", "attributes", and + "span.attributes". + }, + "direction": "desc" # Optional. Default value is "desc". The + sort direction (case-insensitive). Defaults to ``desc``. Known values + are: "asc" and "desc". + } + ], + "pagination": { + "limit": 100 # Optional. Default value is 100. Maximum number of + traces to return. Omitted or ``0`` uses the default of 100. Negative values + or values above 1000 return ``400``"" ; they are not clamped. + } + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "traceId": "str", # The trace identifier. Required. + "durationNs": 0, # Optional. Wall-clock duration of the + trace in nanoseconds. + "errorCount": 0, # Optional. The number of spans in the + trace with an ``Error`` status code. Omitted when zero. + "serviceName": "str", # Optional. The service that emitted + the root span. Omitted when the root span has no service.name resource + attribute. + "spanCount": 0, # Optional. The number of spans in the + trace. + "spanNames": [ + "str" # Optional. The distinct span names present in + the trace. + ], + "started": "2020-02-20 00:00:00", # Optional. The start time + of the earliest span in the trace, in RFC 3339 format. + "status": "str" # Optional. The rolled-up status of the + trace. ``Error`` if any span has an ``Error`` status code, otherwise + ``Ok``. Known values are: "Ok" and "Error". + } + ], + "pagination": { + "hasMore": bool # Whether more results matched the query than were + returned. Required. + } + } + # response body for status code(s): 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def post_traces_search( + self, + region: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Union[JSON, str]: # pylint: disable=line-too-long - """List All Kubernetes Clusters. + """Search traces. - To list all of the Kubernetes clusters on your account, send a GET request - to ``/v2/kubernetes/clusters``. + To search traces in a region, send a POST request to + ``/v2/insights/query/{region}/traces/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + Each result is one trace, aggregated from all of its spans in the time range. A trace is + included when at least one of its spans matches ``filter``. The time range must not exceed 7 + days (\\ ``168h``\\ ). ``pagination.limit`` defaults to 100 (also used when ``limit`` is + ``0``\\ ) and must be between 0 and 1000. Results are ordered by ``started`` descending unless + ``orderBy`` is set. + JSON field names are camelCase (\\ ``timeRange``\\ , ``orderBy``\\ , ``hasMore``\\ , + ``traceId``\\ ). Unknown request properties, invalid filters, and out-of-range values are + rejected with ``400``. + Each request searches a single region; there is no multi-region search. Supported regions are + ``ams2``\\ , ``ams3``\\ , ``atl1``\\ , ``blr1``\\ , ``fra1``\\ , ``lon1``\\ , ``mem1``\\ , + ``nyc1``\\ , ``nyc2``\\ , ``nyc3``\\ , ``ric1``\\ , ``sfo1``\\ , ``sfo2``\\ , ``sfo3``\\ , + ``sgp1``\\ , ``syd1``\\ , and ``tor1``. Requests time out after 60 seconds. + Errors produced by the traces service (\\ ``400``\\ ) have a ``text/plain`` body containing a + short message. Authentication and authorization errors (\\ ``401``\\ , ``403``\\ ), rate + limiting (\\ ``429``\\ ), and routing errors (for example, ``404`` for an unknown region) come + from the API gateway and use the standard JSON error object with ``id`` and ``message``. + ``403`` is also returned for accounts that are in a trial or not in good standing. If the + regional traces backend cannot be reached, the response is ``502`` with a ``text/plain`` body. - :keyword per_page: Number of items returned per page. Default value is 20. - :paramtype per_page: int - :keyword page: Which 'page' of paginated results to return. Default value is 1. - :paramtype page: int - :return: JSON object - :rtype: JSON + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or str + :rtype: JSON or str :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -166384,272 +166623,237 @@ async def list_clusters( # response body for status code(s): 200 response == { - "meta": { - "total": 0 # Optional. Number of objects returned by the request. + "data": [ + { + "traceId": "str", # The trace identifier. Required. + "durationNs": 0, # Optional. Wall-clock duration of the + trace in nanoseconds. + "errorCount": 0, # Optional. The number of spans in the + trace with an ``Error`` status code. Omitted when zero. + "serviceName": "str", # Optional. The service that emitted + the root span. Omitted when the root span has no service.name resource + attribute. + "spanCount": 0, # Optional. The number of spans in the + trace. + "spanNames": [ + "str" # Optional. The distinct span names present in + the trace. + ], + "started": "2020-02-20 00:00:00", # Optional. The start time + of the earliest span in the trace, in RFC 3339 format. + "status": "str" # Optional. The rolled-up status of the + trace. ``Error`` if any span has an ``Error`` status code, otherwise + ``Ok``. Known values are: "Ok" and "Error". + } + ], + "pagination": { + "hasMore": bool # Whether more results matched the query than were + returned. Required. + } + } + # response body for status code(s): 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def post_traces_search( + self, region: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Union[JSON, str]: + # pylint: disable=line-too-long + """Search traces. + + To search traces in a region, send a POST request to + ``/v2/insights/query/{region}/traces/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + Each result is one trace, aggregated from all of its spans in the time range. A trace is + included when at least one of its spans matches ``filter``. The time range must not exceed 7 + days (\\ ``168h``\\ ). ``pagination.limit`` defaults to 100 (also used when ``limit`` is + ``0``\\ ) and must be between 0 and 1000. Results are ordered by ``started`` descending unless + ``orderBy`` is set. + JSON field names are camelCase (\\ ``timeRange``\\ , ``orderBy``\\ , ``hasMore``\\ , + ``traceId``\\ ). Unknown request properties, invalid filters, and out-of-range values are + rejected with ``400``. + Each request searches a single region; there is no multi-region search. Supported regions are + ``ams2``\\ , ``ams3``\\ , ``atl1``\\ , ``blr1``\\ , ``fra1``\\ , ``lon1``\\ , ``mem1``\\ , + ``nyc1``\\ , ``nyc2``\\ , ``nyc3``\\ , ``ric1``\\ , ``sfo1``\\ , ``sfo2``\\ , ``sfo3``\\ , + ``sgp1``\\ , ``syd1``\\ , and ``tor1``. Requests time out after 60 seconds. + Errors produced by the traces service (\\ ``400``\\ ) have a ``text/plain`` body containing a + short message. Authentication and authorization errors (\\ ``401``\\ , ``403``\\ ), rate + limiting (\\ ``429``\\ ), and routing errors (for example, ``404`` for an unknown region) come + from the API gateway and use the standard JSON error object with ``id`` and ``message``. + ``403`` is also returned for accounts that are in a trial or not in good standing. If the + regional traces backend cannot be reached, the response is ``502`` with a ``text/plain`` body. + + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object or str + :rtype: JSON or str + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "timeRange": { + "from": { + "absolute": "str", # Optional. An absolute timestamp, either + RFC3339 (with optional fractional seconds) or a Unix epoch integer as a + decimal string. Epoch precision is inferred from magnitude: seconds, + milliseconds, microseconds, or nanoseconds. + "relative": "str" # Optional. A time relative to now. Use + ``now`` for the current time, a bare duration such as ``15m`` or ``24h`` + to look back from now, or an offset such as ``now-2h`` or ``now+30m``. + Supported units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``"" ; + decimal amounts such as ``1.5h`` are allowed. + }, + "to": { + "absolute": "str", # Optional. An absolute timestamp, either + RFC3339 (with optional fractional seconds) or a Unix epoch integer as a + decimal string. Epoch precision is inferred from magnitude: seconds, + milliseconds, microseconds, or nanoseconds. + "relative": "str" # Optional. A time relative to now. Use + ``now`` for the current time, a bare duration such as ``15m`` or ``24h`` + to look back from now, or an offset such as ``now-2h`` or ``now+30m``. + Supported units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``"" ; + decimal amounts such as ``1.5h`` are allowed. + } }, - "kubernetes_clusters": [ + "filter": { + "expressions": [ + ... + ], + "field": { + "name": "str", # The field name. Without ``scope``"" , these + names (case-insensitive) resolve to built-in span columns: `traceId` + (`trace.id`, `trace_id`), `spanId` (`span.id`, `span_id`), `parentSpanId` + (`parent.span.id`, `parent_span_id`), `startTime` (`start_time`, + `timestamp`), `endTime` (`end_time`), `durationNs` (`duration`, in + nanoseconds), `name` (`span.name`), `kind` (`span.kind`), `statusCode` + (`status.code`, `status_code`), `statusMessage` (`status.message`, + `status_message`), and `serviceName` (`service.name`, `service_name`). + Any other name is looked up as a span attribute, falling back to a + resource attribute. With `scope` set, `name` is always treated as an + attribute key. Attribute keys may contain only letters, digits, and `.`, + `_`, `-`, `/`, `:`, `@`. In traces ``orderBy``"" , ``name`` must be a + trace-level sort field instead; see the ``orderBy`` field description. + Required. + "scope": "str" # Optional. Restricts the lookup to one + attribute map (case-insensitive). ``resource`` (or + ``resource.attributes``"" ) reads resource attributes; ``attribute`` (or + ``attributes``"" , ``span.attributes``"" ) reads span attributes. Omit to + use the built-in column mapping described for ``name``. Ignored in traces + ``orderBy``. Known values are: "resource", "resource.attributes", + "attribute", "attributes", and "span.attributes". + }, + "operator": "str", # Optional. The comparison operator for a + ``condition`` node. Matching is case-insensitive, and the symbol forms + ``=``"" , ``!=``"" , ``>``"" , ``>=``"" , ``<``"" , and ``<=`` are accepted + as aliases for ``eq``"" , ``neq``"" , ``gt``"" , ``gte``"" , ``lt``"" , and + ``lte``. ``exists`` matches spans where the field is present and non-empty + and ignores ``value``. ``in`` requires an array ``value`` with 1 to 100 + entries. ``neq`` on string fields also matches spans where the field is + absent. Known values are: "eq", "neq", "in", "exists", "gt", "gte", "lt", and + "lte". + "query": "str", # Optional. The search string for a ``text_search`` + node. Leading and trailing whitespace is trimmed; the trimmed string must be + non-empty. + "type": "condition", # Optional. Default value is "condition". The + node type. Matching is case-insensitive. Known values are: "condition", + "and", "or", "not", and "text_search". + "value": {} + }, + "orderBy": [ { - "name": "str", # A human-readable name for a Kubernetes - cluster. Required. - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean - value indicating whether auto-scaling is enabled for this node - pool. - "count": 0, # Optional. The number of - Droplet instances in the node pool. - "gpu_partition_mode": "str", # Optional. The - AMD GPU partition mode for this node pool. Only applicable to AMD - GPU sizes that support partitioning. Immutable after the node - pool is created. When omitted, the GPUs in the pool are left - unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" - and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that - can be used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of - key/value mappings specifying labels to apply to all nodes in a - pool. Labels will automatically be applied to all existing nodes - and any subsequent nodes added to the pool. Note that when a - label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum - number of nodes that this node pool can be auto-scaled to. The - value will be ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum - number of nodes that this node pool can be auto-scaled to. The - value will be ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable - name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 - 00:00:00", # Optional. A time value given in ISO8601 - combined date and time format that represents when the - node was created. - "droplet_id": "str", # - Optional. The ID of the Droplet used for the worker node. - "id": "str", # Optional. A - unique ID that can be used to identify and reference the - node. - "name": "str", # Optional. - An automatically generated, human-readable name for the - node. - "status": { - "state": "str" # - Optional. A string indicating the current status of - the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 - 00:00:00" # Optional. A time value given in ISO8601 - combined date and time format that represents when the - node was last updated. - } - ], - "size": "str", # Optional. The slug - identifier for the type of Droplet used as workers in the node - pool. - "tags": [ - "str" # Optional. An array - containing the tags applied to the node pool. All node pools - are automatically tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. - How the node reacts to pods that it won't tolerate. - Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values - are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if - the value of the ``key`` field is "special" and the value - of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. - An arbitrary string. The ``key`` and ``value`` fields of - the ``taint`` object form a key-value pair. For example, - if the value of the ``key`` field is "special" and the - value of the ``value`` field is "gpu", the key value pair - would be ``special=gpu``. - } - ] - } - ], - "region": "str", # The slug identifier for the region where - the Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), - the latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available - versions. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the - AMD Device Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the - AMD GPU Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the - AMD GPU DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether the cluster will be automatically - upgraded to new patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used - by cluster-autoscaler. The autoscaler will apply each expander - from the provided list to narrow down the selection of node types - created to scale up, until either a single node type is left, or - the list of expanders is exhausted. If this flag is unset, - autoscaler will use its default expander ``random``. Passing an - empty list ("" *not* ``null``"" ) will unset any previous - expander customizations. Available expanders: * ``random``"" : - Randomly selects a node group to scale. * `priority`: Selects the - node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in - the least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used - to customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. - Used to customize when cluster autoscaler scales down non-empty nodes - by setting the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP - addresses for the overlay network of the Kubernetes cluster in CIDR - notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public - addresses (IPv4 or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the - control plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the - CoreDNS Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the Kubernetes cluster was created. - "endpoint": "str", # Optional. The base URL of the API - server on the Kubernetes master node. - "ha": False, # Optional. Default value is False. A boolean - value indicating whether the control plane is run in a highly available - configuration in the cluster. Highly available control planes incur less - downtime. The property cannot be disabled. When omitted on create, the - default is version-dependent; for DOKS 1.36.0 and later, the default is - true; for earlier versions, the default is false. - "id": "str", # Optional. A unique ID that can be used to - identify and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the - Kubernetes master node. This will not be set if high availability is - configured on the cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is - False. A boolean value indicating whether worker nodes in the cluster are - not assigned public IP addresses. When omitted on create, the default - value is false. When enabled, a NAT gateway must exist in the VPC where - the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance - window policy. May be one of ``monday`` through ``sunday``"" , or - ``any`` to indicate an arbitrary week day. Known values are: "any", - "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", - and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in - UTC of the maintenance window policy in 24-hour clock format / HH:MM - notation (e.g., ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the - NFS CSI plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the - Nvidia GPU Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the - NVIDIA GPU DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the - RDMA shared device plugin is enabled. - }, - "registries": [ - "str" # Optional. An array of integrated DOCR - registries. - ], - "registry_enabled": bool, # Optional. A read-only boolean - value indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable - IP addresses for services running in the Kubernetes cluster in CIDR - notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is - False. Indicates whether SSO authentication is enabled for the - cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL - for the identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is - False. Indicates whether any non-SSO forms of authentication are - disallowed. Can only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message - providing additional information about the current cluster state. - "state": "str" # Optional. A string indicating the - current status of the cluster. Known values are: "running", - "provisioning", "degraded", "error", "deleted", "upgrading", and - "deleting". + "field": { + "name": "str", # The field name. Without ``scope``"" + , these names (case-insensitive) resolve to built-in span columns: + `traceId` (`trace.id`, `trace_id`), `spanId` (`span.id`, `span_id`), + `parentSpanId` (`parent.span.id`, `parent_span_id`), `startTime` + (`start_time`, `timestamp`), `endTime` (`end_time`), `durationNs` + (`duration`, in nanoseconds), `name` (`span.name`), `kind` + (`span.kind`), `statusCode` (`status.code`, `status_code`), + `statusMessage` (`status.message`, `status_message`), and + `serviceName` (`service.name`, `service_name`). Any other name is + looked up as a span attribute, falling back to a resource attribute. + With `scope` set, `name` is always treated as an attribute key. + Attribute keys may contain only letters, digits, and `.`, `_`, `-`, + `/`, `:`, `@`. In traces ``orderBy``"" , ``name`` must be a + trace-level sort field instead; see the ``orderBy`` field + description. Required. + "scope": "str" # Optional. Restricts the lookup to + one attribute map (case-insensitive). ``resource`` (or + ``resource.attributes``"" ) reads resource attributes; ``attribute`` + (or ``attributes``"" , ``span.attributes``"" ) reads span attributes. + Omit to use the built-in column mapping described for ``name``. + Ignored in traces ``orderBy``. Known values are: "resource", + "resource.attributes", "attribute", "attributes", and + "span.attributes". }, - "surge_upgrade": False, # Optional. Default value is False. - A boolean value indicating whether surge upgrade is enabled/disabled for - the cluster. Surge upgrade makes cluster upgrades fast and reliable by - bringing up new nodes before destroying the outdated nodes. - "tags": [ - "str" # Optional. An array of tags applied to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the Kubernetes cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID - of the VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC - subnet worker nodes are attached to. When unset, the default subnet for - the VPC is used.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "direction": "desc" # Optional. Default value is "desc". The + sort direction (case-insensitive). Defaults to ``desc``. Known values + are: "asc" and "desc". } ], - "links": { - "pages": {} + "pagination": { + "limit": 100 # Optional. Default value is 100. Maximum number of + traces to return. Omitted or ``0`` uses the default of 100. Negative values + or values above 1000 return ``400``"" ; they are not clamped. + } + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "traceId": "str", # The trace identifier. Required. + "durationNs": 0, # Optional. Wall-clock duration of the + trace in nanoseconds. + "errorCount": 0, # Optional. The number of spans in the + trace with an ``Error`` status code. Omitted when zero. + "serviceName": "str", # Optional. The service that emitted + the root span. Omitted when the root span has no service.name resource + attribute. + "spanCount": 0, # Optional. The number of spans in the + trace. + "spanNames": [ + "str" # Optional. The distinct span names present in + the trace. + ], + "started": "2020-02-20 00:00:00", # Optional. The start time + of the earliest span in the trace, in RFC 3339 format. + "status": "str" # Optional. The rolled-up status of the + trace. ``Error`` if any span has an ``Error`` status code, otherwise + ``Ok``. Known values are: "Ok" and "Error". + } + ], + "pagination": { + "hasMore": bool # Whether more results matched the query than were + returned. Required. } } + # response body for status code(s): 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -166664,14 +166868,27 @@ async def list_clusters( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Union[JSON, str]] = kwargs.pop("cls", None) - _request = build_kubernetes_list_clusters_request( - per_page=per_page, - page=page, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_insights_post_traces_search_request( + region=region, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -166686,50 +166903,389 @@ async def list_clusters( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 400, 403, 404, 404, 502]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 502: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(Union[JSON, str], deserialized), response_headers) # type: ignore + + return cast(Union[JSON, str], deserialized) # type: ignore + + @distributed_trace_async + async def get_trace( + self, + region: str, + trace_id: str, + *, + from_parameter: Optional[str] = None, + to: Optional[str] = None, + **kwargs: Any + ) -> Union[JSON, str]: + # pylint: disable=line-too-long + """Retrieve an existing trace. + + To retrieve a single trace and all of its spans, send a GET request to + ``/v2/insights/query/{region}/traces/{trace_id}``. + Only spans that started within the lookup window are returned. The window defaults to the last + 7 days and can be narrowed with the ``from`` and ``to`` query parameters; it must not exceed 7 + days, and ``from`` must not be after ``to``. Spans are returned ordered by start time. At most + 10,000 spans are returned; ``truncated`` is ``true`` when the trace has more. + A trace ID with no spans in the window returns ``404``\\ , as do malformed or uppercase trace + IDs. A trace is only resolvable in the region that ingested it; querying another region also + returns ``404``. + Supported regions are ``ams2``\\ , ``ams3``\\ , ``atl1``\\ , ``blr1``\\ , ``fra1``\\ , + ``lon1``\\ , ``mem1``\\ , ``nyc1``\\ , ``nyc2``\\ , ``nyc3``\\ , ``ric1``\\ , ``sfo1``\\ , + ``sfo2``\\ , ``sfo3``\\ , ``sgp1``\\ , ``syd1``\\ , and ``tor1``. Requests time out after 60 + seconds. + Errors produced by the traces service (\\ ``400``\\ , and ``404`` when no trace is found) have + a ``text/plain`` body containing a short message. Authentication and authorization errors (\\ + ``401``\\ , ``403``\\ ), rate limiting (\\ ``429``\\ ), and routing errors (for example, + ``404`` for an unknown region) come from the API gateway and use the standard JSON error object + with ``id`` and ``message``. ``403`` is also returned for accounts that are in a trial or not + in good standing. If the regional traces backend cannot be reached, the response is ``502`` + with a ``text/plain`` body. + JSON field names are camelCase (\\ ``traceId``\\ , ``spanId``\\ , ``startTime``\\ , + ``endTime``\\ , ``durationNs``\\ , ``serviceName``\\ , ``statusCode``\\ , ``parentSpanId``\\ ). + + :param region: The datacenter region slug for the query. Required. + :type region: str + :param trace_id: The OpenTelemetry trace ID to retrieve, as 32 lowercase hexadecimal + characters. IDs are matched exactly; an ID with no spans in the lookup window returns ``404``. + Malformed or uppercase IDs are not rejected with ``400``\\ ; they also return ``404``. + Required. + :type trace_id: str + :keyword from_parameter: Start of the trace lookup window. Accepts a relative time (\\ + ``now``\\ , a bare duration such as ``24h`` to look back from now, or ``now-2h``\\ ) or an + absolute time (RFC3339, or a Unix epoch integer in seconds, milliseconds, microseconds, or + nanoseconds). Defaults to 7 days before now. Default value is None. + :paramtype from_parameter: str + :keyword to: End of the trace lookup window, in the same formats as ``from``. Defaults to now. + Default value is None. + :paramtype to: str + :return: JSON object or str + :rtype: JSON or str + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "spans": [ + { + "spanId": "str", # The span identifier. Required. + "traceId": "str", # The trace this span belongs to. + Required. + "attributes": { + "str": "str" # Optional. Span attributes. Omitted + when empty. + }, + "durationNs": 0, # Optional. Span duration in nanoseconds. + "endTime": "2020-02-20 00:00:00", # Optional. The span end + time. + "kind": "str", # Optional. The OpenTelemetry span kind as a + string, for example ``Server``"" , ``Client``"" , or ``Internal``. + "name": "str", # Optional. The span name, typically the + operation being performed. + "parentSpanId": "str", # Optional. The parent span + identifier. Omitted for the root span. + "resource": { + "str": "str" # Optional. Resource attributes + associated with the span. + }, + "serviceName": "str", # Optional. The service that emitted + the span. Omitted when the span has no service.name resource attribute. + "startTime": "2020-02-20 00:00:00", # Optional. The span + start time. + "statusCode": "str", # Optional. The OpenTelemetry span + status code as a string: ``Unset``"" , ``Ok``"" , or ``Error``. + "statusMessage": "str" # Optional. The status description. + Omitted when empty. + } + ], + "traceId": "str", # Optional. The trace identifier. + "truncated": bool # Optional. True when the trace has more spans than were + returned in this response. Omitted when false. + } + # response body for status code(s): 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Union[JSON, str]] = kwargs.pop("cls", None) + + _request = build_insights_get_trace_request( + region=region, + trace_id=trace_id, + from_parameter=from_parameter, + to=to, + headers=_headers, + params=_params, ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) ) - if response.content: - deserialized = response.json() - else: - deserialized = None + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 403, 404, 404, 502]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 502: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(Union[JSON, str], deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return cast(Union[JSON, str], deserialized) # type: ignore @overload - async def create_cluster( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + async def post_spans_search( + self, + region: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Create a New Kubernetes Cluster. - - To create a new Kubernetes cluster, send a POST request to - ``/v2/kubernetes/clusters``. The request must contain at least one node pool - with at least one worker. + """Search spans. - The request may contain a maintenance window policy describing a time period - when disruptive maintenance tasks may be carried out. Omitting the policy - implies that a window will be chosen automatically. See - `here `_ - for details. + To search spans in a region, send a POST request to + ``/v2/insights/query/{region}/spans/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + The time range must not exceed 7 days. ``pagination.limit`` defaults to 100 and must be between + 1 and 1000. Results are ordered by ``startTime`` descending by default. Cursor-based pagination + is not yet supported; ``pagination.hasMore`` indicates whether additional spans matched beyond + the returned page. + :param region: The datacenter region slug for the query. Required. + :type region: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -166744,507 +167300,753 @@ async def create_cluster( # JSON input template you can fill out and use as your body input. body = { - "name": "str", # A human-readable name for a Kubernetes cluster. Required. - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean value indicating - whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in - the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes that - support partitioning. Immutable after the node pool is created. When - omitted, the GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to - identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings - specifying labels to apply to all nodes in a pool. Labels will - automatically be applied to all existing nodes and any subsequent nodes - added to the pool. Note that when a label is removed, it is not deleted - from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that - this node pool can be auto-scaled to. The value will be ``0`` if - ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that - this node pool can be auto-scaled to. The value will be ``0`` if - ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for the - node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # - Optional. A time value given in ISO8601 combined date and time - format that represents when the node was created. - "droplet_id": "str", # Optional. The ID of - the Droplet used for the worker node. - "id": "str", # Optional. A unique ID that - can be used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # - Optional. A time value given in ISO8601 combined date and time - format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type - of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags - applied to the node pool. All node pools are automatically tagged - ``k8s``"" , ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node - reacts to pods that it won't tolerate. Available effect values - are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary - string. The ``key`` and ``value`` fields of the ``taint`` object - form a key-value pair. For example, if the value of the ``key`` - field is "special" and the value of the ``value`` field is "gpu", - the key value pair would be ``special=gpu``. - "value": "str" # Optional. An arbitrary - string. The ``key`` and ``value`` fields of the ``taint`` object - form a key-value pair. For example, if the value of the ``key`` - field is "special" and the value of the ``value`` field is "gpu", - the key value pair would be ``special=gpu``. - } - ] + "timeRange": { + "from": { + "absolute": "str", # Optional. An absolute timestamp. + Accepts an RFC3339/RFC3339Nano string or a Unix timestamp (seconds, + milliseconds, microseconds, or nanoseconds) encoded as a decimal string. + "relative": "str" # Optional. A relative time. Use ``now`` + for the current time, a bare duration such as ``1h`` or ``7d`` to look + back from now, or an offset such as ``now-15m`` or ``now+30m``. Supported + units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``. + }, + "to": { + "absolute": "str", # Optional. An absolute timestamp. + Accepts an RFC3339/RFC3339Nano string or a Unix timestamp (seconds, + milliseconds, microseconds, or nanoseconds) encoded as a decimal string. + "relative": "str" # Optional. A relative time. Use ``now`` + for the current time, a bare duration such as ``1h`` or ``7d`` to look + back from now, or an offset such as ``now-15m`` or ``now+30m``. Supported + units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``. } - ], - "region": "str", # The slug identifier for the region where the Kubernetes - cluster is located. Required. - "version": "str", # The slug identifier for the version of Kubernetes used - for the cluster. If set to a minor version (e.g. "1.14"), the latest version - within it will be used (e.g. "1.14.6-do.1"); if set to "latest", the latest - published version will be used. See the ``/v2/kubernetes/options`` endpoint to - find all currently available versions. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device Metrics - Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU Device - Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver - is enabled. }, - "auto_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether the cluster will be automatically upgraded to new patch - releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to scale - up, until either a single node type is left, or the list of expanders is - exhausted. If this flag is unset, autoscaler will use its default - expander ``random``. Passing an empty list ("" *not* ``null``"" ) will - unset any previous expander customizations. Available expanders: * - ``random``"" : Randomly selects a node group to scale. * `priority`: - Selects the node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to customize how - long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting the - node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for the - overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 or - CIDR) allowed to access the control plane. + "filter": { + "type": "str", # The node kind. Required. Known values are: + "condition", "and", "or", "not", and "text_search". + "expressions": [ + ... ], - "enabled": bool # Optional. Indicates whether the control plane - firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS Cluster - Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the Kubernetes cluster - was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the control plane - is run in a highly available configuration in the cluster. Highly available - control planes incur less downtime. The property cannot be disabled. When omitted - on create, the default is version-dependent; for DOKS 1.36.0 and later, the - default is true; for earlier versions, the default is false. - "id": "str", # Optional. A unique ID that can be used to identify and - reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes master - node. This will not be set if high availability is configured on the cluster - (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A boolean - value indicating whether worker nodes in the cluster are not assigned public IP - addresses. When omitted on create, the default value is false. When enabled, a - NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window policy. - May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an - arbitrary week day. Known values are: "any", "monday", "tuesday", - "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the maintenance - window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI plugin is - enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU Device - Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA - Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI - registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA shared device - plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value indicating - if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the routing-agent - component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP addresses - for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID registered with - the identity provider. Required when ``enabled`` is ``true``. - "enabled": False, # Optional. Default value is False. Indicates - whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. Indicates - whether any non-SSO forms of authentication are disallowed. Can only be set - to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current status of - the cluster. Known values are: "running", "provisioning", "degraded", - "error", "deleted", "upgrading", and "deleting". + "field": { + "name": "str", # The field name. Well-known span fields + include ``traceId``"" , ``spanId``"" , ``parentSpanId``"" , + ``startTime``"" , ``endTime``"" , ``durationNs``"" , ``name``"" , + ``serviceName``"" , ``kind``"" , ``statusCode``"" , and + ``statusMessage``. Any other value is treated as a span or resource + attribute key. Required. + "scope": "str" # Optional. Optional attribute scope. Use + ``resource`` to match a resource attribute or ``attributes`` to match a + span attribute. Omit for well-known fields or to search both attribute + maps. Known values are: "resource" and "attributes". + }, + "operator": "str", # Optional. The comparison operator for a + ``condition`` node. Known values are: "eq", "neq", "gt", "gte", "lt", "lte", + "in", and "exists". + "query": "str", # Optional. The substring to match for a + ``text_search`` node. + "value": {} }, - "surge_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether surge upgrade is enabled/disabled for the cluster. Surge - upgrade makes cluster upgrades fast and reliable by bringing up new nodes before - destroying the outdated nodes. - "tags": [ - "str" # Optional. An array of tags to apply to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` and - ``tag:create`` scope, as well as ``tag:delete`` if existing tags are getting - removed. + "orderBy": [ + { + "field": { + "name": "str", # The field name. Well-known span + fields include ``traceId``"" , ``spanId``"" , ``parentSpanId``"" , + ``startTime``"" , ``endTime``"" , ``durationNs``"" , ``name``"" , + ``serviceName``"" , ``kind``"" , ``statusCode``"" , and + ``statusMessage``. Any other value is treated as a span or resource + attribute key. Required. + "scope": "str" # Optional. Optional attribute scope. + Use ``resource`` to match a resource attribute or ``attributes`` to + match a span attribute. Omit for well-known fields or to search both + attribute maps. Known values are: "resource" and "attributes". + }, + "direction": "str" # Optional. The sort direction. Defaults + to ``desc`` when omitted. Known values are: "asc" and "desc". + } ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the Kubernetes cluster - was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the VPC to - which the Kubernetes cluster is assigned.:code:`
`:code:`
`Requires - ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet to attach - worker nodes to. When omitted on create, the default subnet for the VPC is used. - This value cannot be changed after the cluster is created. ``vpc_uuid`` must - also be set. :code:`
`:code:`
`Requires ``vpc:read`` scope. + "pagination": { + "limit": 100 # Optional. Default value is 100. Maximum number of + spans to return. Defaults to 100 and must be between 1 and 1000. + } } - # response body for status code(s): 201 + # response body for status code(s): 200 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] - } - ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". + "data": [ + { + "attributes": { + "str": "str" # Optional. Span attributes. + }, + "durationNs": 0, # Optional. The span duration in + nanoseconds. + "endTime": "2020-02-20 00:00:00", # Optional. The span end + time. + "kind": "str", # Optional. The span kind. + "name": "str", # Optional. The span name. + "parentSpanId": "str", # Optional. The parent span + identifier. Omitted for root spans. + "region": "str", # Optional. The datacenter region slug the + span was queried from. + "resource": { + "str": "str" # Optional. Resource attributes + associated with the span. + }, + "serviceName": "str", # Optional. The name of the service + that emitted the span. + "spanId": "str", # Optional. The span identifier. + "startTime": "2020-02-20 00:00:00", # Optional. The span + start time. + "statusCode": "str", # Optional. The span status code. + "statusMessage": "str", # Optional. The span status message. + Omitted when empty. + "traceId": "str" # Optional. The trace identifier the span + belongs to. + } + ], + "pagination": { + "hasMore": bool # Optional. Whether more spans matched than were + returned in this page. Cursor-based continuation is not yet supported. + } + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def post_spans_search( + self, + region: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Search spans. + + To search spans in a region, send a POST request to + ``/v2/insights/query/{region}/spans/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + The time range must not exceed 7 days. ``pagination.limit`` defaults to 100 and must be between + 1 and 1000. Results are ordered by ``startTime`` descending by default. Cursor-based pagination + is not yet supported; ``pagination.hasMore`` indicates whether additional spans matched beyond + the returned page. + + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": [ + { + "attributes": { + "str": "str" # Optional. Span attributes. + }, + "durationNs": 0, # Optional. The span duration in + nanoseconds. + "endTime": "2020-02-20 00:00:00", # Optional. The span end + time. + "kind": "str", # Optional. The span kind. + "name": "str", # Optional. The span name. + "parentSpanId": "str", # Optional. The parent span + identifier. Omitted for root spans. + "region": "str", # Optional. The datacenter region slug the + span was queried from. + "resource": { + "str": "str" # Optional. Resource attributes + associated with the span. + }, + "serviceName": "str", # Optional. The name of the service + that emitted the span. + "spanId": "str", # Optional. The span identifier. + "startTime": "2020-02-20 00:00:00", # Optional. The span + start time. + "statusCode": "str", # Optional. The span status code. + "statusMessage": "str", # Optional. The span status message. + Omitted when empty. + "traceId": "str" # Optional. The trace identifier the span + belongs to. + } + ], + "pagination": { + "hasMore": bool # Optional. Whether more spans matched than were + returned in this page. Cursor-based continuation is not yet supported. + } + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def post_spans_search( + self, region: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Search spans. + + To search spans in a region, send a POST request to + ``/v2/insights/query/{region}/spans/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + The time range must not exceed 7 days. ``pagination.limit`` defaults to 100 and must be between + 1 and 1000. Results are ordered by ``startTime`` descending by default. Cursor-based pagination + is not yet supported; ``pagination.hasMore`` indicates whether additional spans matched beyond + the returned page. + + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "timeRange": { + "from": { + "absolute": "str", # Optional. An absolute timestamp. + Accepts an RFC3339/RFC3339Nano string or a Unix timestamp (seconds, + milliseconds, microseconds, or nanoseconds) encoded as a decimal string. + "relative": "str" # Optional. A relative time. Use ``now`` + for the current time, a bare duration such as ``1h`` or ``7d`` to look + back from now, or an offset such as ``now-15m`` or ``now+30m``. Supported + units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``. }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. - "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "to": { + "absolute": "str", # Optional. An absolute timestamp. + Accepts an RFC3339/RFC3339Nano string or a Unix timestamp (seconds, + milliseconds, microseconds, or nanoseconds) encoded as a decimal string. + "relative": "str" # Optional. A relative time. Use ``now`` + for the current time, a bare duration such as ``1h`` or ``7d`` to look + back from now, or an offset such as ``now-15m`` or ``now+30m``. Supported + units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``. + } + }, + "filter": { + "type": "str", # The node kind. Required. Known values are: + "condition", "and", "or", "not", and "text_search". + "expressions": [ + ... ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "field": { + "name": "str", # The field name. Well-known span fields + include ``traceId``"" , ``spanId``"" , ``parentSpanId``"" , + ``startTime``"" , ``endTime``"" , ``durationNs``"" , ``name``"" , + ``serviceName``"" , ``kind``"" , ``statusCode``"" , and + ``statusMessage``. Any other value is treated as a span or resource + attribute key. Required. + "scope": "str" # Optional. Optional attribute scope. Use + ``resource`` to match a resource attribute or ``attributes`` to match a + span attribute. Omit for well-known fields or to search both attribute + maps. Known values are: "resource" and "attributes". + }, + "operator": "str", # Optional. The comparison operator for a + ``condition`` node. Known values are: "eq", "neq", "gt", "gte", "lt", "lte", + "in", and "exists". + "query": "str", # Optional. The substring to match for a + ``text_search`` node. + "value": {} + }, + "orderBy": [ + { + "field": { + "name": "str", # The field name. Well-known span + fields include ``traceId``"" , ``spanId``"" , ``parentSpanId``"" , + ``startTime``"" , ``endTime``"" , ``durationNs``"" , ``name``"" , + ``serviceName``"" , ``kind``"" , ``statusCode``"" , and + ``statusMessage``. Any other value is treated as a span or resource + attribute key. Required. + "scope": "str" # Optional. Optional attribute scope. + Use ``resource`` to match a resource attribute or ``attributes`` to + match a span attribute. Omit for well-known fields or to search both + attribute maps. Known values are: "resource" and "attributes". + }, + "direction": "str" # Optional. The sort direction. Defaults + to ``desc`` when omitted. Known values are: "asc" and "desc". + } + ], + "pagination": { + "limit": 100 # Optional. Default value is 100. Maximum number of + spans to return. Defaults to 100 and must be between 1 and 1000. + } + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "attributes": { + "str": "str" # Optional. Span attributes. + }, + "durationNs": 0, # Optional. The span duration in + nanoseconds. + "endTime": "2020-02-20 00:00:00", # Optional. The span end + time. + "kind": "str", # Optional. The span kind. + "name": "str", # Optional. The span name. + "parentSpanId": "str", # Optional. The parent span + identifier. Omitted for root spans. + "region": "str", # Optional. The datacenter region slug the + span was queried from. + "resource": { + "str": "str" # Optional. Resource attributes + associated with the span. + }, + "serviceName": "str", # Optional. The name of the service + that emitted the span. + "spanId": "str", # Optional. The span identifier. + "startTime": "2020-02-20 00:00:00", # Optional. The span + start time. + "statusCode": "str", # Optional. The span status code. + "statusMessage": "str", # Optional. The span status message. + Omitted when empty. + "traceId": "str" # Optional. The trace identifier the span + belongs to. + } + ], + "pagination": { + "hasMore": bool # Optional. Whether more spans matched than were + returned in this page. Cursor-based continuation is not yet supported. + } + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_insights_post_spans_search_request( + region=region, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 403, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + +class SignalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`signals` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace_async + async def list_consents( + self, *, source: Optional[str] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List All Consent Records. + + To list all signals consent records for your team, send a GET request to + ``/v1/consent``. Each record indicates whether signals collection is enabled + for a source: per-environment records (\\ ``source: agent``\\ ) for Harness Runtime, and + the team-level record (\\ ``source: inference``\\ ) for Serverless Inference chat + completions. + + Pass ``?source=agent`` or ``?source=inference`` to return only that source's + records. When filtered, the response also echoes the ``source``. + + :keyword source: Filter consent records by source. ``agent`` returns per-environment records + (Harness Runtime); ``inference`` returns the team-level record for Serverless Inference chat + completions. When omitted, records for all sources are returned. Known values are: "agent" and + "inference". Default value is None. + :paramtype source: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "consents": [ + { + "agent_id": "str", # The unique identifier of the + environment. For Harness Runtime, this is the Environment Config ID. + Empty for team-level records ("" ``source: inference``"" ), which are not + tied to an environment. Required. + "enabled": bool, # Whether signals collection is enabled for + this source. Required. + "id": 0, # The unique numeric identifier for the consent + record. Required. + "source": "str", # The source this consent applies to. + ``agent`` is per-environment consent for Harness Runtime; ``inference`` + is team-level consent for Serverless Inference chat completions. + Required. Known values are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. + Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in + ISO8601 combined date and time format. Required. + } + ], + "source": "str" # Optional. Echoes the ``source`` filter when the request + was filtered by source. Omitted when the list was not filtered. Known values are: + "agent" and "inference". + } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_consents_request( + source=source, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def update_team_consent( + self, + body: JSON, + *, + source: str, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Team-Level Consent. + + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. + + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. + + :param body: Required. + :type body: JSON + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this source. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. } } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ @overload - async def create_cluster( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + async def update_team_consent( + self, + body: IO[bytes], + *, + source: str, + content_type: str = "application/json", + **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Create a New Kubernetes Cluster. + """Update Team-Level Consent. - To create a new Kubernetes cluster, send a POST request to - ``/v2/kubernetes/clusters``. The request must contain at least one node pool - with at least one worker. + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. - The request may contain a maintenance window policy describing a time period - when disruptive maintenance tasks may be carried out. Omitting the policy - implies that a window will be chosen automatically. See - `here `_ - for details. + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. :param body: Required. :type body: IO[bytes] + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -167255,274 +168057,6965 @@ async def create_cluster( Example: .. code-block:: python - # response body for status code(s): 201 + # response body for status code(s): 200 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. Required. - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] - } - ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. - "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. - ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def update_team_consent( + self, body: Union[JSON, IO[bytes]], *, source: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Team-Level Consent. + + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. + + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this source. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. } } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_update_team_consent_request( + source=source, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_consent(self, agent_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Consent for an Environment. + + To retrieve the consent record for a specific environment, send a GET + request to ``/v1/consent/{agent_id}``. The response includes an ``enabled`` + field indicating whether signals collection is on for this environment. + + This endpoint only serves per-environment (\\ ``source: agent``\\ ) records. Team-level + inference consent is read from ``GET /v1/consent?source=inference``. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "agent_id": "str", # The unique identifier of the environment. For Harness + Runtime, this is the Environment Config ID. Required. + "enabled": bool, # Whether signals collection is enabled for this + environment. Required. + "source": "str", # The source this consent applies to. Always ``agent`` for + per-environment records returned by this endpoint. Required. "agent" + "team_id": 0, # The team ID that owns this consent record. Required. + "id": 0, # Optional. The unique numeric identifier for the consent record. + "updated_at": "2020-02-20 00:00:00" # Optional. A time value given in + ISO8601 combined date and time format. + } + # response body for status code(s): 400, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_consent_request( + agent_id=agent_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def update_consent( + self, + agent_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this environment. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def update_consent( + self, + agent_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def update_consent( + self, agent_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this environment. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_update_consent_request( + agent_id=agent_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def list_agent_sessions( + self, + agent_id: str, + *, + limit: int = 20, + after: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + signal_type: Optional[str] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Sessions for an Environment. + + To list signals sessions for a specific environment, send a GET request to + ``/v1/signals/agents/{agent_id}/sessions``. Results are paginated using cursor-based + pagination with ``limit`` and ``after`` parameters. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :keyword limit: Maximum number of items to return per page. Default value is 20. + :paramtype limit: int + :keyword after: An opaque cursor string returned from a previous page. Pass this value to + retrieve the next page of results. Default value is None. + :paramtype after: str + :keyword start_time: Filter results to those occurring at or after this timestamp (RFC 3339). + Default value is None. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Filter results to those occurring at or before this timestamp (RFC 3339). + Default value is None. + :paramtype end_time: ~datetime.datetime + :keyword signal_type: Filter results by signal type. Use the export options endpoint to list + available signal types. Default value is None. + :paramtype signal_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "edges": [ + { + "cursor": "str", # Optional. An opaque cursor for + pagination. + "node": { + "session_id": "str", # The unique identifier for the + session. Required. + "duration_seconds": 0.0, # Optional. The duration of + the session in seconds. + "signal_count": 0, # Optional. The number of signals + detected in this session. + "started_at": "2020-02-20 00:00:00", # Optional. + When the session started. + "total_turns": 0 # Optional. The total number of + conversation turns in this session. + } + } + ], + "page_info": { + "has_next_page": bool # Optional. Whether there are more results + after this page. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_agent_sessions_request( + agent_id=agent_id, + limit=limit, + after=after, + start_time=start_time, + end_time=end_time, + signal_type=signal_type, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def list_session_dialogues( + self, + session_id: str, + *, + limit: int = 20, + after: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + signal_type: Optional[str] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Dialogues for a Session. + + To list the dialogue turns within a specific session, send a GET request to + ``/v1/signals/sessions/{session_id}/dialogues``. Each dialogue represents a + single turn of conversation between a user and the environment, along with + any signals detected. Results are paginated using cursor-based pagination. + + :param session_id: A unique identifier for a signals session. Required. + :type session_id: str + :keyword limit: Maximum number of items to return per page. Default value is 20. + :paramtype limit: int + :keyword after: An opaque cursor string returned from a previous page. Pass this value to + retrieve the next page of results. Default value is None. + :paramtype after: str + :keyword start_time: Filter results to those occurring at or after this timestamp (RFC 3339). + Default value is None. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Filter results to those occurring at or before this timestamp (RFC 3339). + Default value is None. + :paramtype end_time: ~datetime.datetime + :keyword signal_type: Filter results by signal type. Use the export options endpoint to list + available signal types. Default value is None. + :paramtype signal_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "edges": [ + { + "cursor": "str", # Optional. An opaque cursor for + pagination. + "node": { + "id": "str", # The unique identifier for the + dialogue. Required. + "run_status": "str", # Optional. The execution + status of this dialogue turn. + "sequence": 0, # Optional. The sequence number of + this dialogue within the session. + "signals": [ + "str" # Optional. A list of signal types + detected in this dialogue. + ], + "user_message": "str" # Optional. The user's message + in this dialogue turn. + } + } + ], + "page_info": { + "has_next_page": bool # Optional. Whether there are more results + after this page. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_session_dialogues_request( + session_id=session_id, + limit=limit, + after=after, + start_time=start_time, + end_time=end_time, + signal_type=signal_type, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def list_exports( + self, *, limit: int = 20, after: Optional[str] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Export Jobs. + + To list signals export jobs for your team, send a GET request to + ``/v1/signals/exports``. Results are paginated using cursor-based pagination + with ``limit`` and ``after`` parameters. + + :keyword limit: Maximum number of items to return per page. Default value is 20. + :paramtype limit: int + :keyword after: An opaque cursor string returned from a previous page. Pass this value to + retrieve the next page of results. Default value is None. + :paramtype after: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "edges": [ + { + "cursor": "str", # Optional. An opaque cursor for + pagination. + "node": { + "agent_id": "str", # The environment whose data is + being exported. For Harness Runtime, this is the Environment Config + ID. Not meaningful for ``inference`` exports; use ``type`` to + distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export + was created. Required. + "export_id": "str", # The unique identifier for the + export job. Required. + "status": "str", # The current status of the export + job. Required. Known values are: "pending", "processing", "complete", + and "failed". + "completed_at": 0, # Optional. Unix timestamp when + the export completed, or null if still in progress. + "error_message": "str", # Optional. Error message if + the export failed, or null on success. + "expires_at": 0, # Optional. Unix timestamp when the + export download link expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session + IDs included in the export. + ], + "signal_type": [ + "str" # Optional. Signal types + included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. + ``agent`` covers one Harness Runtime environment; ``inference`` + covers the team's Serverless Inference Signals conversations. Known + values are: "agent" and "inference". + } + } + ], + "page_info": { + "has_next_page": bool # Optional. Whether there are more results + after this page. + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_exports_request( + limit=limit, + after=after, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def create_export( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create an Export Job. + + To create a new signals data export, send a POST request to + ``/v1/signals/exports``. To export one Harness Runtime environment, include its + ``agent_id`` (\\ ``type`` defaults to ``agent``\\ ). To export the team's Serverless + Inference Signals conversations, set ``type`` to ``inference`` and omit + ``agent_id``. You may optionally filter the export by ``signal_type``\\ , + ``session_ids``\\ , ``start_time``\\ , and ``end_time``. Use the export options endpoint + to discover available signal types. + + The export job runs asynchronously. Poll the get export endpoint to check + its status. When complete, use the download endpoint to retrieve a + pre-signed URL. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "agent_id": "str", # Optional. The environment whose data should be + exported. For Harness Runtime, this is the Environment Config ID. Required when + ``type`` is ``agent``"" ; must be omitted when ``type`` is ``inference``. + "end_time": "2020-02-20 00:00:00", # Optional. Include only sessions that + started at or before this timestamp. + "session_ids": [ + "str" # Optional. Optional list of specific session IDs to include + in the export. + ], + "signal_type": [ + "str" # Optional. Filter the export to only include the specified + signal types. Use the export options endpoint to list available values. + ], + "start_time": "2020-02-20 00:00:00", # Optional. Include only sessions that + started at or after this timestamp. + "type": "str" # Optional. The scope of the export. ``agent`` exports Signals + conversations for one Harness Runtime environment and requires ``agent_id``. + ``inference`` exports Serverless Inference Signals conversations for the whole + team (team-wide; omit ``agent_id``"" ). Defaults to ``agent`` when ``agent_id`` + is provided and to ``inference`` when it is omitted. Known values are: "agent" + and "inference". + } + + # response body for status code(s): 201 + response == { + "agent_id": "str", # The environment whose data is being exported. For + Harness Runtime, this is the Environment Config ID. Not meaningful for + ``inference`` exports; use ``type`` to distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export was created. Required. + "export_id": "str", # The unique identifier for the export job. Required. + "status": "str", # The current status of the export job. Required. Known + values are: "pending", "processing", "complete", and "failed". + "completed_at": 0, # Optional. Unix timestamp when the export completed, or + null if still in progress. + "error_message": "str", # Optional. Error message if the export failed, or + null on success. + "expires_at": 0, # Optional. Unix timestamp when the export download link + expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session IDs included in the + export. + ], + "signal_type": [ + "str" # Optional. Signal types included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. ``agent`` covers one + Harness Runtime environment; ``inference`` covers the team's Serverless Inference + Signals conversations. Known values are: "agent" and "inference". + } + # response body for status code(s): 400, 422 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def create_export( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create an Export Job. + + To create a new signals data export, send a POST request to + ``/v1/signals/exports``. To export one Harness Runtime environment, include its + ``agent_id`` (\\ ``type`` defaults to ``agent``\\ ). To export the team's Serverless + Inference Signals conversations, set ``type`` to ``inference`` and omit + ``agent_id``. You may optionally filter the export by ``signal_type``\\ , + ``session_ids``\\ , ``start_time``\\ , and ``end_time``. Use the export options endpoint + to discover available signal types. + + The export job runs asynchronously. Poll the get export endpoint to check + its status. When complete, use the download endpoint to retrieve a + pre-signed URL. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "agent_id": "str", # The environment whose data is being exported. For + Harness Runtime, this is the Environment Config ID. Not meaningful for + ``inference`` exports; use ``type`` to distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export was created. Required. + "export_id": "str", # The unique identifier for the export job. Required. + "status": "str", # The current status of the export job. Required. Known + values are: "pending", "processing", "complete", and "failed". + "completed_at": 0, # Optional. Unix timestamp when the export completed, or + null if still in progress. + "error_message": "str", # Optional. Error message if the export failed, or + null on success. + "expires_at": 0, # Optional. Unix timestamp when the export download link + expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session IDs included in the + export. + ], + "signal_type": [ + "str" # Optional. Signal types included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. ``agent`` covers one + Harness Runtime environment; ``inference`` covers the team's Serverless Inference + Signals conversations. Known values are: "agent" and "inference". + } + # response body for status code(s): 400, 422 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def create_export(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create an Export Job. + + To create a new signals data export, send a POST request to + ``/v1/signals/exports``. To export one Harness Runtime environment, include its + ``agent_id`` (\\ ``type`` defaults to ``agent``\\ ). To export the team's Serverless + Inference Signals conversations, set ``type`` to ``inference`` and omit + ``agent_id``. You may optionally filter the export by ``signal_type``\\ , + ``session_ids``\\ , ``start_time``\\ , and ``end_time``. Use the export options endpoint + to discover available signal types. + + The export job runs asynchronously. Poll the get export endpoint to check + its status. When complete, use the download endpoint to retrieve a + pre-signed URL. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "agent_id": "str", # Optional. The environment whose data should be + exported. For Harness Runtime, this is the Environment Config ID. Required when + ``type`` is ``agent``"" ; must be omitted when ``type`` is ``inference``. + "end_time": "2020-02-20 00:00:00", # Optional. Include only sessions that + started at or before this timestamp. + "session_ids": [ + "str" # Optional. Optional list of specific session IDs to include + in the export. + ], + "signal_type": [ + "str" # Optional. Filter the export to only include the specified + signal types. Use the export options endpoint to list available values. + ], + "start_time": "2020-02-20 00:00:00", # Optional. Include only sessions that + started at or after this timestamp. + "type": "str" # Optional. The scope of the export. ``agent`` exports Signals + conversations for one Harness Runtime environment and requires ``agent_id``. + ``inference`` exports Serverless Inference Signals conversations for the whole + team (team-wide; omit ``agent_id``"" ). Defaults to ``agent`` when ``agent_id`` + is provided and to ``inference`` when it is omitted. Known values are: "agent" + and "inference". + } + + # response body for status code(s): 201 + response == { + "agent_id": "str", # The environment whose data is being exported. For + Harness Runtime, this is the Environment Config ID. Not meaningful for + ``inference`` exports; use ``type`` to distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export was created. Required. + "export_id": "str", # The unique identifier for the export job. Required. + "status": "str", # The current status of the export job. Required. Known + values are: "pending", "processing", "complete", and "failed". + "completed_at": 0, # Optional. Unix timestamp when the export completed, or + null if still in progress. + "error_message": "str", # Optional. Error message if the export failed, or + null on success. + "expires_at": 0, # Optional. Unix timestamp when the export download link + expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session IDs included in the + export. + ], + "signal_type": [ + "str" # Optional. Signal types included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. ``agent`` covers one + Harness Runtime environment; ``inference`` covers the team's Serverless Inference + Signals conversations. Known values are: "agent" and "inference". + } + # response body for status code(s): 400, 422 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_create_export_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201, 400, 422]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 422: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_export_options(self, **kwargs: Any) -> JSON: + """Get Export Options. + + To retrieve the available filter options for creating an export, send a GET + request to ``/v1/signals/exports/options``. The response lists valid signal + types that can be used in the ``signal_type`` filter when creating an export. + + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "filters": { + "signal_type": [ + "str" # The list of valid signal type values that can be + used when creating an export. Required. + ] + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_export_options_request( + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_export(self, export_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Export Job. + + To retrieve the status and details of a signals export job, send a GET + request to ``/v1/signals/exports/{export_id}``. + + :param export_id: A unique identifier for an export job. Required. + :type export_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "agent_id": "str", # The environment whose data is being exported. For + Harness Runtime, this is the Environment Config ID. Not meaningful for + ``inference`` exports; use ``type`` to distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export was created. Required. + "export_id": "str", # The unique identifier for the export job. Required. + "status": "str", # The current status of the export job. Required. Known + values are: "pending", "processing", "complete", and "failed". + "completed_at": 0, # Optional. Unix timestamp when the export completed, or + null if still in progress. + "error_message": "str", # Optional. Error message if the export failed, or + null on success. + "expires_at": 0, # Optional. Unix timestamp when the export download link + expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session IDs included in the + export. + ], + "signal_type": [ + "str" # Optional. Signal types included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. ``agent`` covers one + Harness Runtime environment; ``inference`` covers the team's Serverless Inference + Signals conversations. Known values are: "agent" and "inference". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_export_request( + export_id=export_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_export_download(self, export_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Get Export Download URL. + + To retrieve a pre-signed download URL for a completed export, send a GET + request to ``/v1/signals/exports/{export_id}/download``. The export must have + a ``complete`` status. The URL is temporary and will expire. + + :param export_id: A unique identifier for an export job. Required. + :type export_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "download_url": "str", # A temporary pre-signed URL to download the export + archive. Required. + "expires_at": 0 # Unix timestamp when the download URL expires. The URL is + valid for 15 minutes. Required. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_export_download_request( + export_id=export_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def list_deletions( + self, *, limit: int = 20, after: Optional[str] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Data Deletion Jobs. + + To list signals data deletion jobs for your team, newest first, send a GET + request to ``/v1/signals/deletions``. Results are paginated using + cursor-based pagination with ``limit`` and ``after`` parameters. + + :keyword limit: Maximum number of items to return per page. Default value is 20. + :paramtype limit: int + :keyword after: An opaque cursor string returned from a previous page. Pass this value to + retrieve the next page of results. Default value is None. + :paramtype after: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "edges": [ + { + "cursor": "str", # Optional. An opaque cursor for + pagination. + "node": { + "created_at": 0, # Unix timestamp when the deletion + job was created. Required. + "deletion_id": "str", # The unique identifier for + the deletion job (ULID). Required. + "status": "str", # The current status of the + deletion job. Required. Known values are: "queued", "running", + "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. + Required. + "type": "str", # The scope of the deletion. + ``agent`` deletes Signals conversations for one Harness Runtime + environment. ``inference`` deletes Serverless Inference Signals + conversations for the whole team. Required. Known values are: "agent" + and "inference". + "agent_id": "str", # Optional. The Harness Runtime + Environment Config ID (agent UUID) whose conversations are being + deleted. Only present for ``agent`` deletions. + "completed_at": 0, # Optional. Unix timestamp when + the deletion finished, or null if still in progress. + "error_message": "str", # Optional. Error message if + the deletion failed, or null otherwise. + "started_at": 0 # Optional. Unix timestamp when + processing started, or null if still queued. + } + } + ], + "page_info": { + "end_cursor": "str", # Optional. Cursor of the last item. Pass as + ``after`` to fetch the next page. Present only when there are more results. + "has_next_page": bool # Optional. Whether there are more results + after this page. + } + } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_deletions_request( + limit=limit, + after=after, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def create_deletion( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Data Deletion Job. + + To permanently delete Signals conversation data, send a POST request to + ``/v1/signals/deletions``. Deletion cannot be undone. + + Two deletion types are supported: + + + * ``agent`` — deletes Signals conversations for one Harness Runtime environment and + turns off collection for that environment. Requires ``agent_id``\\ , which is the + environment's Environment Config ID (the environment's ``agent_id``\\ ). On create, matching + conversations are hidden from Signals reads immediately. Wait until the + job is ``complete`` before enabling Signals for the environment again. + * ``inference`` — deletes Serverless Inference Signals conversations for your + whole team (team-wide; not limited to one endpoint or model) that were + collected at or before the deletion request, and turns off team inference + collection (\\ ``source=inference``\\ ). Do not send ``agent_id``. On create, + matching conversations are hidden from Signals reads immediately. + + The job runs asynchronously; poll the get endpoint until ``status`` is + ``complete`` or ``failed``. DigitalOcean may retry transient processing errors + while a job is still active. If a job ends as ``failed``\\ , matching + conversations stay hidden and collection stays off; send the same create + request again to retry. Earlier export files are not deleted and remain + available until they expire. + + Note: Deletion removes Signals conversation data for the requested scope. + Aggregated Insights or metrics charts may still show historical summary + datapoints after deletion. Those summaries are not the same as recoverable + conversation content. + + The endpoint is idempotent: if a queued or running job already exists for + the same target, it is returned with ``200 OK``. A new job returns + ``202 Accepted``. Each team can have a limited number of active jobs; + requests beyond that limit return ``429 Too Many Requests``. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "team_id": 0, # The team whose data should be deleted. Must match the + authenticated team. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment and requires ``agent_id``. + ``inference`` deletes Serverless Inference Signals conversations for the whole + team (team-wide; omit ``agent_id``"" ). Required. Known values are: "agent" and + "inference". + "agent_id": "str" # Optional. The Harness Runtime Environment Config ID of + the environment whose conversations should be deleted. This is the environment's + ``agent_id``. Required when ``type`` is ``agent``"" ; must be omitted when + ``type`` is ``inference``. + } + + # response body for status code(s): 200, 202 + response == { + "created_at": 0, # Unix timestamp when the deletion job was created. + Required. + "deletion_id": "str", # The unique identifier for the deletion job (ULID). + Required. + "status": "str", # The current status of the deletion job. Required. Known + values are: "queued", "running", "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment. ``inference`` deletes + Serverless Inference Signals conversations for the whole team. Required. Known + values are: "agent" and "inference". + "agent_id": "str", # Optional. The Harness Runtime Environment Config ID + (agent UUID) whose conversations are being deleted. Only present for ``agent`` + deletions. + "completed_at": 0, # Optional. Unix timestamp when the deletion finished, or + null if still in progress. + "error_message": "str", # Optional. Error message if the deletion failed, or + null otherwise. + "started_at": 0 # Optional. Unix timestamp when processing started, or null + if still queued. + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def create_deletion( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Data Deletion Job. + + To permanently delete Signals conversation data, send a POST request to + ``/v1/signals/deletions``. Deletion cannot be undone. + + Two deletion types are supported: + + + * ``agent`` — deletes Signals conversations for one Harness Runtime environment and + turns off collection for that environment. Requires ``agent_id``\\ , which is the + environment's Environment Config ID (the environment's ``agent_id``\\ ). On create, matching + conversations are hidden from Signals reads immediately. Wait until the + job is ``complete`` before enabling Signals for the environment again. + * ``inference`` — deletes Serverless Inference Signals conversations for your + whole team (team-wide; not limited to one endpoint or model) that were + collected at or before the deletion request, and turns off team inference + collection (\\ ``source=inference``\\ ). Do not send ``agent_id``. On create, + matching conversations are hidden from Signals reads immediately. + + The job runs asynchronously; poll the get endpoint until ``status`` is + ``complete`` or ``failed``. DigitalOcean may retry transient processing errors + while a job is still active. If a job ends as ``failed``\\ , matching + conversations stay hidden and collection stays off; send the same create + request again to retry. Earlier export files are not deleted and remain + available until they expire. + + Note: Deletion removes Signals conversation data for the requested scope. + Aggregated Insights or metrics charts may still show historical summary + datapoints after deletion. Those summaries are not the same as recoverable + conversation content. + + The endpoint is idempotent: if a queued or running job already exists for + the same target, it is returned with ``200 OK``. A new job returns + ``202 Accepted``. Each team can have a limited number of active jobs; + requests beyond that limit return ``429 Too Many Requests``. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "created_at": 0, # Unix timestamp when the deletion job was created. + Required. + "deletion_id": "str", # The unique identifier for the deletion job (ULID). + Required. + "status": "str", # The current status of the deletion job. Required. Known + values are: "queued", "running", "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment. ``inference`` deletes + Serverless Inference Signals conversations for the whole team. Required. Known + values are: "agent" and "inference". + "agent_id": "str", # Optional. The Harness Runtime Environment Config ID + (agent UUID) whose conversations are being deleted. Only present for ``agent`` + deletions. + "completed_at": 0, # Optional. Unix timestamp when the deletion finished, or + null if still in progress. + "error_message": "str", # Optional. Error message if the deletion failed, or + null otherwise. + "started_at": 0 # Optional. Unix timestamp when processing started, or null + if still queued. + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def create_deletion( + self, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Data Deletion Job. + + To permanently delete Signals conversation data, send a POST request to + ``/v1/signals/deletions``. Deletion cannot be undone. + + Two deletion types are supported: + + + * ``agent`` — deletes Signals conversations for one Harness Runtime environment and + turns off collection for that environment. Requires ``agent_id``\\ , which is the + environment's Environment Config ID (the environment's ``agent_id``\\ ). On create, matching + conversations are hidden from Signals reads immediately. Wait until the + job is ``complete`` before enabling Signals for the environment again. + * ``inference`` — deletes Serverless Inference Signals conversations for your + whole team (team-wide; not limited to one endpoint or model) that were + collected at or before the deletion request, and turns off team inference + collection (\\ ``source=inference``\\ ). Do not send ``agent_id``. On create, + matching conversations are hidden from Signals reads immediately. + + The job runs asynchronously; poll the get endpoint until ``status`` is + ``complete`` or ``failed``. DigitalOcean may retry transient processing errors + while a job is still active. If a job ends as ``failed``\\ , matching + conversations stay hidden and collection stays off; send the same create + request again to retry. Earlier export files are not deleted and remain + available until they expire. + + Note: Deletion removes Signals conversation data for the requested scope. + Aggregated Insights or metrics charts may still show historical summary + datapoints after deletion. Those summaries are not the same as recoverable + conversation content. + + The endpoint is idempotent: if a queued or running job already exists for + the same target, it is returned with ``200 OK``. A new job returns + ``202 Accepted``. Each team can have a limited number of active jobs; + requests beyond that limit return ``429 Too Many Requests``. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "team_id": 0, # The team whose data should be deleted. Must match the + authenticated team. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment and requires ``agent_id``. + ``inference`` deletes Serverless Inference Signals conversations for the whole + team (team-wide; omit ``agent_id``"" ). Required. Known values are: "agent" and + "inference". + "agent_id": "str" # Optional. The Harness Runtime Environment Config ID of + the environment whose conversations should be deleted. This is the environment's + ``agent_id``. Required when ``type`` is ``agent``"" ; must be omitted when + ``type`` is ``inference``. + } + + # response body for status code(s): 200, 202 + response == { + "created_at": 0, # Unix timestamp when the deletion job was created. + Required. + "deletion_id": "str", # The unique identifier for the deletion job (ULID). + Required. + "status": "str", # The current status of the deletion job. Required. Known + values are: "queued", "running", "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment. ``inference`` deletes + Serverless Inference Signals conversations for the whole team. Required. Known + values are: "agent" and "inference". + "agent_id": "str", # Optional. The Harness Runtime Environment Config ID + (agent UUID) whose conversations are being deleted. Only present for ``agent`` + deletions. + "completed_at": 0, # Optional. Unix timestamp when the deletion finished, or + null if still in progress. + "error_message": "str", # Optional. Error message if the deletion failed, or + null otherwise. + "started_at": 0 # Optional. Unix timestamp when processing started, or null + if still queued. + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_create_deletion_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 400, 403, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 202: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_deletion(self, deletion_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve a Data Deletion Job. + + To retrieve the status of a signals data deletion job, send a GET request + to ``/v1/signals/deletions/{deletion_id}``. + + :param deletion_id: A unique identifier for a data deletion job. Required. + :type deletion_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "created_at": 0, # Unix timestamp when the deletion job was created. + Required. + "deletion_id": "str", # The unique identifier for the deletion job (ULID). + Required. + "status": "str", # The current status of the deletion job. Required. Known + values are: "queued", "running", "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment. ``inference`` deletes + Serverless Inference Signals conversations for the whole team. Required. Known + values are: "agent" and "inference". + "agent_id": "str", # Optional. The Harness Runtime Environment Config ID + (agent UUID) whose conversations are being deleted. Only present for ``agent`` + deletions. + "completed_at": 0, # Optional. Unix timestamp when the deletion finished, or + null if still in progress. + "error_message": "str", # Optional. Error message if the deletion failed, or + null otherwise. + "started_at": 0 # Optional. Unix timestamp when processing started, or null + if still queued. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_deletion_request( + deletion_id=deletion_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + +class KubernetesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`kubernetes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace_async + async def list_clusters( + self, *, per_page: int = 20, page: int = 1, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List All Kubernetes Clusters. + + To list all of the Kubernetes clusters on your account, send a GET request + to ``/v2/kubernetes/clusters``. + + :keyword per_page: Number of items returned per page. Default value is 20. + :paramtype per_page: int + :keyword page: Which 'page' of paginated results to return. Default value is 1. + :paramtype page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "meta": { + "total": 0 # Optional. Number of objects returned by the request. + }, + "kubernetes_clusters": [ + { + "name": "str", # A human-readable name for a Kubernetes + cluster. Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean + value indicating whether auto-scaling is enabled for this node + pool. + "count": 0, # Optional. The number of + Droplet instances in the node pool. + "gpu_partition_mode": "str", # Optional. The + AMD GPU partition mode for this node pool. Only applicable to AMD + GPU sizes that support partitioning. Immutable after the node + pool is created. When omitted, the GPUs in the pool are left + unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" + and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that + can be used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of + key/value mappings specifying labels to apply to all nodes in a + pool. Labels will automatically be applied to all existing nodes + and any subsequent nodes added to the pool. Note that when a + label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum + number of nodes that this node pool can be auto-scaled to. The + value will be ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum + number of nodes that this node pool can be auto-scaled to. The + value will be ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable + name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 + 00:00:00", # Optional. A time value given in ISO8601 + combined date and time format that represents when the + node was created. + "droplet_id": "str", # + Optional. The ID of the Droplet used for the worker node. + "id": "str", # Optional. A + unique ID that can be used to identify and reference the + node. + "name": "str", # Optional. + An automatically generated, human-readable name for the + node. + "status": { + "state": "str" # + Optional. A string indicating the current status of + the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 + 00:00:00" # Optional. A time value given in ISO8601 + combined date and time format that represents when the + node was last updated. + } + ], + "size": "str", # Optional. The slug + identifier for the type of Droplet used as workers in the node + pool. + "tags": [ + "str" # Optional. An array + containing the tags applied to the node pool. All node pools + are automatically tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. + How the node reacts to pods that it won't tolerate. + Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values + are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if + the value of the ``key`` field is "special" and the value + of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. + An arbitrary string. The ``key`` and ``value`` fields of + the ``taint`` object form a key-value pair. For example, + if the value of the ``key`` field is "special" and the + value of the ``value`` field is "gpu", the key value pair + would be ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where + the Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), + the latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available + versions. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the + AMD Device Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the + AMD GPU Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the + AMD GPU DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether the cluster will be automatically + upgraded to new patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used + by cluster-autoscaler. The autoscaler will apply each expander + from the provided list to narrow down the selection of node types + created to scale up, until either a single node type is left, or + the list of expanders is exhausted. If this flag is unset, + autoscaler will use its default expander ``random``. Passing an + empty list ("" *not* ``null``"" ) will unset any previous + expander customizations. Available expanders: * ``random``"" : + Randomly selects a node group to scale. * `priority`: Selects the + node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in + the least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used + to customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. + Used to customize when cluster autoscaler scales down non-empty nodes + by setting the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP + addresses for the overlay network of the Kubernetes cluster in CIDR + notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public + addresses (IPv4 or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the + control plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the + CoreDNS Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the Kubernetes cluster was created. + "endpoint": "str", # Optional. The base URL of the API + server on the Kubernetes master node. + "ha": False, # Optional. Default value is False. A boolean + value indicating whether the control plane is run in a highly available + configuration in the cluster. Highly available control planes incur less + downtime. The property cannot be disabled. When omitted on create, the + default is version-dependent; for DOKS 1.36.0 and later, the default is + true; for earlier versions, the default is false. + "id": "str", # Optional. A unique ID that can be used to + identify and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the + Kubernetes master node. This will not be set if high availability is + configured on the cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is + False. A boolean value indicating whether worker nodes in the cluster are + not assigned public IP addresses. When omitted on create, the default + value is false. When enabled, a NAT gateway must exist in the VPC where + the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance + window policy. May be one of ``monday`` through ``sunday``"" , or + ``any`` to indicate an arbitrary week day. Known values are: "any", + "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", + and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in + UTC of the maintenance window policy in 24-hour clock format / HH:MM + notation (e.g., ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the + NFS CSI plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the + Nvidia GPU Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the + NVIDIA GPU DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the + RDMA shared device plugin is enabled. + }, + "registries": [ + "str" # Optional. An array of integrated DOCR + registries. + ], + "registry_enabled": bool, # Optional. A read-only boolean + value indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable + IP addresses for services running in the Kubernetes cluster in CIDR + notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is + False. Indicates whether SSO authentication is enabled for the + cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL + for the identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is + False. Indicates whether any non-SSO forms of authentication are + disallowed. Can only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message + providing additional information about the current cluster state. + "state": "str" # Optional. A string indicating the + current status of the cluster. Known values are: "running", + "provisioning", "degraded", "error", "deleted", "upgrading", and + "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. + A boolean value indicating whether surge upgrade is enabled/disabled for + the cluster. Surge upgrade makes cluster upgrades fast and reliable by + bringing up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags applied to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the Kubernetes cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID + of the VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC + subnet worker nodes are attached to. When unset, the default subnet for + the VPC is used.:code:`
`:code:`
`Requires ``vpc:read`` scope. + } + ], + "links": { + "pages": {} + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_list_clusters_request( + per_page=per_page, + page=page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def create_cluster( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Kubernetes Cluster. + + To create a new Kubernetes cluster, send a POST request to + ``/v2/kubernetes/clusters``. The request must contain at least one node pool + with at least one worker. + + The request may contain a maintenance window policy describing a time period + when disruptive maintenance tasks may be carried out. Omitting the policy + implies that a window will be chosen automatically. See + `here `_ + for details. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value indicating + whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in + the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes that + support partitioning. Immutable after the node pool is created. When + omitted, the GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to + identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings + specifying labels to apply to all nodes in a pool. Labels will + automatically be applied to all existing nodes and any subsequent nodes + added to the pool. Note that when a label is removed, it is not deleted + from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that + this node pool can be auto-scaled to. The value will be ``0`` if + ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that + this node pool can be auto-scaled to. The value will be ``0`` if + ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for the + node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # + Optional. A time value given in ISO8601 combined date and time + format that represents when the node was created. + "droplet_id": "str", # Optional. The ID of + the Droplet used for the worker node. + "id": "str", # Optional. A unique ID that + can be used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # + Optional. A time value given in ISO8601 combined date and time + format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type + of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags + applied to the node pool. All node pools are automatically tagged + ``k8s``"" , ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node + reacts to pods that it won't tolerate. Available effect values + are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary + string. The ``key`` and ``value`` fields of the ``taint`` object + form a key-value pair. For example, if the value of the ``key`` + field is "special" and the value of the ``value`` field is "gpu", + the key value pair would be ``special=gpu``. + "value": "str" # Optional. An arbitrary + string. The ``key`` and ``value`` fields of the ``taint`` object + form a key-value pair. For example, if the value of the ``key`` + field is "special" and the value of the ``value`` field is "gpu", + the key value pair would be ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the Kubernetes + cluster is located. Required. + "version": "str", # The slug identifier for the version of Kubernetes used + for the cluster. If set to a minor version (e.g. "1.14"), the latest version + within it will be used (e.g. "1.14.6-do.1"); if set to "latest", the latest + published version will be used. See the ``/v2/kubernetes/options`` endpoint to + find all currently available versions. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device Metrics + Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU Device + Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver + is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether the cluster will be automatically upgraded to new patch + releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to scale + up, until either a single node type is left, or the list of expanders is + exhausted. If this flag is unset, autoscaler will use its default + expander ``random``. Passing an empty list ("" *not* ``null``"" ) will + unset any previous expander customizations. Available expanders: * + ``random``"" : Randomly selects a node group to scale. * `priority`: + Selects the node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to customize how + long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting the + node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for the + overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 or + CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control plane + firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS Cluster + Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the Kubernetes cluster + was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the control plane + is run in a highly available configuration in the cluster. Highly available + control planes incur less downtime. The property cannot be disabled. When omitted + on create, the default is version-dependent; for DOKS 1.36.0 and later, the + default is true; for earlier versions, the default is false. + "id": "str", # Optional. A unique ID that can be used to identify and + reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes master + node. This will not be set if high availability is configured on the cluster + (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A boolean + value indicating whether worker nodes in the cluster are not assigned public IP + addresses. When omitted on create, the default value is false. When enabled, a + NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window policy. + May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an + arbitrary week day. Known values are: "any", "monday", "tuesday", + "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the maintenance + window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI plugin is + enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU Device + Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA + Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI + registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA shared device + plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value indicating + if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the routing-agent + component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP addresses + for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID registered with + the identity provider. Required when ``enabled`` is ``true``. + "enabled": False, # Optional. Default value is False. Indicates + whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. Indicates + whether any non-SSO forms of authentication are disallowed. Can only be set + to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current status of + the cluster. Known values are: "running", "provisioning", "degraded", + "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether surge upgrade is enabled/disabled for the cluster. Surge + upgrade makes cluster upgrades fast and reliable by bringing up new nodes before + destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` and + ``tag:create`` scope, as well as ``tag:delete`` if existing tags are getting + removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the Kubernetes cluster + was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the VPC to + which the Kubernetes cluster is assigned.:code:`
`:code:`
`Requires + ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet to attach + worker nodes to. When omitted on create, the default subnet for the VPC is used. + This value cannot be changed after the cluster is created. ``vpc_uuid`` must + also be set. :code:`
`:code:`
`Requires ``vpc:read`` scope. + } + + # response body for status code(s): 201 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + """ + + @overload + async def create_cluster( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Kubernetes Cluster. + + To create a new Kubernetes cluster, send a POST request to + ``/v2/kubernetes/clusters``. The request must contain at least one node pool + with at least one worker. + + The request may contain a maintenance window policy describing a time period + when disruptive maintenance tasks may be carried out. Omitting the policy + implies that a window will be chosen automatically. See + `here `_ + for details. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + """ + + @distributed_trace_async + async def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create a New Kubernetes Cluster. + + To create a new Kubernetes cluster, send a POST request to + ``/v2/kubernetes/clusters``. The request must contain at least one node pool + with at least one worker. + + The request may contain a maintenance window policy describing a time period + when disruptive maintenance tasks may be carried out. Omitting the policy + implies that a window will be chosen automatically. See + `here `_ + for details. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value indicating + whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in + the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes that + support partitioning. Immutable after the node pool is created. When + omitted, the GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to + identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings + specifying labels to apply to all nodes in a pool. Labels will + automatically be applied to all existing nodes and any subsequent nodes + added to the pool. Note that when a label is removed, it is not deleted + from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that + this node pool can be auto-scaled to. The value will be ``0`` if + ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that + this node pool can be auto-scaled to. The value will be ``0`` if + ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for the + node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # + Optional. A time value given in ISO8601 combined date and time + format that represents when the node was created. + "droplet_id": "str", # Optional. The ID of + the Droplet used for the worker node. + "id": "str", # Optional. A unique ID that + can be used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # + Optional. A time value given in ISO8601 combined date and time + format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type + of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags + applied to the node pool. All node pools are automatically tagged + ``k8s``"" , ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node + reacts to pods that it won't tolerate. Available effect values + are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary + string. The ``key`` and ``value`` fields of the ``taint`` object + form a key-value pair. For example, if the value of the ``key`` + field is "special" and the value of the ``value`` field is "gpu", + the key value pair would be ``special=gpu``. + "value": "str" # Optional. An arbitrary + string. The ``key`` and ``value`` fields of the ``taint`` object + form a key-value pair. For example, if the value of the ``key`` + field is "special" and the value of the ``value`` field is "gpu", + the key value pair would be ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the Kubernetes + cluster is located. Required. + "version": "str", # The slug identifier for the version of Kubernetes used + for the cluster. If set to a minor version (e.g. "1.14"), the latest version + within it will be used (e.g. "1.14.6-do.1"); if set to "latest", the latest + published version will be used. See the ``/v2/kubernetes/options`` endpoint to + find all currently available versions. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device Metrics + Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU Device + Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver + is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether the cluster will be automatically upgraded to new patch + releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to scale + up, until either a single node type is left, or the list of expanders is + exhausted. If this flag is unset, autoscaler will use its default + expander ``random``. Passing an empty list ("" *not* ``null``"" ) will + unset any previous expander customizations. Available expanders: * + ``random``"" : Randomly selects a node group to scale. * `priority`: + Selects the node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to customize how + long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting the + node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for the + overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 or + CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control plane + firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS Cluster + Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the Kubernetes cluster + was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the control plane + is run in a highly available configuration in the cluster. Highly available + control planes incur less downtime. The property cannot be disabled. When omitted + on create, the default is version-dependent; for DOKS 1.36.0 and later, the + default is true; for earlier versions, the default is false. + "id": "str", # Optional. A unique ID that can be used to identify and + reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes master + node. This will not be set if high availability is configured on the cluster + (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A boolean + value indicating whether worker nodes in the cluster are not assigned public IP + addresses. When omitted on create, the default value is false. When enabled, a + NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window policy. + May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an + arbitrary week day. Known values are: "any", "monday", "tuesday", + "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the maintenance + window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI plugin is + enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU Device + Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA + Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI + registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA shared device + plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value indicating + if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the routing-agent + component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP addresses + for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID registered with + the identity provider. Required when ``enabled`` is ``true``. + "enabled": False, # Optional. Default value is False. Indicates + whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. Indicates + whether any non-SSO forms of authentication are disallowed. Can only be set + to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current status of + the cluster. Known values are: "running", "provisioning", "degraded", + "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether surge upgrade is enabled/disabled for the cluster. Surge + upgrade makes cluster upgrades fast and reliable by bringing up new nodes before + destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` and + ``tag:create`` scope, as well as ``tag:delete`` if existing tags are getting + removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the Kubernetes cluster + was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the VPC to + which the Kubernetes cluster is assigned.:code:`
`:code:`
`Requires + ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet to attach + worker nodes to. When omitted on create, the default subnet for the VPC is used. + This value cannot be changed after the cluster is created. ``vpc_uuid`` must + also be set. :code:`
`:code:`
`Requires ``vpc:read`` scope. + } + + # response body for status code(s): 201 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_kubernetes_create_cluster_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Existing Kubernetes Cluster. + + To show information about an existing Kubernetes cluster, send a GET request + to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": False, # Optional. Default value is False. A boolean value + indicating whether the control plane is run in a highly available + configuration in the cluster. Highly available control planes incur less + downtime. The property cannot be disabled. When omitted on create, the + default is version-dependent; for DOKS 1.36.0 and later, the default is true; + for earlier versions, the default is false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registries": [ + "str" # Optional. An array of integrated DOCR registries. + ], + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags applied to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + worker nodes are attached to. When unset, the default subnet for the VPC is + used.:code:`
`:code:`
`Requires ``vpc:read`` scope. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_get_cluster_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def update_cluster( + self, + cluster_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a Kubernetes Cluster. + + To update a Kubernetes cluster, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the + attributes below. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device Metrics + Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU Device + Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver + is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether the cluster will be automatically upgraded to new patch + releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to scale + up, until either a single node type is left, or the list of expanders is + exhausted. If this flag is unset, autoscaler will use its default + expander ``random``. Passing an empty list ("" *not* ``null``"" ) will + unset any previous expander customizations. Available expanders: * + ``random``"" : Randomly selects a node group to scale. * `priority`: + Selects the node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to customize how + long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting the + node utilization threshold. + }, + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 or + CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control plane + firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS Cluster + Proportional Autoscaler add-on is enabled. + }, + "ha": bool, # Optional. A boolean value indicating whether the control plane + is run in a highly available configuration in the cluster. Highly available + control planes incur less downtime. The property cannot be disabled. When omitted + on create, the default is version-dependent; for DOKS 1.36.0 and later, the + default is true; for earlier versions, the default is false. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window policy. + May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an + arbitrary week day. Known values are: "any", "monday", "tuesday", + "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the maintenance + window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI plugin is + enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU Device + Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA + Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI + registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA shared device + plugin is enabled. + }, + "routing_agent": { + "enabled": bool # Optional. Indicates whether the routing-agent + component is enabled. + }, + "sso": { + "client_id": "str", # Optional. The OIDC client ID registered with + the identity provider. Required when ``enabled`` is ``true``. + "enabled": False, # Optional. Default value is False. Indicates + whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. Indicates + whether any non-SSO forms of authentication are disallowed. Can only be set + to ``true`` when ``enabled`` is ``true``. + }, + "surge_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether surge upgrade is enabled/disabled for the cluster. Surge + upgrade makes cluster upgrades fast and reliable by bringing up new nodes before + destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags applied to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. + ] + } + + # response body for status code(s): 202 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def update_cluster( + self, + cluster_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a Kubernetes Cluster. + + To update a Kubernetes cluster, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the + attributes below. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def update_cluster( + self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a Kubernetes Cluster. + + To update a Kubernetes cluster, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the + attributes below. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device Metrics + Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU Device + Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver + is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether the cluster will be automatically upgraded to new patch + releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to scale + up, until either a single node type is left, or the list of expanders is + exhausted. If this flag is unset, autoscaler will use its default + expander ``random``. Passing an empty list ("" *not* ``null``"" ) will + unset any previous expander customizations. Available expanders: * + ``random``"" : Randomly selects a node group to scale. * `priority`: + Selects the node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to customize how + long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting the + node utilization threshold. + }, + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 or + CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control plane + firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS Cluster + Proportional Autoscaler add-on is enabled. + }, + "ha": bool, # Optional. A boolean value indicating whether the control plane + is run in a highly available configuration in the cluster. Highly available + control planes incur less downtime. The property cannot be disabled. When omitted + on create, the default is version-dependent; for DOKS 1.36.0 and later, the + default is true; for earlier versions, the default is false. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window policy. + May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an + arbitrary week day. Known values are: "any", "monday", "tuesday", + "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the maintenance + window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI plugin is + enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU Device + Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA + Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI + registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA shared device + plugin is enabled. + }, + "routing_agent": { + "enabled": bool # Optional. Indicates whether the routing-agent + component is enabled. + }, + "sso": { + "client_id": "str", # Optional. The OIDC client ID registered with + the identity provider. Required when ``enabled`` is ``true``. + "enabled": False, # Optional. Default value is False. Indicates + whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. Indicates + whether any non-SSO forms of authentication are disallowed. Can only be set + to ``true`` when ``enabled`` is ``true``. + }, + "surge_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether surge upgrade is enabled/disabled for the cluster. Surge + upgrade makes cluster upgrades fast and reliable by bringing up new nodes before + destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags applied to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. + ] + } + + # response body for status code(s): 202 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_kubernetes_update_cluster_request( + cluster_id=cluster_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 202: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def delete_cluster(self, cluster_id: str, **kwargs: Any) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete a Kubernetes Cluster. + + To delete a Kubernetes cluster and all services deployed to it, send a DELETE + request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID``. + + A 204 status code with no body will be returned in response to a successful + request. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_kubernetes_delete_cluster_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """List Associated Resources for Cluster Deletion. + + To list the associated billable resources that can be destroyed along with a cluster, send a + GET request to the + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources`` endpoint. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "load_balancers": [ + { + "id": "str", # Optional. The ID of a resource associated + with a Kubernetes cluster. + "name": "str" # Optional. The name of a resource associated + with a Kubernetes cluster. + } + ], + "volume_snapshots": [ + { + "id": "str", # Optional. The ID of a resource associated + with a Kubernetes cluster. + "name": "str" # Optional. The name of a resource associated + with a Kubernetes cluster. + } + ], + "volumes": [ + { + "id": "str", # Optional. The ID of a resource associated + with a Kubernetes cluster. + "name": "str" # Optional. The name of a resource associated + with a Kubernetes cluster. + } + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_list_associated_resources_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def destroy_associated_resources_selective( + self, + cluster_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Selectively Delete a Cluster and its Associated Resources. + + To delete a Kubernetes cluster along with a subset of its associated resources, + send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. + + The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or + ``volume_snapshots`` keys each set to an array of IDs for the associated + resources to be destroyed. + + The IDs can be found by querying the cluster's associated resources endpoint. + Any associated resource not included in the request will remain and continue + to accrue changes on your account. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "load_balancers": [ + "str" # Optional. A list of IDs for associated load balancers to + destroy along with the cluster. + ], + "volume_snapshots": [ + "str" # Optional. A list of IDs for associated volume snapshots to + destroy along with the cluster. + ], + "volumes": [ + "str" # Optional. A list of IDs for associated volumes to destroy + along with the cluster. + ] + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def destroy_associated_resources_selective( + self, + cluster_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Selectively Delete a Cluster and its Associated Resources. + + To delete a Kubernetes cluster along with a subset of its associated resources, + send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. + + The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or + ``volume_snapshots`` keys each set to an array of IDs for the associated + resources to be destroyed. + + The IDs can be found by querying the cluster's associated resources endpoint. + Any associated resource not included in the request will remain and continue + to accrue changes on your account. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def destroy_associated_resources_selective( + self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Selectively Delete a Cluster and its Associated Resources. + + To delete a Kubernetes cluster along with a subset of its associated resources, + send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. + + The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or + ``volume_snapshots`` keys each set to an array of IDs for the associated + resources to be destroyed. + + The IDs can be found by querying the cluster's associated resources endpoint. + Any associated resource not included in the request will remain and continue + to accrue changes on your account. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "load_balancers": [ + "str" # Optional. A list of IDs for associated load balancers to + destroy along with the cluster. + ], + "volume_snapshots": [ + "str" # Optional. A list of IDs for associated volume snapshots to + destroy along with the cluster. + ], + "volumes": [ + "str" # Optional. A list of IDs for associated volumes to destroy + along with the cluster. + ] + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_kubernetes_destroy_associated_resources_selective_request( + cluster_id=cluster_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def destroy_associated_resources_dangerous( + self, cluster_id: str, **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete a Cluster and All of its Associated Resources (Dangerous). + + To delete a Kubernetes cluster with all of its associated resources, send a + DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/dangerous``. + A 204 status code with no body will be returned in response to a successful request. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_kubernetes_destroy_associated_resources_dangerous_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_kubeconfig( + self, + cluster_id: str, + *, + expiry_seconds: int = 0, + type: Optional[str] = None, + **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Retrieve the kubeconfig for a Kubernetes Cluster. + + This endpoint returns a kubeconfig file in YAML format. It can be used to + connect to and administer the cluster using the Kubernetes command line tool, + ``kubectl``\\ , or other programs supporting kubeconfig files (e.g., client libraries). + + The resulting kubeconfig file uses token-based authentication for clusters + supporting it, and certificate-based authentication otherwise. For a list of + supported versions and more information, see "\\ `How to Connect to a DigitalOcean + Kubernetes Cluster + `_\\ ". + + To retrieve a kubeconfig file for use with a Kubernetes cluster, send a GET + request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig``. + + Clusters supporting token-based authentication may define an expiration by + passing a duration in seconds as a query parameter to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig?expiry_seconds=$DURATION_IN_SECONDS``. + If not set or 0, then the token will have a 7 day expiry. The query parameter + has no impact for other kubeconfig types. + + Using an ``sso`` kubeconfig type requires ``doctl`` to be installed to handle the client side + of the OAuth2 flow. + + Kubernetes Roles granted to a user are derived from that user's + DigitalOcean role. Predefined roles (Owner, Member, Modifier etc.) have an automatic mapping + to Kubernetes roles. Custom roles are not automatically mapped to any Kubernetes roles, + and require `additional configuration + `_ + by a cluster administrator. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :keyword expiry_seconds: The duration in seconds that the returned Kubernetes credentials will + be valid. If not set or 0, the credentials will have a 7 day expiry. Default value is 0. + :paramtype expiry_seconds: int + :keyword type: The type of credentials to return in the kubeconfig. When omitted, the + default credential type for the cluster is used: ``sso`` for clusters with SSO enabled, + ``token`` for clusters without SSO enabled. Known values are: "token" and "sso". Default value + is None. + :paramtype type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_kubernetes_get_kubeconfig_request( + cluster_id=cluster_id, + expiry_seconds=expiry_seconds, + type=type, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_credentials( + self, cluster_id: str, *, expiry_seconds: int = 0, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Retrieve Credentials for a Kubernetes Cluster. + + This endpoint returns a JSON object . It can be used to programmatically + construct Kubernetes clients which cannot parse kubeconfig files. + + The resulting JSON object contains token-based authentication for clusters + supporting it, and certificate-based authentication otherwise. For a list of + supported versions and more information, see "\\ `How to Connect to a DigitalOcean + Kubernetes Cluster + `_\\ ". + + To retrieve credentials for accessing a Kubernetes cluster, send a GET + request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials``. + + Clusters supporting token-based authentication may define an expiration by + passing a duration in seconds as a query parameter to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials?expiry_seconds=$DURATION_IN_SECONDS``. + If not set or 0, then the token will have a 7 day expiry. The query parameter + has no impact in certificate-based authentication. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :keyword expiry_seconds: The duration in seconds that the returned Kubernetes credentials will + be valid. If not set or 0, the credentials will have a 7 day expiry. Default value is 0. + :paramtype expiry_seconds: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "certificate_authority_data": bytes("bytes", encoding="utf-8"), # Optional. + A base64 encoding of bytes representing the certificate authority data for + accessing the cluster. + "client_certificate_data": bytes("bytes", encoding="utf-8"), # Optional. A + base64 encoding of bytes representing the x509 client certificate data for access + the cluster. This is only returned for clusters without support for token-based + authentication. Newly created Kubernetes clusters do not return credentials + using certificate-based authentication. For additional information, `see here + `_. + "client_key_data": bytes("bytes", encoding="utf-8"), # Optional. A base64 + encoding of bytes representing the x509 client key data for access the cluster. + This is only returned for clusters without support for token-based + authentication. Newly created Kubernetes clusters do not return credentials + using certificate-based authentication. For additional information, `see here + `_. + "expires_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the access token + expires. + "server": "str", # Optional. The URL used to access the cluster API server. + "token": "str" # Optional. An access token used to authenticate with the + cluster. This is only returned for clusters with support for token-based + authentication. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_get_credentials_request( + cluster_id=cluster_id, + expiry_seconds=expiry_seconds, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Available Upgrades for an Existing Kubernetes Cluster. + + To determine whether a cluster can be upgraded, and the versions to which it + can be upgraded, send a GET request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "available_upgrade_versions": [ + { + "kubernetes_version": "str", # Optional. The upstream + version string for the version of Kubernetes provided by a given slug. + "slug": "str", # Optional. The slug identifier for an + available version of Kubernetes for use when creating or updating a + cluster. The string contains both the upstream version of Kubernetes as + well as the DigitalOcean revision. + "supported_features": [ + "str" # Optional. The features available with the + version of Kubernetes provided by a given slug. + ] + } + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_get_available_upgrades_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def upgrade_cluster( + self, + cluster_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Upgrade a Kubernetes Cluster. + + To immediately upgrade a Kubernetes cluster to a newer patch release of + Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. + The body of the request must specify a version attribute. + + Available upgrade versions for a cluster can be fetched from + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "version": "str" # Optional. The slug identifier for the version of + Kubernetes that the cluster will be upgraded to. + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def upgrade_cluster( + self, + cluster_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Upgrade a Kubernetes Cluster. + + To immediately upgrade a Kubernetes cluster to a newer patch release of + Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. + The body of the request must specify a version attribute. + + Available upgrade versions for a cluster can be fetched from + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ @distributed_trace_async - async def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + async def upgrade_cluster( + self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Create a New Kubernetes Cluster. + """Upgrade a Kubernetes Cluster. - To create a new Kubernetes cluster, send a POST request to - ``/v2/kubernetes/clusters``. The request must contain at least one node pool - with at least one worker. + To immediately upgrade a Kubernetes cluster to a newer patch release of + Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. + The body of the request must specify a version attribute. - The request may contain a maintenance window policy describing a time period - when disruptive maintenance tasks may be carried out. Omitting the policy - implies that a window will be chosen automatically. See - `here `_ - for details. + Available upgrade versions for a cluster can be fetched from + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -167530,7 +175023,129 @@ async def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> J # JSON input template you can fill out and use as your body input. body = { - "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "version": "str" # Optional. The slug identifier for the version of + Kubernetes that the cluster will be upgraded to. + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_kubernetes_upgrade_cluster_request( + cluster_id=cluster_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 202: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_node_pools(self, cluster_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """List All Node Pools in a Kubernetes Clusters. + + To list all of the node pools in a Kubernetes clusters, send a GET request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { "node_pools": [ { "auto_scale": bool, # Optional. A boolean value indicating @@ -167606,410 +175221,583 @@ async def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> J } ] } - ], - "region": "str", # The slug identifier for the region where the Kubernetes - cluster is located. Required. - "version": "str", # The slug identifier for the version of Kubernetes used - for the cluster. If set to a minor version (e.g. "1.14"), the latest version - within it will be used (e.g. "1.14.6-do.1"); if set to "latest", the latest - published version will be used. See the ``/v2/kubernetes/options`` endpoint to - find all currently available versions. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device Metrics - Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU Device - Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver - is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether the cluster will be automatically upgraded to new patch - releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to scale - up, until either a single node type is left, or the list of expanders is - exhausted. If this flag is unset, autoscaler will use its default - expander ``random``. Passing an empty list ("" *not* ``null``"" ) will - unset any previous expander customizations. Available expanders: * - ``random``"" : Randomly selects a node group to scale. * `priority`: - Selects the node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to customize how - long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting the - node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for the - overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 or - CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control plane - firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS Cluster - Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the Kubernetes cluster - was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the control plane - is run in a highly available configuration in the cluster. Highly available - control planes incur less downtime. The property cannot be disabled. When omitted - on create, the default is version-dependent; for DOKS 1.36.0 and later, the - default is true; for earlier versions, the default is false. + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_list_node_pools_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def add_node_pool( + self, + cluster_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Add a Node Pool to a Kubernetes Cluster. + + To add an additional node pool to a Kubernetes clusters, send a POST request + to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following + attributes. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode for this + node pool. Only applicable to AMD GPU sizes that support partitioning. Immutable + after the node pool is created. When omitted, the GPUs in the pool are left + unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". "id": "str", # Optional. A unique ID that can be used to identify and - reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes master - node. This will not be set if high availability is configured on the cluster - (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A boolean - value indicating whether worker nodes in the cluster are not assigned public IP - addresses. When omitted on create, the default value is false. When enabled, a - NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window policy. - May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an - arbitrary week day. Known values are: "any", "monday", "tuesday", - "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the maintenance - window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI plugin is - enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU Device - Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA - Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI - registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA shared device - plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value indicating - if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the routing-agent - component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP addresses - for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID registered with - the identity provider. Required when ``enabled`` is ``true``. - "enabled": False, # Optional. Default value is False. Indicates - whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. Indicates - whether any non-SSO forms of authentication are disallowed. Can only be set - to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current status of - the cluster. Known values are: "running", "provisioning", "degraded", - "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether surge upgrade is enabled/disabled for the cluster. Surge - upgrade makes cluster upgrades fast and reliable by bringing up new nodes before - destroying the outdated nodes. + reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying labels + to apply to all nodes in a pool. Labels will automatically be applied to all + existing nodes and any subsequent nodes added to the pool. Note that when a label + is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the node was created. + "droplet_id": "str", # Optional. The ID of the Droplet used + for the worker node. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the node. + "name": "str", # Optional. An automatically generated, + human-readable name for the node. + "status": { + "state": "str" # Optional. A string indicating the + current status of the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A time value + given in ISO8601 combined date and time format that represents when the + node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type of Droplet used + as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` and - ``tag:create`` scope, as well as ``tag:delete`` if existing tags are getting - removed. + "str" # Optional. An array containing the tags applied to the node + pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , + and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the Kubernetes cluster - was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the VPC to - which the Kubernetes cluster is assigned.:code:`
`:code:`
`Requires - ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet to attach - worker nodes to. When omitted on create, the default subnet for the VPC is used. - This value cannot be changed after the cluster is created. ``vpc_uuid`` must - also be set. :code:`
`:code:`
`Requires ``vpc:read`` scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to pods + that it won't tolerate. Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: + "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] } # response body for status code(s): 201 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def add_node_pool( + self, + cluster_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Add a Node Pool to a Kubernetes Cluster. + + To add an additional node pool to a Kubernetes clusters, send a POST request + to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following + attributes. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. + "id": "str", # Optional. A unique ID that can be + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def add_node_pool( + self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Add a Node Pool to a Kubernetes Cluster. + + To add an additional node pool to a Kubernetes clusters, send a POST request + to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following + attributes. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode for this + node pool. Only applicable to AMD GPU sizes that support partitioning. Immutable + after the node pool is created. When omitted, the GPUs in the pool are left + unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify and + reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying labels + to apply to all nodes in a pool. Labels will automatically be applied to all + existing nodes and any subsequent nodes added to the pool. Note that when a label + is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the node was created. + "droplet_id": "str", # Optional. The ID of the Droplet used + for the worker node. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the node. + "name": "str", # Optional. An automatically generated, + human-readable name for the node. + "status": { + "state": "str" # Optional. A string indicating the + current status of the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A time value + given in ISO8601 combined date and time format that represents when the + node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type of Droplet used + as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags applied to the node + pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , + and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to pods + that it won't tolerate. Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: + "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + + # response body for status code(s): 201 + response == { + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. + "id": "str", # Optional. A unique ID that can be + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -168040,7 +175828,8 @@ async def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> J else: _json = body - _request = build_kubernetes_create_cluster_request( + _request = build_kubernetes_add_node_pool_request( + cluster_id=cluster_id, content_type=content_type, json=_json, content=_content, @@ -168058,27 +175847,44 @@ async def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> J response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [201, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore @@ -168086,15 +175892,20 @@ async def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> J return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: + async def get_node_pool( + self, cluster_id: str, node_pool_id: str, **kwargs: Any + ) -> JSON: # pylint: disable=line-too-long - """Retrieve an Existing Kubernetes Cluster. + """Retrieve a Node Pool for a Kubernetes Cluster. - To show information about an existing Kubernetes cluster, send a GET request - to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID``. + To show information about a specific node pool in a Kubernetes cluster, send + a GET request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID``. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -168104,249 +175915,76 @@ async def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: # response body for status code(s): 200 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": False, # Optional. Default value is False. A boolean value - indicating whether the control plane is run in a highly available - configuration in the cluster. Highly available control planes incur less - downtime. The property cannot be disabled. When omitted on create, the - default is version-dependent; for DOKS 1.36.0 and later, the default is true; - for earlier versions, the default is false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registries": [ - "str" # Optional. An array of integrated DOCR registries. - ], - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags applied to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - worker nodes are attached to. When unset, the default subnet for the VPC is - used.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } # response body for status code(s): 404 @@ -168379,8 +176017,9 @@ async def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_cluster_request( + _request = build_kubernetes_get_node_pool_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, headers=_headers, params=_params, ) @@ -168440,23 +176079,28 @@ async def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore @overload - async def update_cluster( + async def update_node_pool( self, cluster_id: str, + node_pool_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update a Kubernetes Cluster. + """Update a Node Pool in a Kubernetes Cluster. - To update a Kubernetes cluster, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the - attributes below. + To update the name of a node pool, edit the tags applied to it, or adjust its + number of nodes, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the + following attributes. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -168471,362 +176115,141 @@ async def update_cluster( # JSON input template you can fill out and use as your body input. body = { - "name": "str", # A human-readable name for a Kubernetes cluster. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device Metrics - Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU Device - Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver - is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether the cluster will be automatically upgraded to new patch - releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to scale - up, until either a single node type is left, or the list of expanders is - exhausted. If this flag is unset, autoscaler will use its default - expander ``random``. Passing an empty list ("" *not* ``null``"" ) will - unset any previous expander customizations. Available expanders: * - ``random``"" : Randomly selects a node group to scale. * `priority`: - Selects the node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to customize how - long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting the - node utilization threshold. - }, - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 or - CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control plane - firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS Cluster - Proportional Autoscaler add-on is enabled. - }, - "ha": bool, # Optional. A boolean value indicating whether the control plane - is run in a highly available configuration in the cluster. Highly available - control planes incur less downtime. The property cannot be disabled. When omitted - on create, the default is version-dependent; for DOKS 1.36.0 and later, the - default is true; for earlier versions, the default is false. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window policy. - May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an - arbitrary week day. Known values are: "any", "monday", "tuesday", - "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the maintenance - window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI plugin is - enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU Device - Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA - Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI - registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA shared device - plugin is enabled. - }, - "routing_agent": { - "enabled": bool # Optional. Indicates whether the routing-agent - component is enabled. - }, - "sso": { - "client_id": "str", # Optional. The OIDC client ID registered with - the identity provider. Required when ``enabled`` is ``true``. - "enabled": False, # Optional. Default value is False. Indicates - whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. Indicates - whether any non-SSO forms of authentication are disallowed. Can only be set - to ``true`` when ``enabled`` is ``true``. - }, - "surge_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether surge upgrade is enabled/disabled for the cluster. Surge - upgrade makes cluster upgrades fast and reliable by bringing up new nodes before - destroying the outdated nodes. + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node pool. + "id": "str", # Optional. A unique ID that can be used to identify and + reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying labels + to apply to all nodes in a pool. Labels will automatically be applied to all + existing nodes and any subsequent nodes added to the pool. Note that when a label + is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the node was created. + "droplet_id": "str", # Optional. The ID of the Droplet used + for the worker node. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the node. + "name": "str", # Optional. An automatically generated, + human-readable name for the node. + "status": { + "state": "str" # Optional. A string indicating the + current status of the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A time value + given in ISO8601 combined date and time format that represents when the + node was last updated. + } + ], "tags": [ - "str" # Optional. An array of tags applied to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. + "str" # Optional. An array containing the tags applied to the node + pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , + and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to pods + that it won't tolerate. Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: + "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } ] } # response body for status code(s): 202 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } # response body for status code(s): 404 @@ -168843,23 +176266,28 @@ async def update_cluster( """ @overload - async def update_cluster( + async def update_node_pool( self, cluster_id: str, + node_pool_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update a Kubernetes Cluster. + """Update a Node Pool in a Kubernetes Cluster. - To update a Kubernetes cluster, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the - attributes below. + To update the name of a node pool, edit the tags applied to it, or adjust its + number of nodes, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the + following attributes. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -168874,249 +176302,76 @@ async def update_cluster( # response body for status code(s): 202 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } # response body for status code(s): 404 @@ -169133,18 +176388,26 @@ async def update_cluster( """ @distributed_trace_async - async def update_cluster( - self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + async def update_node_pool( + self, + cluster_id: str, + node_pool_id: str, + body: Union[JSON, IO[bytes]], + **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update a Kubernetes Cluster. + """Update a Node Pool in a Kubernetes Cluster. - To update a Kubernetes cluster, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the - attributes below. + To update the name of a node pool, edit the tags applied to it, or adjust its + number of nodes, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the + following attributes. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] :return: JSON object @@ -169156,362 +176419,141 @@ async def update_cluster( # JSON input template you can fill out and use as your body input. body = { - "name": "str", # A human-readable name for a Kubernetes cluster. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device Metrics - Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU Device - Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver - is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether the cluster will be automatically upgraded to new patch - releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to scale - up, until either a single node type is left, or the list of expanders is - exhausted. If this flag is unset, autoscaler will use its default - expander ``random``. Passing an empty list ("" *not* ``null``"" ) will - unset any previous expander customizations. Available expanders: * - ``random``"" : Randomly selects a node group to scale. * `priority`: - Selects the node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to customize how - long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting the - node utilization threshold. - }, - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 or - CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control plane - firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS Cluster - Proportional Autoscaler add-on is enabled. - }, - "ha": bool, # Optional. A boolean value indicating whether the control plane - is run in a highly available configuration in the cluster. Highly available - control planes incur less downtime. The property cannot be disabled. When omitted - on create, the default is version-dependent; for DOKS 1.36.0 and later, the - default is true; for earlier versions, the default is false. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window policy. - May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an - arbitrary week day. Known values are: "any", "monday", "tuesday", - "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the maintenance - window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI plugin is - enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU Device - Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA - Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI - registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA shared device - plugin is enabled. - }, - "routing_agent": { - "enabled": bool # Optional. Indicates whether the routing-agent - component is enabled. - }, - "sso": { - "client_id": "str", # Optional. The OIDC client ID registered with - the identity provider. Required when ``enabled`` is ``true``. - "enabled": False, # Optional. Default value is False. Indicates - whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. Indicates - whether any non-SSO forms of authentication are disallowed. Can only be set - to ``true`` when ``enabled`` is ``true``. - }, - "surge_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether surge upgrade is enabled/disabled for the cluster. Surge - upgrade makes cluster upgrades fast and reliable by bringing up new nodes before - destroying the outdated nodes. + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node pool. + "id": "str", # Optional. A unique ID that can be used to identify and + reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying labels + to apply to all nodes in a pool. Labels will automatically be applied to all + existing nodes and any subsequent nodes added to the pool. Note that when a label + is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the node was created. + "droplet_id": "str", # Optional. The ID of the Droplet used + for the worker node. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the node. + "name": "str", # Optional. An automatically generated, + human-readable name for the node. + "status": { + "state": "str" # Optional. A string indicating the + current status of the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A time value + given in ISO8601 combined date and time format that represents when the + node was last updated. + } + ], "tags": [ - "str" # Optional. An array of tags applied to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. + "str" # Optional. An array containing the tags applied to the node + pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , + and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to pods + that it won't tolerate. Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: + "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } ] } # response body for status code(s): 202 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } # response body for status code(s): 404 @@ -169555,8 +176597,9 @@ async def update_cluster( else: _json = body - _request = build_kubernetes_update_cluster_request( + _request = build_kubernetes_update_node_pool_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, content_type=content_type, json=_json, content=_content, @@ -169619,18 +176662,23 @@ async def update_cluster( return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def delete_cluster(self, cluster_id: str, **kwargs: Any) -> Optional[JSON]: + async def delete_node_pool( + self, cluster_id: str, node_pool_id: str, **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Delete a Kubernetes Cluster. + """Delete a Node Pool in a Kubernetes Cluster. - To delete a Kubernetes cluster and all services deployed to it, send a DELETE - request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID``. + To delete a node pool, send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID``. A 204 status code with no body will be returned in response to a successful - request. + request. Nodes in the pool will subsequently be drained and deleted. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :return: JSON object or None :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: @@ -169668,8 +176716,9 @@ async def delete_cluster(self, cluster_id: str, **kwargs: Any) -> Optional[JSON] cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_delete_cluster_request( + _request = build_kubernetes_delete_node_pool_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, headers=_headers, params=_params, ) @@ -169725,50 +176774,53 @@ async def delete_cluster(self, cluster_id: str, **kwargs: Any) -> Optional[JSON] return deserialized # type: ignore @distributed_trace_async - async def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSON: + async def delete_node( + self, + cluster_id: str, + node_pool_id: str, + node_id: str, + *, + skip_drain: int = 0, + replace: int = 0, + **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """List Associated Resources for Cluster Deletion. + """Delete a Node in a Kubernetes Cluster. - To list the associated billable resources that can be destroyed along with a cluster, send a - GET request to the - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources`` endpoint. + To delete a single node in a pool, send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID``. + + Appending the ``skip_drain=1`` query parameter to the request causes node + draining to be skipped. Omitting the query parameter or setting its value to + ``0`` carries out draining prior to deletion. + + Appending the ``replace=1`` query parameter to the request causes the node to + be replaced by a new one after deletion. Omitting the query parameter or + setting its value to ``0`` deletes without replacement. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str - :return: JSON object - :rtype: JSON + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str + :param node_id: A unique ID that can be used to reference a node in a Kubernetes node pool. + Required. + :type node_id: str + :keyword skip_drain: Specifies whether or not to drain workloads from a node before it is + deleted. Setting it to ``1`` causes node draining to be skipped. Omitting the query parameter + or setting its value to ``0`` carries out draining prior to deletion. Default value is 0. + :paramtype skip_drain: int + :keyword replace: Specifies whether or not to replace a node after it has been deleted. Setting + it to ``1`` causes the node to be replaced by a new one after deletion. Omitting the query + parameter or setting its value to ``0`` deletes without replacement. Default value is 0. + :paramtype replace: int + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 - response == { - "load_balancers": [ - { - "id": "str", # Optional. The ID of a resource associated - with a Kubernetes cluster. - "name": "str" # Optional. The name of a resource associated - with a Kubernetes cluster. - } - ], - "volume_snapshots": [ - { - "id": "str", # Optional. The ID of a resource associated - with a Kubernetes cluster. - "name": "str" # Optional. The name of a resource associated - with a Kubernetes cluster. - } - ], - "volumes": [ - { - "id": "str", # Optional. The ID of a resource associated - with a Kubernetes cluster. - "name": "str" # Optional. The name of a resource associated - with a Kubernetes cluster. - } - ] - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -169797,10 +176849,14 @@ async def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSO _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_list_associated_resources_request( + _request = build_kubernetes_delete_node_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, + node_id=node_id, + skip_drain=skip_drain, + replace=replace, headers=_headers, params=_params, ) @@ -169815,14 +176871,15 @@ async def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSO response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [202, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - if response.status_code == 200: + if response.status_code == 202: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -169833,11 +176890,6 @@ async def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSO "int", response.headers.get("ratelimit-reset") ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -169855,36 +176907,32 @@ async def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSO deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return deserialized # type: ignore @overload - async def destroy_associated_resources_selective( + async def recycle_node_pool( self, cluster_id: str, + node_pool_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> Optional[JSON]: # pylint: disable=line-too-long - """Selectively Delete a Cluster and its Associated Resources. - - To delete a Kubernetes cluster along with a subset of its associated resources, - send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. - - The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or - ``volume_snapshots`` keys each set to an array of IDs for the associated - resources to be destroyed. + """Recycle a Kubernetes Node Pool. - The IDs can be found by querying the cluster's associated resources endpoint. - Any associated resource not included in the request will remain and continue - to accrue changes on your account. + The endpoint has been deprecated. Please use the DELETE + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` + method instead. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -169899,17 +176947,8 @@ async def destroy_associated_resources_selective( # JSON input template you can fill out and use as your body input. body = { - "load_balancers": [ - "str" # Optional. A list of IDs for associated load balancers to - destroy along with the cluster. - ], - "volume_snapshots": [ - "str" # Optional. A list of IDs for associated volume snapshots to - destroy along with the cluster. - ], - "volumes": [ - "str" # Optional. A list of IDs for associated volumes to destroy - along with the cluster. + "nodes": [ + "str" # Optional. ] } @@ -169927,31 +176966,27 @@ async def destroy_associated_resources_selective( """ @overload - async def destroy_associated_resources_selective( + async def recycle_node_pool( self, cluster_id: str, + node_pool_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> Optional[JSON]: # pylint: disable=line-too-long - """Selectively Delete a Cluster and its Associated Resources. - - To delete a Kubernetes cluster along with a subset of its associated resources, - send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. - - The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or - ``volume_snapshots`` keys each set to an array of IDs for the associated - resources to be destroyed. + """Recycle a Kubernetes Node Pool. - The IDs can be found by querying the cluster's associated resources endpoint. - Any associated resource not included in the request will remain and continue - to accrue changes on your account. + The endpoint has been deprecated. Please use the DELETE + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` + method instead. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -169978,26 +177013,25 @@ async def destroy_associated_resources_selective( """ @distributed_trace_async - async def destroy_associated_resources_selective( - self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + async def recycle_node_pool( + self, + cluster_id: str, + node_pool_id: str, + body: Union[JSON, IO[bytes]], + **kwargs: Any ) -> Optional[JSON]: # pylint: disable=line-too-long - """Selectively Delete a Cluster and its Associated Resources. - - To delete a Kubernetes cluster along with a subset of its associated resources, - send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. - - The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or - ``volume_snapshots`` keys each set to an array of IDs for the associated - resources to be destroyed. + """Recycle a Kubernetes Node Pool. - The IDs can be found by querying the cluster's associated resources endpoint. - Any associated resource not included in the request will remain and continue - to accrue changes on your account. + The endpoint has been deprecated. Please use the DELETE + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` + method instead. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] :return: JSON object or None @@ -170006,20 +177040,11 @@ async def destroy_associated_resources_selective( Example: .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "load_balancers": [ - "str" # Optional. A list of IDs for associated load balancers to - destroy along with the cluster. - ], - "volume_snapshots": [ - "str" # Optional. A list of IDs for associated volume snapshots to - destroy along with the cluster. - ], - "volumes": [ - "str" # Optional. A list of IDs for associated volumes to destroy - along with the cluster. + + # JSON input template you can fill out and use as your body input. + body = { + "nodes": [ + "str" # Optional. ] } @@ -170064,8 +177089,9 @@ async def destroy_associated_resources_selective( else: _json = body - _request = build_kubernetes_destroy_associated_resources_selective_request( + _request = build_kubernetes_recycle_node_pool_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, content_type=content_type, json=_json, content=_content, @@ -170083,7 +177109,7 @@ async def destroy_associated_resources_selective( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [202, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore @@ -170091,7 +177117,7 @@ async def destroy_associated_resources_selective( deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 202: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -170124,26 +177150,33 @@ async def destroy_associated_resources_selective( return deserialized # type: ignore @distributed_trace_async - async def destroy_associated_resources_dangerous( - self, cluster_id: str, **kwargs: Any - ) -> Optional[JSON]: + async def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Delete a Cluster and All of its Associated Resources (Dangerous). + """Retrieve User Information for a Kubernetes Cluster. - To delete a Kubernetes cluster with all of its associated resources, send a - DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/dangerous``. - A 204 status code with no body will be returned in response to a successful request. + To show information the user associated with a Kubernetes cluster, send a GET + request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/user``. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "kubernetes_cluster_user": { + "groups": [ + "str" # Optional. A list of in-cluster groups that the user + belongs to. + ], + "username": "str" # Optional. The username for the cluster admin + user. + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -170172,9 +177205,9 @@ async def destroy_associated_resources_dangerous( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_destroy_associated_resources_dangerous_request( + _request = build_kubernetes_get_cluster_user_request( cluster_id=cluster_id, headers=_headers, params=_params, @@ -170190,15 +177223,14 @@ async def destroy_associated_resources_dangerous( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [200, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -170209,6 +177241,11 @@ async def destroy_associated_resources_dangerous( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -170226,68 +177263,61 @@ async def destroy_associated_resources_dangerous( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_kubeconfig( - self, - cluster_id: str, - *, - expiry_seconds: int = 0, - type: Optional[str] = None, - **kwargs: Any - ) -> Optional[JSON]: + async def list_options(self, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Retrieve the kubeconfig for a Kubernetes Cluster. - - This endpoint returns a kubeconfig file in YAML format. It can be used to - connect to and administer the cluster using the Kubernetes command line tool, - ``kubectl``\\ , or other programs supporting kubeconfig files (e.g., client libraries). - - The resulting kubeconfig file uses token-based authentication for clusters - supporting it, and certificate-based authentication otherwise. For a list of - supported versions and more information, see "\\ `How to Connect to a DigitalOcean - Kubernetes Cluster - `_\\ ". - - To retrieve a kubeconfig file for use with a Kubernetes cluster, send a GET - request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig``. - - Clusters supporting token-based authentication may define an expiration by - passing a duration in seconds as a query parameter to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig?expiry_seconds=$DURATION_IN_SECONDS``. - If not set or 0, then the token will have a 7 day expiry. The query parameter - has no impact for other kubeconfig types. - - Using an ``sso`` kubeconfig type requires ``doctl`` to be installed to handle the client side - of the OAuth2 flow. + """List Available Regions, Node Sizes, and Versions of Kubernetes. - Kubernetes Roles granted to a user are derived from that user's - DigitalOcean role. Predefined roles (Owner, Member, Modifier etc.) have an automatic mapping - to Kubernetes roles. Custom roles are not automatically mapped to any Kubernetes roles, - and require `additional configuration - `_ - by a cluster administrator. + To list the versions of Kubernetes available for use, the regions that support Kubernetes, and + the available node sizes, send a GET request to ``/v2/kubernetes/options``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :keyword expiry_seconds: The duration in seconds that the returned Kubernetes credentials will - be valid. If not set or 0, the credentials will have a 7 day expiry. Default value is 0. - :paramtype expiry_seconds: int - :keyword type: The type of credentials to return in the kubeconfig. When omitted, the - default credential type for the cluster is used: ``sso`` for clusters with SSO enabled, - ``token`` for clusters without SSO enabled. Known values are: "token" and "sso". Default value - is None. - :paramtype type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "options": { + "regions": [ + { + "name": "str", # Optional. A DigitalOcean region + where Kubernetes is available. + "slug": "str" # Optional. The identifier for a + region for use when creating a new cluster. + } + ], + "sizes": [ + { + "name": "str", # Optional. A Droplet size available + for use in a Kubernetes node pool. + "slug": "str" # Optional. The identifier for a size + for use when creating a new cluster. + } + ], + "versions": [ + { + "kubernetes_version": "str", # Optional. The + upstream version string for the version of Kubernetes provided by a + given slug. + "slug": "str", # Optional. The slug identifier for + an available version of Kubernetes for use when creating or updating + a cluster. The string contains both the upstream version of + Kubernetes as well as the DigitalOcean revision. + "supported_features": [ + "str" # Optional. The features available + with the version of Kubernetes provided by a given slug. + ] + } + ] + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -170316,12 +177346,9 @@ async def get_kubeconfig( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_kubeconfig_request( - cluster_id=cluster_id, - expiry_seconds=expiry_seconds, - type=type, + _request = build_kubernetes_list_options_request( headers=_headers, params=_params, ) @@ -170342,7 +177369,6 @@ async def get_kubeconfig( map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( @@ -170355,6 +177381,11 @@ async def get_kubeconfig( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -170372,40 +177403,119 @@ async def get_kubeconfig( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore - @distributed_trace_async - async def get_credentials( - self, cluster_id: str, *, expiry_seconds: int = 0, **kwargs: Any + @overload + async def run_cluster_lint( + self, + cluster_id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Retrieve Credentials for a Kubernetes Cluster. + """Run Clusterlint Checks on a Kubernetes Cluster. - This endpoint returns a JSON object . It can be used to programmatically - construct Kubernetes clients which cannot parse kubeconfig files. + Clusterlint helps operators conform to Kubernetes best practices around + resources, security and reliability to avoid common problems while operating + or upgrading the clusters. - The resulting JSON object contains token-based authentication for clusters - supporting it, and certificate-based authentication otherwise. For a list of - supported versions and more information, see "\\ `How to Connect to a DigitalOcean - Kubernetes Cluster - `_\\ ". + To request a clusterlint run on your cluster, send a POST request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all + checks present in the ``doks`` group by default, if a request body is not + specified. Optionally specify the below attributes. - To retrieve credentials for accessing a Kubernetes cluster, send a GET - request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials``. + For information about the available checks, please refer to + `the clusterlint check documentation + `_. - Clusters supporting token-based authentication may define an expiration by - passing a duration in seconds as a query parameter to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials?expiry_seconds=$DURATION_IN_SECONDS``. - If not set or 0, then the token will have a 7 day expiry. The query parameter - has no impact in certificate-based authentication. + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "exclude_checks": [ + "str" # Optional. An array of checks that will be run when + clusterlint executes checks. + ], + "exclude_groups": [ + "str" # Optional. An array of check groups that will be omitted when + clusterlint executes checks. + ], + "include_checks": [ + "str" # Optional. An array of checks that will be run when + clusterlint executes checks. + ], + "include_groups": [ + "str" # Optional. An array of check groups that will be run when + clusterlint executes checks. + ] + } + + # response body for status code(s): 202 + response == { + "run_id": "str" # Optional. ID of the clusterlint run that can be used later + to fetch the diagnostics. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def run_cluster_lint( + self, + cluster_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Run Clusterlint Checks on a Kubernetes Cluster. + + Clusterlint helps operators conform to Kubernetes best practices around + resources, security and reliability to avoid common problems while operating + or upgrading the clusters. + + To request a clusterlint run on your cluster, send a POST request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all + checks present in the ``doks`` group by default, if a request body is not + specified. Optionally specify the below attributes. + + For information about the available checks, please refer to + `the clusterlint check documentation + `_. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str - :keyword expiry_seconds: The duration in seconds that the returned Kubernetes credentials will - be valid. If not set or 0, the credentials will have a 7 day expiry. Default value is 0. - :paramtype expiry_seconds: int + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -170413,30 +177523,82 @@ async def get_credentials( Example: .. code-block:: python - # response body for status code(s): 200 + # response body for status code(s): 202 response == { - "certificate_authority_data": bytes("bytes", encoding="utf-8"), # Optional. - A base64 encoding of bytes representing the certificate authority data for - accessing the cluster. - "client_certificate_data": bytes("bytes", encoding="utf-8"), # Optional. A - base64 encoding of bytes representing the x509 client certificate data for access - the cluster. This is only returned for clusters without support for token-based - authentication. Newly created Kubernetes clusters do not return credentials - using certificate-based authentication. For additional information, `see here - `_. - "client_key_data": bytes("bytes", encoding="utf-8"), # Optional. A base64 - encoding of bytes representing the x509 client key data for access the cluster. - This is only returned for clusters without support for token-based - authentication. Newly created Kubernetes clusters do not return credentials - using certificate-based authentication. For additional information, `see here - `_. - "expires_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the access token - expires. - "server": "str", # Optional. The URL used to access the cluster API server. - "token": "str" # Optional. An access token used to authenticate with the - cluster. This is only returned for clusters with support for token-based - authentication. + "run_id": "str" # Optional. ID of the clusterlint run that can be used later + to fetch the diagnostics. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def run_cluster_lint( + self, + cluster_id: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Run Clusterlint Checks on a Kubernetes Cluster. + + Clusterlint helps operators conform to Kubernetes best practices around + resources, security and reliability to avoid common problems while operating + or upgrading the clusters. + + To request a clusterlint run on your cluster, send a POST request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all + checks present in the ``doks`` group by default, if a request body is not + specified. Optionally specify the below attributes. + + For information about the available checks, please refer to + `the clusterlint check documentation + `_. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "exclude_checks": [ + "str" # Optional. An array of checks that will be run when + clusterlint executes checks. + ], + "exclude_groups": [ + "str" # Optional. An array of check groups that will be omitted when + clusterlint executes checks. + ], + "include_checks": [ + "str" # Optional. An array of checks that will be run when + clusterlint executes checks. + ], + "include_groups": [ + "str" # Optional. An array of check groups that will be run when + clusterlint executes checks. + ] + } + + # response body for status code(s): 202 + response == { + "run_id": "str" # Optional. ID of the clusterlint run that can be used later + to fetch the diagnostics. } # response body for status code(s): 404 response == { @@ -170463,14 +177625,30 @@ async def get_credentials( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_credentials_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_kubernetes_run_cluster_lint_request( cluster_id=cluster_id, - expiry_seconds=expiry_seconds, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -170485,14 +177663,14 @@ async def get_credentials( response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [202, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: + if response.status_code == 202: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -170530,16 +177708,26 @@ async def get_credentials( return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: + async def get_cluster_lint_results( + self, cluster_id: str, *, run_id: Optional[str] = None, **kwargs: Any + ) -> JSON: # pylint: disable=line-too-long - """Retrieve Available Upgrades for an Existing Kubernetes Cluster. + """Fetch Clusterlint Diagnostics for a Kubernetes Cluster. - To determine whether a cluster can be upgraded, and the versions to which it - can be upgraded, send a GET request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + To request clusterlint diagnostics for your cluster, send a GET request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. If the ``run_id`` query + parameter is provided, then the diagnostics for the specific run is fetched. + By default, the latest results are shown. + + To find out how to address clusterlint feedback, please refer to + `the clusterlint check documentation + `_. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :keyword run_id: Specifies the clusterlint run whose results will be retrieved. Default value + is None. + :paramtype run_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -170549,20 +177737,31 @@ async def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: # response body for status code(s): 200 response == { - "available_upgrade_versions": [ + "completed_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the schedule + clusterlint run request was completed. + "diagnostics": [ { - "kubernetes_version": "str", # Optional. The upstream - version string for the version of Kubernetes provided by a given slug. - "slug": "str", # Optional. The slug identifier for an - available version of Kubernetes for use when creating or updating a - cluster. The string contains both the upstream version of Kubernetes as - well as the DigitalOcean revision. - "supported_features": [ - "str" # Optional. The features available with the - version of Kubernetes provided by a given slug. - ] + "check_name": "str", # Optional. The clusterlint check that + resulted in the diagnostic. + "message": "str", # Optional. Feedback about the object for + users to fix. + "object": { + "kind": "str", # Optional. The kind of Kubernetes + API object. + "name": "str", # Optional. Name of the object. + "namespace": "str" # Optional. The namespace the + object resides in the cluster. + }, + "severity": "str" # Optional. Can be one of error, warning + or suggestion. } - ] + ], + "requested_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the schedule + clusterlint run request was made. + "run_id": "str" # Optional. Id of the clusterlint run that can be used later + to fetch the diagnostics. } # response body for status code(s): 404 response == { @@ -170594,8 +177793,9 @@ async def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_available_upgrades_request( + _request = build_kubernetes_get_cluster_lint_results_request( cluster_id=cluster_id, + run_id=run_id, headers=_headers, params=_params, ) @@ -170655,33 +177855,25 @@ async def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore @overload - async def upgrade_cluster( + async def add_registry( # pylint: disable=inconsistent-return-statements self, - cluster_id: str, - body: JSON, + body: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Upgrade a Kubernetes Cluster. - - To immediately upgrade a Kubernetes cluster to a newer patch release of - Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. - The body of the request must specify a version attribute. + ) -> None: + """Add Container Registry to Kubernetes Clusters. - Available upgrade versions for a cluster can be fetched from - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + To integrate the container registry with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registry``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Required. + :param body: Default value is None. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -170689,89 +177881,152 @@ async def upgrade_cluster( # JSON input template you can fill out and use as your body input. body = { - "version": "str" # Optional. The slug identifier for the version of - Kubernetes that the cluster will be upgraded to. - } - - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ] } """ @overload - async def upgrade_cluster( + async def add_registry( # pylint: disable=inconsistent-return-statements self, - cluster_id: str, - body: IO[bytes], + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Upgrade a Kubernetes Cluster. - - To immediately upgrade a Kubernetes cluster to a newer patch release of - Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. - The body of the request must specify a version attribute. + ) -> None: + """Add Container Registry to Kubernetes Clusters. - Available upgrade versions for a cluster can be fetched from - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + To integrate the container registry with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registry``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Required. + :param body: Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def add_registry( # pylint: disable=inconsistent-return-statements + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> None: + """Add Container Registry to Kubernetes Clusters. + + To integrate the container registry with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registry``. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + # JSON input template you can fill out and use as your body input. + body = { + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ] } """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @distributed_trace_async - async def upgrade_cluster( - self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Upgrade a Kubernetes Cluster. + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - To immediately upgrade a Kubernetes cluster to a newer patch release of - Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. - The body of the request must specify a version attribute. + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - Available upgrade versions for a cluster can be fetched from - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :return: JSON object or None - :rtype: JSON or None + _request = build_kubernetes_add_registry_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + async def remove_registry( # pylint: disable=inconsistent-return-statements + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Remove Container Registry from Kubernetes Clusters. + + To remove the container registry from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registry``. + + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -170779,20 +178034,60 @@ async def upgrade_cluster( # JSON input template you can fill out and use as your body input. body = { - "version": "str" # Optional. The slug identifier for the version of - Kubernetes that the cluster will be upgraded to. + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ] } + """ - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + @overload + async def remove_registry( # pylint: disable=inconsistent-return-statements + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Remove Container Registry from Kubernetes Clusters. + + To remove the container registry from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registry``. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def remove_registry( # pylint: disable=inconsistent-return-statements + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> None: + """Remove Container Registry from Kubernetes Clusters. + + To remove the container registry from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registry``. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ] } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -170814,7 +178109,7 @@ async def upgrade_cluster( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -170822,10 +178117,12 @@ async def upgrade_cluster( if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + if body is not None: + _json = body + else: + _json = None - _request = build_kubernetes_upgrade_cluster_request( - cluster_id=cluster_id, + _request = build_kubernetes_remove_registry_request( content_type=content_type, json=_json, content=_content, @@ -170843,153 +178140,114 @@ async def upgrade_cluster( response = pipeline_response.http_response - if response.status_code not in [202, 404]: + if response.status_code not in [204]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 202: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore - if response.content: - deserialized = response.json() - else: - deserialized = None + @overload + async def add_registries( # pylint: disable=inconsistent-return-statements + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Add Container Registries to Kubernetes Clusters. - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + To integrate the container registries with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registries``. - return deserialized # type: ignore + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ], + "registries": [ + "str" # Optional. An array containing the registry names. + ] + } + """ + + @overload + async def add_registries( # pylint: disable=inconsistent-return-statements + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Add Container Registries to Kubernetes Clusters. + + To integrate the container registries with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registries``. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def list_node_pools(self, cluster_id: str, **kwargs: Any) -> JSON: - # pylint: disable=line-too-long - """List All Node Pools in a Kubernetes Clusters. + async def add_registries( # pylint: disable=inconsistent-return-statements + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> None: + """Add Container Registries to Kubernetes Clusters. - To list all of the node pools in a Kubernetes clusters, send a GET request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools``. + To integrate the container registries with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registries``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :return: JSON object - :rtype: JSON + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 - response == { - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean value indicating - whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in - the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes that - support partitioning. Immutable after the node pool is created. When - omitted, the GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to - identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings - specifying labels to apply to all nodes in a pool. Labels will - automatically be applied to all existing nodes and any subsequent nodes - added to the pool. Note that when a label is removed, it is not deleted - from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that - this node pool can be auto-scaled to. The value will be ``0`` if - ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that - this node pool can be auto-scaled to. The value will be ``0`` if - ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for the - node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # - Optional. A time value given in ISO8601 combined date and time - format that represents when the node was created. - "droplet_id": "str", # Optional. The ID of - the Droplet used for the worker node. - "id": "str", # Optional. A unique ID that - can be used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # - Optional. A time value given in ISO8601 combined date and time - format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type - of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags - applied to the node pool. All node pools are automatically tagged - ``k8s``"" , ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node - reacts to pods that it won't tolerate. Available effect values - are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary - string. The ``key`` and ``value`` fields of the ``taint`` object - form a key-value pair. For example, if the value of the ``key`` - field is "special" and the value of the ``value`` field is "gpu", - the key value pair would be ``special=gpu``. - "value": "str" # Optional. An arbitrary - string. The ``key`` and ``value`` fields of the ``taint`` object - form a key-value pair. For example, if the value of the ``key`` - field is "special" and the value of the ``value`` field is "gpu", - the key value pair would be ``special=gpu``. - } - ] - } + # JSON input template you can fill out and use as your body input. + body = { + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ], + "registries": [ + "str" # Optional. An array containing the registry names. ] } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -171004,13 +178262,29 @@ async def list_node_pools(self, cluster_id: str, **kwargs: Any) -> JSON: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_kubernetes_list_node_pools_request( - cluster_id=cluster_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_kubernetes_add_registries_request( + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -171025,75 +178299,46 @@ async def list_node_pools(self, cluster_id: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [204]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore + return cls(pipeline_response, None, response_headers) # type: ignore @overload - async def add_node_pool( + async def remove_registries( # pylint: disable=inconsistent-return-statements self, - cluster_id: str, - body: JSON, + body: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Add a Node Pool to a Kubernetes Cluster. + ) -> None: + """Remove Container Registries from Kubernetes Clusters. - To add an additional node pool to a Kubernetes clusters, send a POST request - to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following - attributes. + To remove the container registries from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registries``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Required. + :param body: Default value is None. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -171101,297 +178346,52 @@ async def add_node_pool( # JSON input template you can fill out and use as your body input. body = { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode for this - node pool. Only applicable to AMD GPU sizes that support partitioning. Immutable - after the node pool is created. When omitted, the GPUs in the pool are left - unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify and - reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying labels - to apply to all nodes in a pool. Labels will automatically be applied to all - existing nodes and any subsequent nodes added to the pool. Note that when a label - is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the node was created. - "droplet_id": "str", # Optional. The ID of the Droplet used - for the worker node. - "id": "str", # Optional. A unique ID that can be used to - identify and reference the node. - "name": "str", # Optional. An automatically generated, - human-readable name for the node. - "status": { - "state": "str" # Optional. A string indicating the - current status of the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A time value - given in ISO8601 combined date and time format that represents when the - node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of Droplet used - as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to the node - pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , - and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to pods - that it won't tolerate. Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: - "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } + "registries": [ + "str" # Optional. An array containing the registry names. ] } - - # response body for status code(s): 201 - response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - } - ] - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ @overload - async def add_node_pool( + async def remove_registries( # pylint: disable=inconsistent-return-statements self, - cluster_id: str, - body: IO[bytes], + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Add a Node Pool to a Kubernetes Cluster. + ) -> None: + """Remove Container Registries from Kubernetes Clusters. - To add an additional node pool to a Kubernetes clusters, send a POST request - to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following - attributes. + To remove the container registries from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registries``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Required. + :param body: Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 201 - response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - } - ] - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ @distributed_trace_async - async def add_node_pool( - self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Add a Node Pool to a Kubernetes Cluster. + async def remove_registries( # pylint: disable=inconsistent-return-statements + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> None: + """Remove Container Registries from Kubernetes Clusters. - To add an additional node pool to a Kubernetes clusters, send a POST request - to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following - attributes. + To remove the container registries from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registries``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -171399,161 +178399,14 @@ async def add_node_pool( # JSON input template you can fill out and use as your body input. body = { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode for this - node pool. Only applicable to AMD GPU sizes that support partitioning. Immutable - after the node pool is created. When omitted, the GPUs in the pool are left - unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify and - reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying labels - to apply to all nodes in a pool. Labels will automatically be applied to all - existing nodes and any subsequent nodes added to the pool. Note that when a label - is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the node was created. - "droplet_id": "str", # Optional. The ID of the Droplet used - for the worker node. - "id": "str", # Optional. A unique ID that can be used to - identify and reference the node. - "name": "str", # Optional. An automatically generated, - human-readable name for the node. - "status": { - "state": "str" # Optional. A string indicating the - current status of the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A time value - given in ISO8601 combined date and time format that represents when the - node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of Droplet used - as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to the node - pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , - and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to pods - that it won't tolerate. Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: - "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } + "registries": [ + "str" # Optional. An array containing the registry names. ] } - - # response body for status code(s): 201 - response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - } - ] - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -171574,7 +178427,7 @@ async def add_node_pool( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -171582,10 +178435,12 @@ async def add_node_pool( if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + if body is not None: + _json = body + else: + _json = None - _request = build_kubernetes_add_node_pool_request( - cluster_id=cluster_id, + _request = build_kubernetes_remove_registries_request( content_type=content_type, json=_json, content=_content, @@ -171603,65 +178458,46 @@ async def add_node_pool( response = pipeline_response.http_response - if response.status_code not in [201, 404]: + if response.status_code not in [204]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 201: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async - async def get_node_pool( - self, cluster_id: str, node_pool_id: str, **kwargs: Any + async def get_status_messages( + self, + cluster_id: str, + *, + since: Optional[datetime.datetime] = None, + **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Retrieve a Node Pool for a Kubernetes Cluster. + """Fetch Status Messages for a Kubernetes Cluster. - To show information about a specific node pool in a Kubernetes cluster, send - a GET request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID``. + To retrieve status messages for a Kubernetes cluster, send a GET request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/status_messages``. Status messages inform users of + any issues that come up during the cluster lifecycle. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str + :keyword since: A timestamp used to return status messages emitted since the specified time. + The timestamp should be in ISO8601 format. Default value is None. + :paramtype since: ~datetime.datetime :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -171671,77 +178507,14 @@ async def get_node_pool( # response body for status code(s): 200 response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - } - ] - } + "messages": [ + { + "message": "str", # Optional. Status information about the + cluster which impacts it's lifecycle. + "timestamp": "2020-02-20 00:00:00" # Optional. A timestamp + in ISO8601 format that represents when the status message was emitted. + } + ] } # response body for status code(s): 404 response == { @@ -171773,9 +178546,9 @@ async def get_node_pool( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_node_pool_request( + _request = build_kubernetes_get_status_messages_request( cluster_id=cluster_id, - node_pool_id=node_pool_id, + since=since, headers=_headers, params=_params, ) @@ -171834,29 +178607,47 @@ async def get_node_pool( return cast(JSON, deserialized) # type: ignore + +class LoadBalancersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`load_balancers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + @overload - async def update_node_pool( - self, - cluster_id: str, - node_pool_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any + async def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update a Node Pool in a Kubernetes Cluster. + """Create a New Load Balancer. - To update the name of a node pool, edit the tags applied to it, or adjust its - number of nodes, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the - following attributes. + To create a new load balancer instance, send a POST request to + ``/v2/load_balancers``. + + You can specify the Droplets that will sit behind the load balancer using one + of two methods: + + + * Set ``droplet_ids`` to a list of specific Droplet IDs. + * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be + assigned to the load balancer. Additional Droplets will be automatically + assigned as they are tagged. + + These methods are mutually exclusive. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -171870,180 +178661,247 @@ async def update_node_pool( .. code-block:: python # JSON input template you can fill out and use as your body input. - body = { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node pool. - "id": "str", # Optional. A unique ID that can be used to identify and - reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying labels - to apply to all nodes in a pool. Labels will automatically be applied to all - existing nodes and any subsequent nodes added to the pool. Note that when a label - is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the node was created. - "droplet_id": "str", # Optional. The ID of the Droplet used - for the worker node. - "id": "str", # Optional. A unique ID that can be used to - identify and reference the node. - "name": "str", # Optional. An automatically generated, - human-readable name for the node. - "status": { - "state": "str" # Optional. A string indicating the - current status of the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A time value - given in ISO8601 combined date and time format that represents when the - node was last updated. - } - ], - "tags": [ - "str" # Optional. An array containing the tags applied to the node - pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , - and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to pods - that it won't tolerate. Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: - "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] - } + body = {} # response body for status code(s): 202 response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ + "load_balancer": { + "forwarding_rules": [ { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. } ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. } - ] + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. } } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ @overload - async def update_node_pool( - self, - cluster_id: str, - node_pool_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any + async def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update a Node Pool in a Kubernetes Cluster. + """Create a New Load Balancer. - To update the name of a node pool, edit the tags applied to it, or adjust its - number of nodes, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the - following attributes. + To create a new load balancer instance, send a POST request to + ``/v2/load_balancers``. + + You can specify the Droplets that will sit behind the load balancer using one + of two methods: + + + * Set ``droplet_ids`` to a list of specific Droplet IDs. + * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be + assigned to the load balancer. Additional Droplets will be automatically + assigned as they are tagged. + + These methods are mutually exclusive. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -172058,112 +178916,241 @@ async def update_node_pool( # response body for status code(s): 202 response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ + "load_balancer": { + "forwarding_rules": [ { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. } ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. } - ] + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. } } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ @distributed_trace_async - async def update_node_pool( - self, - cluster_id: str, - node_pool_id: str, - body: Union[JSON, IO[bytes]], - **kwargs: Any - ) -> JSON: + async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Update a Node Pool in a Kubernetes Cluster. + """Create a New Load Balancer. - To update the name of a node pool, edit the tags applied to it, or adjust its - number of nodes, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the - following attributes. + To create a new load balancer instance, send a POST request to + ``/v2/load_balancers``. + + You can specify the Droplets that will sit behind the load balancer using one + of two methods: + + + * Set ``droplet_ids`` to a list of specific Droplet IDs. + * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be + assigned to the load balancer. Additional Droplets will be automatically + assigned as they are tagged. + + These methods are mutually exclusive. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] :return: JSON object @@ -172174,155 +179161,224 @@ async def update_node_pool( .. code-block:: python # JSON input template you can fill out and use as your body input. - body = { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node pool. - "id": "str", # Optional. A unique ID that can be used to identify and - reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying labels - to apply to all nodes in a pool. Labels will automatically be applied to all - existing nodes and any subsequent nodes added to the pool. Note that when a label - is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the node was created. - "droplet_id": "str", # Optional. The ID of the Droplet used - for the worker node. - "id": "str", # Optional. A unique ID that can be used to - identify and reference the node. - "name": "str", # Optional. An automatically generated, - human-readable name for the node. - "status": { - "state": "str" # Optional. A string indicating the - current status of the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A time value - given in ISO8601 combined date and time format that represents when the - node was last updated. - } - ], - "tags": [ - "str" # Optional. An array containing the tags applied to the node - pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , - and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to pods - that it won't tolerate. Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: - "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] - } + body = {} # response body for status code(s): 202 response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ + "load_balancer": { + "forwarding_rules": [ { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. } ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. } - ] + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. } } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -172353,9 +179409,7 @@ async def update_node_pool( else: _json = body - _request = build_kubernetes_update_node_pool_request( - cluster_id=cluster_id, - node_pool_id=node_pool_id, + _request = build_load_balancers_create_request( content_type=content_type, json=_json, content=_content, @@ -172373,44 +179427,27 @@ async def update_node_pool( response = pipeline_response.http_response - if response.status_code not in [202, 404]: + if response.status_code not in [202]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 202: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore @@ -172418,40 +179455,259 @@ async def update_node_pool( return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def delete_node_pool( - self, cluster_id: str, node_pool_id: str, **kwargs: Any - ) -> Optional[JSON]: + async def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Delete a Node Pool in a Kubernetes Cluster. - - To delete a node pool, send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID``. + """List All Load Balancers. - A 204 status code with no body will be returned in response to a successful - request. Nodes in the pool will subsequently be drained and deleted. + To list all of the load balancer instances on your account, send a GET request + to ``/v2/load_balancers``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str - :return: JSON object or None - :rtype: JSON or None + :keyword per_page: Number of items returned per page. Default value is 20. + :paramtype per_page: int + :keyword page: Which 'page' of paginated results to return. Default value is 1. + :paramtype page: int + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "meta": { + "total": 0 # Optional. Number of objects returned by the request. + }, + "links": { + "pages": {} + }, + "load_balancers": [ + { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing + the port on which the load balancer instance will listen. + Required. + "entry_protocol": "str", # The protocol used + for traffic to the load balancer. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" + , or ``udp``. If you set the ``entry_protocol`` to ``udp``"" , + the ``target_protocol`` must be set to ``udp``. When using UDP, + the load balancer requires that you set up a health check with a + port that uses TCP, HTTP, or HTTPS to work properly. Required. + Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing + the port on the backend Droplets to which the load balancer will + send traffic. Required. + "target_protocol": "str", # The protocol + used for traffic from the load balancer to the backend Droplets. + The possible values are: ``http``"" , ``https``"" , ``http2``"" , + ``tcp``"" , or ``udp``. If you set the ``target_protocol`` to + ``udp``"" , the ``entry_protocol`` must be set to ``udp``. When + using UDP, the load balancer requires that you set up a health + check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "tcp", and + "udp". + "certificate_id": "str", # Optional. The ID + of the TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A + boolean value indicating whether SSL encrypted traffic will be + passed through to the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify + an algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the load balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. + Default value is False. A boolean value indicating whether to disable + automatic DNS record creation for Let's Encrypt certificates that are + added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID + of the TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean + value indicating if the domain is already managed by + DigitalOcean. If true, all A and AAAA records required to enable + Global load balancers will be automatically added. + "name": "str" # Optional. FQDN to associate + with a Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the + Droplets assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value + is False. A boolean value indicating whether HTTP keepalive connections + are maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is + False. A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing + traffic to the load balancer (in the form 'ip:1.2.3.4' or + 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying + traffic to the load balancer (in the form 'ip:1.2.3.4' or + 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean + flag to enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer + value as a percentage to indicate failure threshold to decide how the + regional priorities will take effect. A value of ``50`` would + indicate that the Global load balancer will choose a lower priority + region to forward traffic to once this failure threshold has been + reached for the higher priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string + to an integer priority value indicating preference for which + regional target a Global load balancer will forward traffic to. A + lower value indicates a higher priority. + }, + "target_port": 0, # Optional. An integer + representing the port on the target backends which the load balancer + will forward traffic to. + "target_protocol": "str" # Optional. The protocol + used for forwarding traffic from the load balancer to the target + backends. The possible values are ``http``"" , ``https`` and + ``http2``. Known values are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default + value is 10. The number of seconds between between two consecutive + health checks. + "healthy_threshold": 3, # Optional. Default value is + 3. The number of times a health check must pass for a backend Droplet + to be marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The + path on the backend Droplets to which the load balancer instance will + send a request. + "port": 80, # Optional. Default value is 80. An + integer representing the port on the backend Droplets on which the + health check will attempt a connection. + "protocol": "http", # Optional. Default value is + "http". The protocol used for health checks sent to the backend + Droplets. The possible values are ``http``"" , ``https``"" , or + ``tcp``. Known values are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default + value is 5. The number of seconds the load balancer instance will + wait for a response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value + is 5. The number of times a health check must fail for a backend + Droplet to be marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value + is 60. An integer value which configures the idle timeout for HTTP + requests to the target droplets. + "id": "str", # Optional. A unique ID that can be used to + identify and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the + public-facing IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load + balancer instance. + "network": "EXTERNAL", # Optional. Default value is + "EXTERNAL". A string indicating whether the load balancer should be + external or internal. Internal load balancers have no public IPs and are + only accessible to resources on the same VPC network. This property + cannot be updated after creating the load balancer. Known values are: + "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is + "IPV4". A string indicating whether the load balancer will support IPv4 + or both IPv4 and IPv6 networking. This property cannot be updated after + creating the load balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that + the load balancer is associated with. If no ID is provided at creation, + the load balancer associates with the user's default project. If an + invalid project ID is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value + is False. A boolean value indicating whether HTTP requests to the load + balancer on port 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that + represents whether new Droplets can be created in this region. + Required. + "features": [ + "str" # This attribute is set to an array + which contains features available in this region. Required. + ], + "name": "str", # The display name of the region. + This will be a full name that is used in the control panel and other + interfaces. Required. + "sizes": [ + "str" # This attribute is set to an array + which contains the identifying slugs for the sizes available in + this region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used + as a unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". + This field has been replaced by the ``size_unit`` field for all regions + except in AMS2, NYC2, and SFO1. Each available load balancer size now + equates to the load balancer having a set number of nodes. * + ``lb-small`` = 1 node * ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes + You can resize load balancers after creation up to once per hour. You + cannot resize a load balancer within the first hour of its creation. + Known values are: "lb-small", "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many + nodes the load balancer contains. Each additional node increases the load + balancer's ability to manage more connections. Load balancers can be + scaled up or down, and you can change the number of nodes after creation + up to once per hour. This field is currently not available in the AMS2, + NYC2, or SFO1 regions. Use the ``size`` field to scale load balancers + that reside in these regions. + "status": "str", # Optional. A status string indicating the + current state of the load balancer. This can be ``new``"" , ``active``"" + , or ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the + cookie sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of + seconds until the cookie set by the load balancer expires. This + attribute is only returned when using ``cookies`` for the sticky + sessions type. + "type": "none" # Optional. Default value is "none". + An attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values + are ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the + UUID of the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag + corresponding to Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of + the Regional load balancers to be used as target backends for a + Global load balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used + by the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. + The default value is ``DEFAULT``. Known values are: "DEFAULT" and + "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". + A string indicating whether the load balancer should be a standard + regional HTTP load balancer, a regional network load balancer that routes + traffic at the TCP/UDP transport layer, or a global load balancer. Known + values are: "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID + of the VPC to which the load balancer is assigned. + } + ] } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -172470,11 +179726,11 @@ async def delete_node_pool( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_delete_node_pool_request( - cluster_id=cluster_id, - node_pool_id=node_pool_id, + _request = build_load_balancers_list_request( + per_page=per_page, + page=page, headers=_headers, params=_params, ) @@ -172489,94 +179745,266 @@ async def delete_node_pool( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [200]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def delete_node( - self, - cluster_id: str, - node_pool_id: str, - node_id: str, - *, - skip_drain: int = 0, - replace: int = 0, - **kwargs: Any - ) -> Optional[JSON]: + async def get(self, lb_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Delete a Node in a Kubernetes Cluster. - - To delete a single node in a pool, send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID``. - - Appending the ``skip_drain=1`` query parameter to the request causes node - draining to be skipped. Omitting the query parameter or setting its value to - ``0`` carries out draining prior to deletion. + """Retrieve an Existing Load Balancer. - Appending the ``replace=1`` query parameter to the request causes the node to - be replaced by a new one after deletion. Omitting the query parameter or - setting its value to ``0`` deletes without replacement. + To show information about a load balancer instance, send a GET request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str - :param node_id: A unique ID that can be used to reference a node in a Kubernetes node pool. - Required. - :type node_id: str - :keyword skip_drain: Specifies whether or not to drain workloads from a node before it is - deleted. Setting it to ``1`` causes node draining to be skipped. Omitting the query parameter - or setting its value to ``0`` carries out draining prior to deletion. Default value is 0. - :paramtype skip_drain: int - :keyword replace: Specifies whether or not to replace a node after it has been deleted. Setting - it to ``1`` causes the node to be replaced by a new one after deletion. Omitting the query - parameter or setting its value to ``0`` deletes without replacement. Default value is 0. - :paramtype replace: int - :return: JSON object or None - :rtype: JSON or None + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "load_balancer": { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -172605,14 +180033,10 @@ async def delete_node( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_delete_node_request( - cluster_id=cluster_id, - node_pool_id=node_pool_id, - node_id=node_id, - skip_drain=skip_drain, - replace=replace, + _request = build_load_balancers_get_request( + lb_id=lb_id, headers=_headers, params=_params, ) @@ -172627,15 +180051,14 @@ async def delete_node( response = pipeline_response.http_response - if response.status_code not in [202, 404]: + if response.status_code not in [200, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 202: + if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -172646,6 +180069,11 @@ async def delete_node( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -172663,51 +180091,262 @@ async def delete_node( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @overload - async def recycle_node_pool( + async def update( self, - cluster_id: str, - node_pool_id: str, + lb_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Recycle a Kubernetes Node Pool. + """Update a Load Balancer. - The endpoint has been deprecated. Please use the DELETE - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` - method instead. + To update a load balancer's settings, send a PUT request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full + representation of the load balancer including existing attributes. It may + contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually + exclusive. **Note that any attribute that is not provided will be reset to its + default value.**. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python # JSON input template you can fill out and use as your body input. - body = { - "nodes": [ - "str" # Optional. - ] - } + body = {} + # response body for status code(s): 200 + response == { + "load_balancer": { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -172722,39 +180361,254 @@ async def recycle_node_pool( """ @overload - async def recycle_node_pool( + async def update( self, - cluster_id: str, - node_pool_id: str, + lb_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Recycle a Kubernetes Node Pool. + """Update a Load Balancer. - The endpoint has been deprecated. Please use the DELETE - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` - method instead. + To update a load balancer's settings, send a PUT request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full + representation of the load balancer including existing attributes. It may + contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually + exclusive. **Note that any attribute that is not provided will be reset to its + default value.**. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "load_balancer": { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -172769,41 +180623,249 @@ async def recycle_node_pool( """ @distributed_trace_async - async def recycle_node_pool( - self, - cluster_id: str, - node_pool_id: str, - body: Union[JSON, IO[bytes]], - **kwargs: Any - ) -> Optional[JSON]: + async def update( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: # pylint: disable=line-too-long - """Recycle a Kubernetes Node Pool. + """Update a Load Balancer. - The endpoint has been deprecated. Please use the DELETE - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` - method instead. + To update a load balancer's settings, send a PUT request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full + representation of the load balancer including existing attributes. It may + contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually + exclusive. **Note that any attribute that is not provided will be reset to its + default value.**. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python # JSON input template you can fill out and use as your body input. - body = { - "nodes": [ - "str" # Optional. - ] + body = {} + + # response body for status code(s): 200 + response == { + "load_balancer": { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. + } } - # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -172835,7 +180897,7 @@ async def recycle_node_pool( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -172845,9 +180907,8 @@ async def recycle_node_pool( else: _json = body - _request = build_kubernetes_recycle_node_pool_request( - cluster_id=cluster_id, - node_pool_id=node_pool_id, + _request = build_load_balancers_update_request( + lb_id=lb_id, content_type=content_type, json=_json, content=_content, @@ -172865,15 +180926,14 @@ async def recycle_node_pool( response = pipeline_response.http_response - if response.status_code not in [202, 404]: + if response.status_code not in [200, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 202: + if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -172884,6 +180944,11 @@ async def recycle_node_pool( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -172901,38 +180966,31 @@ async def recycle_node_pool( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: + async def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: # pylint: disable=line-too-long - """Retrieve User Information for a Kubernetes Cluster. + """Delete a Load Balancer. - To show information the user associated with a Kubernetes cluster, send a GET - request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/user``. + To delete a load balancer instance, disassociating any Droplets assigned to it + and removing it from your account, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :return: JSON object - :rtype: JSON + A successful request will receive a 204 status code with no body in response. + This indicates that the request was processed successfully. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 - response == { - "kubernetes_cluster_user": { - "groups": [ - "str" # Optional. A list of in-cluster groups that the user - belongs to. - ], - "username": "str" # Optional. The username for the cluster admin - user. - } - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -172961,10 +181019,10 @@ async def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_get_cluster_user_request( - cluster_id=cluster_id, + _request = build_load_balancers_delete_request( + lb_id=lb_id, headers=_headers, params=_params, ) @@ -172979,14 +181037,15 @@ async def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [204, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - if response.status_code == 200: + if response.status_code == 204: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -172997,11 +181056,6 @@ async def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: "int", response.headers.get("ratelimit-reset") ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -173019,61 +181073,30 @@ async def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return deserialized # type: ignore @distributed_trace_async - async def list_options(self, **kwargs: Any) -> JSON: + async def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: # pylint: disable=line-too-long - """List Available Regions, Node Sizes, and Versions of Kubernetes. + """Delete a Global Load Balancer CDN Cache. - To list the versions of Kubernetes available for use, the regions that support Kubernetes, and - the available node sizes, send a GET request to ``/v2/kubernetes/options``. + To delete a Global load balancer CDN cache, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/cache``. - :return: JSON object - :rtype: JSON + A successful request will receive a 204 status code with no body in response. + This indicates that the request was processed successfully. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 - response == { - "options": { - "regions": [ - { - "name": "str", # Optional. A DigitalOcean region - where Kubernetes is available. - "slug": "str" # Optional. The identifier for a - region for use when creating a new cluster. - } - ], - "sizes": [ - { - "name": "str", # Optional. A Droplet size available - for use in a Kubernetes node pool. - "slug": "str" # Optional. The identifier for a size - for use when creating a new cluster. - } - ], - "versions": [ - { - "kubernetes_version": "str", # Optional. The - upstream version string for the version of Kubernetes provided by a - given slug. - "slug": "str", # Optional. The slug identifier for - an available version of Kubernetes for use when creating or updating - a cluster. The string contains both the upstream version of - Kubernetes as well as the DigitalOcean revision. - "supported_features": [ - "str" # Optional. The features available - with the version of Kubernetes provided by a given slug. - ] - } - ] - } - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -173102,9 +181125,10 @@ async def list_options(self, **kwargs: Any) -> JSON: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_list_options_request( + _request = build_load_balancers_delete_cache_request( + lb_id=lb_id, headers=_headers, params=_params, ) @@ -173119,14 +181143,15 @@ async def list_options(self, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [204, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - if response.status_code == 200: + if response.status_code == 204: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -173137,11 +181162,6 @@ async def list_options(self, **kwargs: Any) -> JSON: "int", response.headers.get("ratelimit-reset") ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -173159,44 +181179,42 @@ async def list_options(self, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return deserialized # type: ignore @overload - async def run_cluster_lint( + async def add_droplets( self, - cluster_id: str, - body: Optional[JSON] = None, + lb_id: str, + body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> JSON: + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Run Clusterlint Checks on a Kubernetes Cluster. - - Clusterlint helps operators conform to Kubernetes best practices around - resources, security and reliability to avoid common problems while operating - or upgrading the clusters. + """Add Droplets to a Load Balancer. - To request a clusterlint run on your cluster, send a POST request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all - checks present in the ``doks`` group by default, if a request body is not - specified. Optionally specify the below attributes. + To assign a Droplet to a load balancer instance, send a POST request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. + Individual Droplets can not be added to a load balancer configured with a + Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" + response from the API. - For information about the available checks, please refer to - `the clusterlint check documentation - `_. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Default value is None. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -173204,29 +181222,12 @@ async def run_cluster_lint( # JSON input template you can fill out and use as your body input. body = { - "exclude_checks": [ - "str" # Optional. An array of checks that will be run when - clusterlint executes checks. - ], - "exclude_groups": [ - "str" # Optional. An array of check groups that will be omitted when - clusterlint executes checks. - ], - "include_checks": [ - "str" # Optional. An array of checks that will be run when - clusterlint executes checks. - ], - "include_groups": [ - "str" # Optional. An array of check groups that will be run when - clusterlint executes checks. + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets assigned + to the load balancer. ] } - # response body for status code(s): 202 - response == { - "run_id": "str" # Optional. ID of the clusterlint run that can be used later - to fetch the diagnostics. - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -173241,121 +181242,42 @@ async def run_cluster_lint( """ @overload - async def run_cluster_lint( + async def add_droplets( self, - cluster_id: str, - body: Optional[IO[bytes]] = None, + lb_id: str, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> JSON: + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Run Clusterlint Checks on a Kubernetes Cluster. - - Clusterlint helps operators conform to Kubernetes best practices around - resources, security and reliability to avoid common problems while operating - or upgrading the clusters. + """Add Droplets to a Load Balancer. - To request a clusterlint run on your cluster, send a POST request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all - checks present in the ``doks`` group by default, if a request body is not - specified. Optionally specify the below attributes. + To assign a Droplet to a load balancer instance, send a POST request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. + Individual Droplets can not be added to a load balancer configured with a + Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" + response from the API. - For information about the available checks, please refer to - `the clusterlint check documentation - `_. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Default value is None. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "run_id": "str" # Optional. ID of the clusterlint run that can be used later - to fetch the diagnostics. - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ - - @distributed_trace_async - async def run_cluster_lint( - self, - cluster_id: str, - body: Optional[Union[JSON, IO[bytes]]] = None, - **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Run Clusterlint Checks on a Kubernetes Cluster. - - Clusterlint helps operators conform to Kubernetes best practices around - resources, security and reliability to avoid common problems while operating - or upgrading the clusters. - - To request a clusterlint run on your cluster, send a POST request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all - checks present in the ``doks`` group by default, if a request body is not - specified. Optionally specify the below attributes. - - For information about the available checks, please refer to - `the clusterlint check documentation - `_. - - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "exclude_checks": [ - "str" # Optional. An array of checks that will be run when - clusterlint executes checks. - ], - "exclude_groups": [ - "str" # Optional. An array of check groups that will be omitted when - clusterlint executes checks. - ], - "include_checks": [ - "str" # Optional. An array of checks that will be run when - clusterlint executes checks. - ], - "include_groups": [ - "str" # Optional. An array of check groups that will be run when - clusterlint executes checks. - ] - } - - # response body for status code(s): 202 - response == { - "run_id": "str" # Optional. ID of the clusterlint run that can be used later - to fetch the diagnostics. - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -173368,627 +181290,31 @@ async def run_cluster_lint( tickets to help identify the issue. } """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - 401: cast( - Type[HttpResponseError], - lambda response: ClientAuthenticationError(response=response), - ), - 429: HttpResponseError, - 500: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[JSON] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = body - else: - _json = None - - _request = build_kubernetes_run_cluster_lint_request( - cluster_id=cluster_id, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 202: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_cluster_lint_results( - self, cluster_id: str, *, run_id: Optional[str] = None, **kwargs: Any - ) -> JSON: + async def add_droplets( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Fetch Clusterlint Diagnostics for a Kubernetes Cluster. - - To request clusterlint diagnostics for your cluster, send a GET request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. If the ``run_id`` query - parameter is provided, then the diagnostics for the specific run is fetched. - By default, the latest results are shown. - - To find out how to address clusterlint feedback, please refer to - `the clusterlint check documentation - `_. - - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :keyword run_id: Specifies the clusterlint run whose results will be retrieved. Default value - is None. - :paramtype run_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "completed_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the schedule - clusterlint run request was completed. - "diagnostics": [ - { - "check_name": "str", # Optional. The clusterlint check that - resulted in the diagnostic. - "message": "str", # Optional. Feedback about the object for - users to fix. - "object": { - "kind": "str", # Optional. The kind of Kubernetes - API object. - "name": "str", # Optional. Name of the object. - "namespace": "str" # Optional. The namespace the - object resides in the cluster. - }, - "severity": "str" # Optional. Can be one of error, warning - or suggestion. - } - ], - "requested_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the schedule - clusterlint run request was made. - "run_id": "str" # Optional. Id of the clusterlint run that can be used later - to fetch the diagnostics. - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - 401: cast( - Type[HttpResponseError], - lambda response: ClientAuthenticationError(response=response), - ), - 429: HttpResponseError, - 500: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - _request = build_kubernetes_get_cluster_lint_results_request( - cluster_id=cluster_id, - run_id=run_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore - - @overload - async def add_registry( # pylint: disable=inconsistent-return-statements - self, - body: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Add Container Registry to Kubernetes Clusters. - - To integrate the container registry with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registry``. - - :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ] - } - """ - - @overload - async def add_registry( # pylint: disable=inconsistent-return-statements - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Add Container Registry to Kubernetes Clusters. - - To integrate the container registry with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registry``. - - :param body: Default value is None. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def add_registry( # pylint: disable=inconsistent-return-statements - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> None: - """Add Container Registry to Kubernetes Clusters. - - To integrate the container registry with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registry``. - - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ] - } - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - 401: cast( - Type[HttpResponseError], - lambda response: ClientAuthenticationError(response=response), - ), - 429: HttpResponseError, - 500: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = body - else: - _json = None - - _request = build_kubernetes_add_registry_request( - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - async def remove_registry( # pylint: disable=inconsistent-return-statements - self, - body: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Remove Container Registry from Kubernetes Clusters. - - To remove the container registry from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registry``. - - :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ] - } - """ - - @overload - async def remove_registry( # pylint: disable=inconsistent-return-statements - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Remove Container Registry from Kubernetes Clusters. - - To remove the container registry from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registry``. - - :param body: Default value is None. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def remove_registry( # pylint: disable=inconsistent-return-statements - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> None: - """Remove Container Registry from Kubernetes Clusters. - - To remove the container registry from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registry``. - - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ] - } - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - 401: cast( - Type[HttpResponseError], - lambda response: ClientAuthenticationError(response=response), - ), - 429: HttpResponseError, - 500: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = body - else: - _json = None - - _request = build_kubernetes_remove_registry_request( - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - async def add_registries( # pylint: disable=inconsistent-return-statements - self, - body: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Add Container Registries to Kubernetes Clusters. - - To integrate the container registries with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registries``. - - :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ], - "registries": [ - "str" # Optional. An array containing the registry names. - ] - } - """ - - @overload - async def add_registries( # pylint: disable=inconsistent-return-statements - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Add Container Registries to Kubernetes Clusters. - - To integrate the container registries with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registries``. - - :param body: Default value is None. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + """Add Droplets to a Load Balancer. - @distributed_trace_async - async def add_registries( # pylint: disable=inconsistent-return-statements - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> None: - """Add Container Registries to Kubernetes Clusters. + To assign a Droplet to a load balancer instance, send a POST request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. + Individual Droplets can not be added to a load balancer configured with a + Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" + response from the API. - To integrate the container registries with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registries``. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: None - :rtype: None + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -173996,14 +181322,23 @@ async def add_registries( # pylint: disable=inconsistent-return-statements # JSON input template you can fill out and use as your body input. body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ], - "registries": [ - "str" # Optional. An array containing the registry names. + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets assigned + to the load balancer. ] } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -174024,7 +181359,7 @@ async def add_registries( # pylint: disable=inconsistent-return-statements content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -174032,12 +181367,10 @@ async def add_registries( # pylint: disable=inconsistent-return-statements if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = body - else: - _json = None + _json = body - _request = build_kubernetes_add_registries_request( + _request = build_load_balancers_add_droplets_request( + lb_id=lb_id, content_type=content_type, json=_json, content=_content, @@ -174055,46 +181388,75 @@ async def add_registries( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [204, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload - async def remove_registries( # pylint: disable=inconsistent-return-statements + async def remove_droplets( self, - body: Optional[JSON] = None, + lb_id: str, + body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Remove Container Registries from Kubernetes Clusters. + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Remove Droplets from a Load Balancer. - To remove the container registries from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registries``. + To remove a Droplet from a load balancer instance, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - :param body: Default value is None. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -174102,52 +181464,93 @@ async def remove_registries( # pylint: disable=inconsistent-return-statements # JSON input template you can fill out and use as your body input. body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ], - "registries": [ - "str" # Optional. An array containing the registry names. + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets assigned + to the load balancer. ] } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ @overload - async def remove_registries( # pylint: disable=inconsistent-return-statements + async def remove_droplets( self, - body: Optional[IO[bytes]] = None, + lb_id: str, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Remove Container Registries from Kubernetes Clusters. + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Remove Droplets from a Load Balancer. - To remove the container registries from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registries``. + To remove a Droplet from a load balancer instance, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - :param body: Default value is None. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ @distributed_trace_async - async def remove_registries( # pylint: disable=inconsistent-return-statements - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> None: - """Remove Container Registries from Kubernetes Clusters. + async def remove_droplets( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Remove Droplets from a Load Balancer. - To remove the container registries from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registries``. + To remove a Droplet from a load balancer instance, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: None - :rtype: None + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -174155,14 +181558,23 @@ async def remove_registries( # pylint: disable=inconsistent-return-statements # JSON input template you can fill out and use as your body input. body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ], - "registries": [ - "str" # Optional. An array containing the registry names. + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets assigned + to the load balancer. ] } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -174183,7 +181595,7 @@ async def remove_registries( # pylint: disable=inconsistent-return-statements content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -174191,12 +181603,10 @@ async def remove_registries( # pylint: disable=inconsistent-return-statements if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = body - else: - _json = None + _json = body - _request = build_kubernetes_remove_registries_request( + _request = build_load_balancers_remove_droplets_request( + lb_id=lb_id, content_type=content_type, json=_json, content=_content, @@ -174214,64 +181624,235 @@ async def remove_registries( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [204, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - @distributed_trace_async - async def get_status_messages( + return deserialized # type: ignore + + @overload + async def add_forwarding_rules( self, - cluster_id: str, + lb_id: str, + body: JSON, *, - since: Optional[datetime.datetime] = None, + content_type: str = "application/json", **kwargs: Any - ) -> JSON: + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Fetch Status Messages for a Kubernetes Cluster. + """Add Forwarding Rules to a Load Balancer. - To retrieve status messages for a Kubernetes cluster, send a GET request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/status_messages``. Status messages inform users of - any issues that come up during the cluster lifecycle. + To add an additional forwarding rule to a load balancer instance, send a POST + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body + of the request, there should be a ``forwarding_rules`` attribute containing an + array of rules to be added. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :keyword since: A timestamp used to return status messages emitted since the specified time. - The timestamp should be in ISO8601 format. Default value is None. - :paramtype since: ~datetime.datetime - :return: JSON object - :rtype: JSON + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 + # JSON input template you can fill out and use as your body input. + body = { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port on which + the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for traffic to + the load balancer. The possible values are: ``http``"" , ``https``"" , + ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the + ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to + ``udp``. When using UDP, the load balancer requires that you set up a + health check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing the port on the + backend Droplets to which the load balancer will send traffic. Required. + "target_protocol": "str", # The protocol used for traffic + from the load balancer to the backend Droplets. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you + set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be + set to ``udp``. When using UDP, the load balancer requires that you set + up a health check with a port that uses TCP, HTTP, or HTTPS to work + properly. Required. Known values are: "http", "https", "http2", "tcp", + and "udp". + "certificate_id": "str", # Optional. The ID of the TLS + certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to the + backend Droplets. + } + ] + } + + # response body for status code(s): 404 response == { - "messages": [ + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def add_forwarding_rules( + self, + lb_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Add Forwarding Rules to a Load Balancer. + + To add an additional forwarding rule to a load balancer instance, send a POST + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body + of the request, there should be a ``forwarding_rules`` attribute containing an + array of rules to be added. + + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def add_forwarding_rules( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Add Forwarding Rules to a Load Balancer. + + To add an additional forwarding rule to a load balancer instance, send a POST + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body + of the request, there should be a ``forwarding_rules`` attribute containing an + array of rules to be added. + + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "forwarding_rules": [ { - "message": "str", # Optional. Status information about the - cluster which impacts it's lifecycle. - "timestamp": "2020-02-20 00:00:00" # Optional. A timestamp - in ISO8601 format that represents when the status message was emitted. + "entry_port": 0, # An integer representing the port on which + the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for traffic to + the load balancer. The possible values are: ``http``"" , ``https``"" , + ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the + ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to + ``udp``. When using UDP, the load balancer requires that you set up a + health check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing the port on the + backend Droplets to which the load balancer will send traffic. Required. + "target_protocol": "str", # The protocol used for traffic + from the load balancer to the backend Droplets. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you + set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be + set to ``udp``. When using UDP, the load balancer requires that you set + up a health check with a port that uses TCP, HTTP, or HTTPS to work + properly. Required. Known values are: "http", "https", "http2", "tcp", + and "udp". + "certificate_id": "str", # Optional. The ID of the TLS + certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to the + backend Droplets. } ] } + # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -174297,14 +181878,27 @@ async def get_status_messages( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_get_status_messages_request( - cluster_id=cluster_id, - since=since, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_load_balancers_add_forwarding_rules_request( + lb_id=lb_id, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -174319,14 +181913,15 @@ async def get_status_messages( response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [204, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - if response.status_code == 200: + if response.status_code == 204: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -174337,11 +181932,6 @@ async def get_status_messages( "int", response.headers.get("ratelimit-reset") ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -174359,781 +181949,209 @@ async def get_status_messages( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore - - -class LoadBalancersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~pydo.aio.GeneratedClient`'s - :attr:`load_balancers` attribute. - """ + return cls(pipeline_response, deserialized, response_headers) # type: ignore - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = ( - input_args.pop(0) if input_args else kwargs.pop("deserializer") - ) + return deserialized # type: ignore @overload - async def create( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> JSON: + async def remove_forwarding_rules( + self, + lb_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Create a New Load Balancer. - - To create a new load balancer instance, send a POST request to - ``/v2/load_balancers``. - - You can specify the Droplets that will sit behind the load balancer using one - of two methods: - + """Remove Forwarding Rules from a Load Balancer. - * Set ``droplet_ids`` to a list of specific Droplet IDs. - * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be - assigned to the load balancer. Additional Droplets will be automatically - assigned as they are tagged. + To remove forwarding rules from a load balancer instance, send a DELETE + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the + body of the request, there should be a ``forwarding_rules`` attribute containing + an array of rules to be removed. - These methods are mutually exclusive. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python # JSON input template you can fill out and use as your body input. - body = {} - - # response body for status code(s): 202 - response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } - } - """ - - @overload - async def create( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Create a New Load Balancer. - - To create a new load balancer instance, send a POST request to - ``/v2/load_balancers``. - - You can specify the Droplets that will sit behind the load balancer using one - of two methods: - - - * Set ``droplet_ids`` to a list of specific Droplet IDs. - * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be - assigned to the load balancer. Additional Droplets will be automatically - assigned as they are tagged. - - These methods are mutually exclusive. - - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } + body = { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port on which + the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for traffic to + the load balancer. The possible values are: ``http``"" , ``https``"" , + ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the + ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to + ``udp``. When using UDP, the load balancer requires that you set up a + health check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing the port on the + backend Droplets to which the load balancer will send traffic. Required. + "target_protocol": "str", # The protocol used for traffic + from the load balancer to the backend Droplets. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you + set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be + set to ``udp``. When using UDP, the load balancer requires that you set + up a health check with a port that uses TCP, HTTP, or HTTPS to work + properly. Required. Known values are: "http", "https", "http2", "tcp", + and "udp". + "certificate_id": "str", # Optional. The ID of the TLS + certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to the + backend Droplets. + } + ] + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. } """ - @distributed_trace_async - async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + @overload + async def remove_forwarding_rules( + self, + lb_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Create a New Load Balancer. + """Remove Forwarding Rules from a Load Balancer. - To create a new load balancer instance, send a POST request to - ``/v2/load_balancers``. + To remove forwarding rules from a load balancer instance, send a DELETE + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the + body of the request, there should be a ``forwarding_rules`` attribute containing + an array of rules to be removed. - You can specify the Droplets that will sit behind the load balancer using one - of two methods: + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: - * Set ``droplet_ids`` to a list of specific Droplet IDs. - * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be - assigned to the load balancer. Additional Droplets will be automatically - assigned as they are tagged. + Example: + .. code-block:: python - These methods are mutually exclusive. + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def remove_forwarding_rules( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Remove Forwarding Rules from a Load Balancer. + + To remove forwarding rules from a load balancer instance, send a DELETE + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the + body of the request, there should be a ``forwarding_rules`` attribute containing + an array of rules to be removed. + + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python # JSON input template you can fill out and use as your body input. - body = {} + body = { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port on which + the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for traffic to + the load balancer. The possible values are: ``http``"" , ``https``"" , + ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the + ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to + ``udp``. When using UDP, the load balancer requires that you set up a + health check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing the port on the + backend Droplets to which the load balancer will send traffic. Required. + "target_protocol": "str", # The protocol used for traffic + from the load balancer to the backend Droplets. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you + set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be + set to ``udp``. When using UDP, the load balancer requires that you set + up a health check with a port that uses TCP, HTTP, or HTTPS to work + properly. Required. Known values are: "http", "https", "http2", "tcp", + and "udp". + "certificate_id": "str", # Optional. The ID of the TLS + certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to the + backend Droplets. + } + ] + } - # response body for status code(s): 202 + # response body for status code(s): 404 response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -175155,7 +182173,7 @@ async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -175165,7 +182183,8 @@ async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: else: _json = body - _request = build_load_balancers_create_request( + _request = build_load_balancers_remove_forwarding_rules_request( + lb_id=lb_id, content_type=content_type, json=_json, content=_content, @@ -175183,45 +182202,95 @@ async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [204, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return deserialized # type: ignore + + +class MicrovmsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`microvms` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) @distributed_trace_async - async def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: + async def list( + self, + *, + page: int = 1, + per_page: int = 25, + region: Optional[str] = None, + name: Optional[str] = None, + tag_name: Optional[str] = None, + **kwargs: Any + ) -> JSON: # pylint: disable=line-too-long - """List All Load Balancers. + """List all MicroVMs. - To list all of the load balancer instances on your account, send a GET request - to ``/v2/load_balancers``. + To list all of the MicroVMs on your team, send a GET request to ``/v2/microvms``. + + The ``region``\\ , ``name``\\ , and ``tag_name`` filters combine with AND. - :keyword per_page: Number of items returned per page. Default value is 20. - :paramtype per_page: int :keyword page: Which 'page' of paginated results to return. Default value is 1. :paramtype page: int + :keyword per_page: Number of items returned per page. Default value is 25. + :paramtype per_page: int + :keyword region: Only return MicroVMs in this region. Default value is None. + :paramtype region: str + :keyword name: Only return the MicroVM with this exact name. Default value is None. + :paramtype name: str + :keyword tag_name: Only return MicroVMs with this tag. A tag that matches no MicroVMs returns + an empty list. Default value is None. + :paramtype tag_name: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -175237,231 +182306,83 @@ async def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSO "links": { "pages": {} }, - "load_balancers": [ + "microvms": [ { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing - the port on which the load balancer instance will listen. - Required. - "entry_protocol": "str", # The protocol used - for traffic to the load balancer. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" - , or ``udp``. If you set the ``entry_protocol`` to ``udp``"" , - the ``target_protocol`` must be set to ``udp``. When using UDP, - the load balancer requires that you set up a health check with a - port that uses TCP, HTTP, or HTTPS to work properly. Required. - Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing - the port on the backend Droplets to which the load balancer will - send traffic. Required. - "target_protocol": "str", # The protocol - used for traffic from the load balancer to the backend Droplets. - The possible values are: ``http``"" , ``https``"" , ``http2``"" , - ``tcp``"" , or ``udp``. If you set the ``target_protocol`` to - ``udp``"" , the ``entry_protocol`` must be set to ``udp``. When - using UDP, the load balancer requires that you set up a health - check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "tcp", and - "udp". - "certificate_id": "str", # Optional. The ID - of the TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A - boolean value indicating whether SSL encrypted traffic will be - passed through to the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify - an algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the load balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. - Default value is False. A boolean value indicating whether to disable - automatic DNS record creation for Let's Encrypt certificates that are - added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID - of the TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean - value indicating if the domain is already managed by - DigitalOcean. If true, all A and AAAA records required to enable - Global load balancers will be automatically added. - "name": "str" # Optional. FQDN to associate - with a Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the - Droplets assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value - is False. A boolean value indicating whether HTTP keepalive connections - are maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is - False. A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing - traffic to the load balancer (in the form 'ip:1.2.3.4' or - 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying - traffic to the load balancer (in the form 'ip:1.2.3.4' or - 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean - flag to enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer - value as a percentage to indicate failure threshold to decide how the - regional priorities will take effect. A value of ``50`` would - indicate that the Global load balancer will choose a lower priority - region to forward traffic to once this failure threshold has been - reached for the higher priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string - to an integer priority value indicating preference for which - regional target a Global load balancer will forward traffic to. A - lower value indicates a higher priority. - }, - "target_port": 0, # Optional. An integer - representing the port on the target backends which the load balancer - will forward traffic to. - "target_protocol": "str" # Optional. The protocol - used for forwarding traffic from the load balancer to the target - backends. The possible values are ``http``"" , ``https`` and - ``http2``. Known values are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default - value is 10. The number of seconds between between two consecutive - health checks. - "healthy_threshold": 3, # Optional. Default value is - 3. The number of times a health check must pass for a backend Droplet - to be marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The - path on the backend Droplets to which the load balancer instance will - send a request. - "port": 80, # Optional. Default value is 80. An - integer representing the port on the backend Droplets on which the - health check will attempt a connection. - "protocol": "http", # Optional. Default value is - "http". The protocol used for health checks sent to the backend - Droplets. The possible values are ``http``"" , ``https``"" , or - ``tcp``. Known values are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default - value is 5. The number of seconds the load balancer instance will - wait for a response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value - is 5. The number of times a health check must fail for a backend - Droplet to be marked "unhealthy" and be removed from the pool. + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is + on. Always ``true``. + "idle_timeout": "str" # Optional. How long the + MicroVM is idle before it pauses, as a duration such as ``30s``"" , + ``5m``"" , or ``1h``. Defaults to ``5m``. The maximum is ``4h``. + Responses show the duration in the form ``5m0s``. }, - "http_idle_timeout_seconds": 60, # Optional. Default value - is 60. An integer value which configures the idle timeout for HTTP - requests to the target droplets. - "id": "str", # Optional. A unique ID that can be used to - identify and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the - public-facing IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load - balancer instance. - "network": "EXTERNAL", # Optional. Default value is - "EXTERNAL". A string indicating whether the load balancer should be - external or internal. Internal load balancers have no public IPs and are - only accessible to resources on the same VPC network. This property - cannot be updated after creating the load balancer. Known values are: - "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is - "IPV4". A string indicating whether the load balancer will support IPv4 - or both IPv4 and IPv6 networking. This property cannot be updated after - creating the load balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that - the load balancer is associated with. If no ID is provided at creation, - the load balancer associates with the user's default project. If an - invalid project ID is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value - is False. A boolean value indicating whether HTTP requests to the load - balancer on port 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that - represents whether new Droplets can be created in this region. + "auto_resume": True, # Optional. Default value is True. + Whether an HTTP request, command, or console session resumes the MicroVM + when it is paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the + MicroVM was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. + Present only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the + MicroVM's HTTP port serves. ``null`` if the protocol was not set when the + MicroVM was created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be + unique in the region and contain 1 to 63 lowercase letters, digits, and + hyphens. + "networking": "public", # Optional. Default value is + "public". ``public`` sends outbound traffic through a shared NAT gateway. + ``vpc`` places the MicroVM in the VPC network set by ``vpc_uuid``. Known + values are: "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the + MicroVM, including the HTTP port. During the public preview, only the + HTTP port is reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the + MicroVM is in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. - "features": [ - "str" # This attribute is set to an array - which contains features available in this region. Required. - ], - "name": "str", # The display name of the region. - This will be a full name that is used in the control panel and other - interfaces. Required. - "sizes": [ - "str" # This attribute is set to an array - which contains the identifying slugs for the sizes available in - this region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used - as a unique identifier for each region. Required. + "disk": 0 # Optional. The size of the disk, in GB. + Set by the size. }, - "size": "lb-small", # Optional. Default value is "lb-small". - This field has been replaced by the ``size_unit`` field for all regions - except in AMS2, NYC2, and SFO1. Each available load balancer size now - equates to the load balancer having a set number of nodes. * - ``lb-small`` = 1 node * ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes - You can resize load balancers after creation up to once per hour. You - cannot resize a load balancer within the first hour of its creation. - Known values are: "lb-small", "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many - nodes the load balancer contains. Each additional node increases the load - balancer's ability to manage more connections. Load balancers can be - scaled up or down, and you can change the number of nodes after creation - up to once per hour. This field is currently not available in the AMS2, - NYC2, or SFO1 regions. Use the ``size`` field to scale load balancers - that reside in these regions. - "status": "str", # Optional. A status string indicating the - current state of the load balancer. This can be ``new``"" , ``active``"" - , or ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the - cookie sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of - seconds until the cookie set by the load balancer expires. This - attribute is only returned when using ``cookies`` for the sticky - sessions type. - "type": "none" # Optional. Default value is "none". - An attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values - are ``cookies`` or ``none``. Known values are: "cookies" and "none". + "source": { + "checkpoint_id": "str", # Optional. The ID of a + checkpoint to create the MicroVM from. The new MicroVM inherits the + checkpoint's region, size, container image, and environment + variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form + ``registry/repository:tag``. The image can be public, such as an + image on Docker Hub, or private in your team's DigitalOcean Container + Registry. }, - "subnet_uuid": "str", # Optional. A string specifying the - UUID of the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag - corresponding to Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of - the Regional load balancers to be used as target backends for a - Global load balancer. + "state": "str", # Optional. The MicroVM's current state. + Known values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used - by the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. - The default value is ``DEFAULT``. Known values are: "DEFAULT" and - "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". - A string indicating whether the load balancer should be a standard - regional HTTP load balancer, a regional network load balancer that routes - traffic at the TCP/UDP transport layer, or a global load balancer. Known - values are: "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID - of the VPC to which the load balancer is assigned. + "urls": [ + { + "default": bool, # Optional. Whether this is + the endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The + endpoint's hostname. Empty until provisioning finishes. Requests + to the endpoint must include a DigitalOcean API token with the + ``microvm:access`` scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the + endpoint serves. + "status": "str" # Optional. ``PENDING`` + until provisioning finishes, then ``ACTIVE``. Known values are: + "PENDING" and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the + same region that belongs to your team. Present only when ``networking`` + is ``vpc``. } ] } @@ -175484,9 +182405,12 @@ async def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSO cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_load_balancers_list_request( - per_page=per_page, + _request = build_microvms_list_request( page=page, + per_page=per_page, + region=region, + name=name, + tag_name=tag_name, headers=_headers, params=_params, ) @@ -175528,16 +182452,30 @@ async def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSO return cast(JSON, deserialized) # type: ignore - @distributed_trace_async - async def get(self, lb_id: str, **kwargs: Any) -> JSON: + @overload + async def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: # pylint: disable=line-too-long - """Retrieve an Existing Load Balancer. + """Create a MicroVM. - To show information about a load balancer instance, send a GET request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. + To create a MicroVM, send a POST request to ``/v2/microvms``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + ``name`` and ``source`` are required. Set ``source.oci_ref`` to create the MicroVM from a + ``linux/amd64`` container image, or ``source.checkpoint_id`` to create it from a checkpoint. + With ``oci_ref``\\ , ``region`` and ``size`` are also required. + + A MicroVM created from an image is returned with ``state`` set to ``creating``. Poll + ``GET /v2/microvms/{microvm_id}`` until ``state`` is ``running``. A MicroVM created from a + checkpoint is usually returned already ``running``. + + All settings are fixed at creation. There is no update endpoint. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -175545,232 +182483,421 @@ async def get(self, lb_id: str, **kwargs: Any) -> JSON: Example: .. code-block:: python - # response body for status code(s): 200 + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # The name of the MicroVM. Must be unique in the region and + contain 1 to 63 lowercase letters, digits, and hyphens. Required. + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint to create + the MicroVM from. The new MicroVM inherits the checkpoint's region, size, + container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a ``linux/amd64`` + container image in the form ``registry/repository:tag``. The image can be + public, such as an image on Docker Hub, or private in your team's + DigitalOcean Container Registry. + }, + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. Always + ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is idle + before it pauses, as a duration such as ``30s``"" , ``5m``"" , or ``1h``. + Defaults to ``5m``. The maximum is ``4h``. Responses show the duration in the + form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an HTTP + request, command, or console session resumes the MicroVM when it is paused. Set + to ``false`` to require a manual resume. + "environment": { + "str": "str" # Optional. Environment variables passed into the + MicroVM at boot, as key and value pairs. Not returned in responses. + }, + "http_port": 8080, # Optional. Default value is 8080. The guest port the + workload serves HTTP on. Defaults to ``8080``. Not returned in responses. When + creating from a checkpoint without ``ports``"" , must be one of the checkpoint's + ports. + "http_protocol": "str", # Optional. The protocol the HTTP port serves. Known + values are: "http" and "http2". + "networking": "public", # Optional. Default value is "public". ``public`` + sends outbound traffic through a shared NAT gateway. ``vpc`` places the MicroVM + in the VPC network set by ``vpc_uuid``. Known values are: "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports to declare, up to five. Must include + ``http_port``. Defaults to only the HTTP port. During the public preview, + only the HTTP port is reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region to create the MicroVM + in. Required with ``source.oci_ref``. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by the size. + }, + "tags": [ + "str" # Optional. Tags to apply to the MicroVM. + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same region + that belongs to your team. Required when ``networking`` is ``vpc``. + } + + # response body for status code(s): 201 response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. + }, + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. + ], + "urls": [ { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". } ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. + } + } + # response body for status code(s): 400, 403 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. + } + """ + + @overload + async def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a MicroVM. + + To create a MicroVM, send a POST request to ``/v2/microvms``. + + ``name`` and ``source`` are required. Set ``source.oci_ref`` to create the MicroVM from a + ``linux/amd64`` container image, or ``source.checkpoint_id`` to create it from a checkpoint. + With ``oci_ref``\\ , ``region`` and ``size`` are also required. + + A MicroVM created from an image is returned with ``state`` set to ``creating``. Poll + ``GET /v2/microvms/{microvm_id}`` until ``state`` is ``running``. A MicroVM created from a + checkpoint is usually returned already ``running``. + + All settings are fixed at creation. There is no update endpoint. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. + ], + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. + } + } + # response body for status code(s): 400, 403 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. + } + """ + + @distributed_trace_async + async def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create a MicroVM. + + To create a MicroVM, send a POST request to ``/v2/microvms``. + + ``name`` and ``source`` are required. Set ``source.oci_ref`` to create the MicroVM from a + ``linux/amd64`` container image, or ``source.checkpoint_id`` to create it from a checkpoint. + With ``oci_ref``\\ , ``region`` and ``size`` are also required. + + A MicroVM created from an image is returned with ``state`` set to ``creating``. Poll + ``GET /v2/microvms/{microvm_id}`` until ``state`` is ``running``. A MicroVM created from a + checkpoint is usually returned already ``running``. + + All settings are fixed at creation. There is no update endpoint. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # The name of the MicroVM. Must be unique in the region and + contain 1 to 63 lowercase letters, digits, and hyphens. Required. + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint to create + the MicroVM from. The new MicroVM inherits the checkpoint's region, size, + container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a ``linux/amd64`` + container image in the form ``registry/repository:tag``. The image can be + public, such as an image on Docker Hub, or private in your team's + DigitalOcean Container Registry. + }, + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. Always + ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is idle + before it pauses, as a duration such as ``30s``"" , ``5m``"" , or ``1h``. + Defaults to ``5m``. The maximum is ``4h``. Responses show the duration in the + form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an HTTP + request, command, or console session resumes the MicroVM when it is paused. Set + to ``false`` to require a manual resume. + "environment": { + "str": "str" # Optional. Environment variables passed into the + MicroVM at boot, as key and value pairs. Not returned in responses. + }, + "http_port": 8080, # Optional. Default value is 8080. The guest port the + workload serves HTTP on. Defaults to ``8080``. Not returned in responses. When + creating from a checkpoint without ``ports``"" , must be one of the checkpoint's + ports. + "http_protocol": "str", # Optional. The protocol the HTTP port serves. Known + values are: "http" and "http2". + "networking": "public", # Optional. Default value is "public". ``public`` + sends outbound traffic through a shared NAT gateway. ``vpc`` places the MicroVM + in the VPC network set by ``vpc_uuid``. Known values are: "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports to declare, up to five. Must include + ``http_port``. Defaults to only the HTTP port. During the public preview, + only the HTTP port is reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region to create the MicroVM + in. Required with ``source.oci_ref``. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by the size. + }, + "tags": [ + "str" # Optional. Tags to apply to the MicroVM. + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same region + that belongs to your team. Required when ``networking`` is ``vpc``. + } + + # response body for status code(s): 201 + response == { + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. } } - # response body for status code(s): 404 + # response body for status code(s): 400, 403 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -175786,13 +182913,26 @@ async def get(self, lb_id: str, **kwargs: Any) -> JSON: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_load_balancers_get_request( - lb_id=lb_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_microvms_create_request( + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -175807,14 +182947,14 @@ async def get(self, lb_id: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [201, 400, 403]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: + if response.status_code == 201: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -175830,7 +182970,23 @@ async def get(self, lb_id: str, **kwargs: Any) -> JSON: else: deserialized = None - if response.status_code == 404: + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -175851,32 +183007,13 @@ async def get(self, lb_id: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore - @overload - async def update( - self, - lb_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Update a Load Balancer. + @distributed_trace_async + async def get_options(self, **kwargs: Any) -> JSON: + """List MicroVM options. - To update a load balancer's settings, send a PUT request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full - representation of the load balancer including existing attributes. It may - contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually - exclusive. **Note that any attribute that is not provided will be reset to its - default value.**. + To list the default region, sizes, prices, account limits, and features available to + your team, send a GET request to ``/v2/microvms/options``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -175884,518 +183021,130 @@ async def update( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = {} - # response body for status code(s): 200 response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. + "account_limits": { + "max_disk_bytes": 0, # Optional. The maximum disk per MicroVM, in + bytes. + "max_idle_timeout_seconds": 0, # Optional. The maximum auto-pause + idle timeout, in seconds. + "max_memory_bytes": 0, # Optional. The maximum memory per MicroVM, + in bytes. + "max_total_count": 0 # Optional. The maximum number of MicroVMs, + counting both running and paused MicroVMs. + }, + "default_region": "str", # Optional. The slug of the region MicroVMs are + created in by default. + "features": [ + { + "enabled": bool, # Optional. Whether the feature is enabled. + "name": "str" # Optional. The name of the feature. + } + ], + "resource_pricing": { + "price_per_gib_bandwidth": 0.0, # Optional. The price per GiB of + outbound data transfer. + "price_per_gib_memory_hour": 0.0, # Optional. The price per GiB of + memory per hour of running time. + "price_per_gib_storage_month": 0.0, # Optional. The price per + GiB-month of disk and checkpoint storage. + "price_per_vcpu_hour": 0.0 # Optional. The price per vCPU per hour + of running time. + }, + "sizes": [ + { + "available": bool, # Optional. Whether the size is available + on your team's plan. + "cpu": 0, # Optional. The number of vCPUs. + "disk": 0, # Optional. The size of the disk, in GB. + "memory": 0, # Optional. The amount of memory, in MiB. + "pricing": { + "price_per_hour": 0.0, # Optional. The price per + hour of running time, in USD. + "price_per_month": 0.0 # Optional. The price for + running continuously for a month (730 hours), in USD. }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "regions": [ + "str" # Optional. The slugs of the regions the size + is available in. + ] + } + ] } """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def update( - self, - lb_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Update a Load Balancer. + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - To update a load balancer's settings, send a PUT request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full - representation of the load balancer including existing attributes. It may - contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually - exclusive. **Note that any attribute that is not provided will be reset to its - default value.**. + cls: ClsType[JSON] = kwargs.pop("cls", None) - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: + _request = build_microvms_get_options_request( + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - Example: - .. code-block:: python + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) - # response body for status code(s): 200 - response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def update( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> JSON: + async def get(self, microvm_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Update a Load Balancer. + """Retrieve a MicroVM. - To update a load balancer's settings, send a PUT request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full - representation of the load balancer including existing attributes. It may - contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually - exclusive. **Note that any attribute that is not provided will be reset to its - default value.**. + To show information about a MicroVM, send a GET request to ``/v2/microvms/{microvm_id}``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] + The endpoint is in the ``urls`` entry with ``default`` set to ``true``. Its ``hostname`` is + empty + and its ``status`` is ``PENDING`` until provisioning finishes. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -176403,235 +183152,86 @@ async def update( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = {} - # response body for status code(s): 200 response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. } } # response body for status code(s): 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -176647,27 +183247,13 @@ async def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) cls: ClsType[JSON] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_load_balancers_update_request( - lb_id=lb_id, - content_type=content_type, - json=_json, - content=_content, + _request = build_microvms_get_request( + microvm_id=microvm_id, headers=_headers, params=_params, ) @@ -176727,19 +183313,16 @@ async def update( return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: - # pylint: disable=line-too-long - """Delete a Load Balancer. + async def delete(self, microvm_id: str, **kwargs: Any) -> Optional[JSON]: + """Delete a MicroVM. - To delete a load balancer instance, disassociating any Droplets assigned to it - and removing it from your account, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. + To delete a MicroVM and the data on its disk, send a DELETE request to + ``/v2/microvms/{microvm_id}``. The MicroVM's checkpoints are not deleted. - A successful request will receive a 204 status code with no body in response. - This indicates that the request was processed successfully. + A successful request returns a ``204 No Content`` status code. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :return: JSON object or None :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: @@ -176749,14 +183332,8 @@ async def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: # response body for status code(s): 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -176777,8 +183354,8 @@ async def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_load_balancers_delete_request( - lb_id=lb_id, + _request = build_microvms_delete_request( + microvm_id=microvm_id, headers=_headers, params=_params, ) @@ -176834,35 +183411,303 @@ async def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: return deserialized # type: ignore @distributed_trace_async - async def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: + async def post_pause(self, microvm_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Delete a Global Load Balancer CDN Cache. + """Pause a MicroVM. - To delete a Global load balancer CDN cache, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/cache``. + To pause a MicroVM, send a POST request to ``/v2/microvms/{microvm_id}/pause``. + + Pausing suspends the MicroVM's processes and preserves its memory, files, and processes. + A paused MicroVM incurs storage charges only. The request returns when the change + completes. Pausing a MicroVM that is already paused succeeds. The request returns HTTP 400 + when the MicroVM is ``creating``\\ , ``terminated``\\ , or ``failed``. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. + }, + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. + ], + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_microvms_post_pause_request( + microvm_id=microvm_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def post_resume(self, microvm_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Resume a MicroVM. + + To resume a paused MicroVM, send a POST request to ``/v2/microvms/{microvm_id}/resume``. - A successful request will receive a 204 status code with no body in response. - This indicates that the request was processed successfully. + The request returns when the change completes. Resuming a MicroVM that is already running + succeeds. The request returns HTTP 400 when the MicroVM is ``creating``\\ , ``terminated``\\ , + or + ``failed``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :return: JSON object or None - :rtype: JSON or None + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. + }, + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. + ], + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -176881,10 +183726,10 @@ async def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_load_balancers_delete_cache_request( - lb_id=lb_id, + _request = build_microvms_post_resume_request( + microvm_id=microvm_id, headers=_headers, params=_params, ) @@ -176899,15 +183744,30 @@ async def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [200, 400, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -176918,6 +183778,11 @@ async def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -176935,42 +183800,39 @@ async def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @overload - async def add_droplets( + async def run_command( self, - lb_id: str, + microvm_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Droplets to a Load Balancer. + ) -> JSON: + """Run a command in a MicroVM. - To assign a Droplet to a load balancer instance, send a POST request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - Individual Droplets can not be added to a load balancer configured with a - Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" - response from the API. + To run a command in a MicroVM's workload container, send a POST request to + ``/v2/microvms/{microvm_id}/exec``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + ``argv`` runs directly, not through a shell, with standard input closed. If the MicroVM is + paused and auto-resume is on, the request resumes it and waits until it is running. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + A command has 60 seconds to finish. Your team can run 32 commands at once and 60 commands + per minute. Rejected requests count toward the per-minute limit. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -176978,99 +183840,101 @@ async def add_droplets( # JSON input template you can fill out and use as your body input. body = { - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets assigned - to the load balancer. - ] + "argv": [ + "str" # The command and its arguments. Required. + ], + "cwd": "str" # Optional. The working directory to run the command in. } - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "exit_code": 0, # Optional. The command's exit code. + "stderr": "str", # Optional. The command's standard error. Bytes that are + not valid UTF-8 are replaced. + "stdout": "str", # Optional. The command's standard output. Bytes that are + not valid UTF-8 are replaced. + "truncated": bool # Optional. Present and ``true`` when the output exceeded + 4 MiB and was cut off. + } + # response body for status code(s): 400, 403, 404, 502 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ @overload - async def add_droplets( + async def run_command( self, - lb_id: str, + microvm_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Droplets to a Load Balancer. + ) -> JSON: + """Run a command in a MicroVM. - To assign a Droplet to a load balancer instance, send a POST request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - Individual Droplets can not be added to a load balancer configured with a - Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" - response from the API. + To run a command in a MicroVM's workload container, send a POST request to + ``/v2/microvms/{microvm_id}/exec``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + ``argv`` runs directly, not through a shell, with standard input closed. If the MicroVM is + paused and auto-resume is on, the request resumes it and waits until it is running. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + A command has 60 seconds to finish. Your team can run 32 commands at once and 60 commands + per minute. Rejected requests count toward the per-minute limit. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "exit_code": 0, # Optional. The command's exit code. + "stderr": "str", # Optional. The command's standard error. Bytes that are + not valid UTF-8 are replaced. + "stdout": "str", # Optional. The command's standard output. Bytes that are + not valid UTF-8 are replaced. + "truncated": bool # Optional. Present and ``true`` when the output exceeded + 4 MiB and was cut off. + } + # response body for status code(s): 400, 403, 404, 502 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ @distributed_trace_async - async def add_droplets( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Droplets to a Load Balancer. + async def run_command( + self, microvm_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + """Run a command in a MicroVM. - To assign a Droplet to a load balancer instance, send a POST request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - Individual Droplets can not be added to a load balancer configured with a - Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" - response from the API. + To run a command in a MicroVM's workload container, send a POST request to + ``/v2/microvms/{microvm_id}/exec``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + ``argv`` runs directly, not through a shell, with standard input closed. If the MicroVM is + paused and auto-resume is on, the request resumes it and waits until it is running. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + A command has 60 seconds to finish. Your team can run 32 commands at once and 60 commands + per minute. Rejected requests count toward the per-minute limit. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -177078,22 +183942,26 @@ async def add_droplets( # JSON input template you can fill out and use as your body input. body = { - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets assigned - to the load balancer. - ] + "argv": [ + "str" # The command and its arguments. Required. + ], + "cwd": "str" # Optional. The working directory to run the command in. } - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "exit_code": 0, # Optional. The command's exit code. + "stderr": "str", # Optional. The command's standard error. Bytes that are + not valid UTF-8 are replaced. + "stdout": "str", # Optional. The command's standard output. Bytes that are + not valid UTF-8 are replaced. + "truncated": bool # Optional. Present and ``true`` when the output exceeded + 4 MiB and was cut off. + } + # response body for status code(s): 400, 403, 404, 502 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -177115,7 +183983,7 @@ async def add_droplets( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -177125,8 +183993,8 @@ async def add_droplets( else: _json = body - _request = build_load_balancers_add_droplets_request( - lb_id=lb_id, + _request = build_microvms_run_command_request( + microvm_id=microvm_id, content_type=content_type, json=_json, content=_content, @@ -177144,15 +184012,14 @@ async def add_droplets( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [200, 400, 403, 404, 502]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -177163,7 +184030,12 @@ async def add_droplets( "int", response.headers.get("ratelimit-reset") ) - if response.status_code == 404: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -177179,132 +184051,79 @@ async def add_droplets( else: deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def remove_droplets( - self, - lb_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Remove Droplets from a Load Balancer. - - To remove a Droplet from a load balancer instance, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. - - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets assigned - to the load balancer. - ] - } + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ + if response.content: + deserialized = response.json() + else: + deserialized = None - @overload - async def remove_droplets( - self, - lb_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Remove Droplets from a Load Balancer. + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - To remove a Droplet from a load balancer instance, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. + if response.content: + deserialized = response.json() + else: + deserialized = None - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + if response.status_code == 502: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None - :raises ~azure.core.exceptions.HttpResponseError: + if response.content: + deserialized = response.json() + else: + deserialized = None - Example: - .. code-block:: python + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ + return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def remove_droplets( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + async def get_console( + self, microvm_id: str, *, rows: int = 24, cols: int = 80, **kwargs: Any ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Remove Droplets from a Load Balancer. - - To remove a Droplet from a load balancer instance, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. - - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] + """Open a console in a MicroVM. + + To open an interactive ``/bin/sh`` console in a MicroVM's workload container, open a + WebSocket connection to ``wss://api.digitalocean.com/v2/microvms/{microvm_id}/console``. + + Send the API token in the ``Authorization`` header of the handshake. Browsers cannot set this + header, so you cannot open the console from browser JavaScript. The image must include + ``/bin/sh``. A MicroVM can have four consoles open at a time. If the MicroVM is paused and + auto-resume is on, opening a console resumes it. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :keyword rows: The initial number of terminal rows. Default value is 24. + :paramtype rows: int + :keyword cols: The initial number of terminal columns. Default value is 80. + :paramtype cols: int :return: JSON object or None :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: @@ -177312,24 +184131,10 @@ async def remove_droplets( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets assigned - to the load balancer. - ] - } - - # response body for status code(s): 404 + # response body for status code(s): 403, 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -177345,27 +184150,15 @@ async def remove_droplets( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_load_balancers_remove_droplets_request( - lb_id=lb_id, - content_type=content_type, - json=_json, - content=_content, + _request = build_microvms_get_console_request( + microvm_id=microvm_id, + rows=rows, + cols=cols, headers=_headers, params=_params, ) @@ -177380,7 +184173,7 @@ async def remove_droplets( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [101, 403, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore @@ -177388,7 +184181,18 @@ async def remove_droplets( deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 101: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 403: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -177399,6 +184203,11 @@ async def remove_droplets( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -177420,155 +184229,301 @@ async def remove_droplets( return deserialized # type: ignore - @overload - async def add_forwarding_rules( + +class MicrovmCheckpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`microvm_checkpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace_async + async def list( self, - lb_id: str, - body: JSON, *, - content_type: str = "application/json", + page: int = 1, + per_page: int = 25, + microvm_id: Optional[str] = None, **kwargs: Any - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Add Forwarding Rules to a Load Balancer. + """List checkpoints. - To add an additional forwarding rule to a load balancer instance, send a POST - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body - of the request, there should be a ``forwarding_rules`` attribute containing an - array of rules to be added. - - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + To list your team's checkpoints, newest first, send a GET request to + ``/v2/microvms/checkpoints``. To list one MicroVM's checkpoints, add the ``microvm_id`` query + parameter. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :keyword page: Which 'page' of paginated results to return. Default value is 1. + :paramtype page: int + :keyword per_page: Number of items returned per page. Default value is 25. + :paramtype per_page: int + :keyword microvm_id: Only return checkpoints taken from this MicroVM. Default value is None. + :paramtype microvm_id: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "forwarding_rules": [ + # response body for status code(s): 200 + response == { + "meta": { + "total": 0 # Optional. Number of objects returned by the request. + }, + "checkpoints": [ { - "entry_port": 0, # An integer representing the port on which - the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for traffic to - the load balancer. The possible values are: ``http``"" , ``https``"" , - ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the - ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to - ``udp``. When using UDP, the load balancer requires that you set up a - health check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing the port on the - backend Droplets to which the load balancer will send traffic. Required. - "target_protocol": "str", # The protocol used for traffic - from the load balancer to the backend Droplets. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you - set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be - set to ``udp``. When using UDP, the load balancer requires that you set - up a health check with a port that uses TCP, HTTP, or HTTPS to work - properly. Required. Known values are: "http", "https", "http2", "tcp", - and "udp". - "certificate_id": "str", # Optional. The ID of the TLS - certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to the - backend Droplets. + "created_at": "2020-02-20 00:00:00", # Optional. When the + checkpoint was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the + checkpoint's disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the + checkpoint's memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM + the checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If + you do not set one, a name such as ``checkpoint-20260929-143559`` is + generated. + "region": "str", # Optional. The slug of the checkpoint's + region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. + Required. + "disk": 0 # Optional. The size of the disk, in GB. + Set by the size. + }, + "status": "str" # Optional. The checkpoint's status. You can + create MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. + Known values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". } - ] - } - - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + ], + "links": { + "pages": {} + } } """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def add_forwarding_rules( - self, - lb_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Forwarding Rules to a Load Balancer. + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - To add an additional forwarding rule to a load balancer instance, send a POST - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body - of the request, there should be a ``forwarding_rules`` attribute containing an - array of rules to be added. + cls: ClsType[JSON] = kwargs.pop("cls", None) - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + _request = build_microvm_checkpoints_list_request( + page=page, + per_page=per_page, + microvm_id=microvm_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get(self, checkpoint_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve a checkpoint. + + To show information about a checkpoint, send a GET request to + ``/v2/microvms/checkpoints/{checkpoint_id}``. + + :param checkpoint_id: The unique ID of the checkpoint. Required. + :type checkpoint_id: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "checkpoint": { + "created_at": "2020-02-20 00:00:00", # Optional. When the checkpoint + was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the checkpoint's + disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the checkpoint's + memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM the + checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If you do not + set one, a name such as ``checkpoint-20260929-143559`` is generated. + "region": "str", # Optional. The slug of the checkpoint's region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "status": "str" # Optional. The checkpoint's status. You can create + MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. Known + values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". + } + } # response body for status code(s): 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_microvm_checkpoints_get_request( + checkpoint_id=checkpoint_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def add_forwarding_rules( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Forwarding Rules to a Load Balancer. + async def delete(self, checkpoint_id: str, **kwargs: Any) -> Optional[JSON]: + """Delete a checkpoint. - To add an additional forwarding rule to a load balancer instance, send a POST - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body - of the request, there should be a ``forwarding_rules`` attribute containing an - array of rules to be added. + To delete a checkpoint, send a DELETE request to ``/v2/microvms/checkpoints/{checkpoint_id}``. + You can no longer create MicroVMs from a deleted checkpoint. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + The request returns HTTP 400 while the checkpoint is still being captured. A successful + request returns a ``204 No Content`` status code. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] + :param checkpoint_id: The unique ID of the checkpoint. Required. + :type checkpoint_id: str :return: JSON object or None :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: @@ -177576,49 +184531,10 @@ async def add_forwarding_rules( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port on which - the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for traffic to - the load balancer. The possible values are: ``http``"" , ``https``"" , - ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the - ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to - ``udp``. When using UDP, the load balancer requires that you set up a - health check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing the port on the - backend Droplets to which the load balancer will send traffic. Required. - "target_protocol": "str", # The protocol used for traffic - from the load balancer to the backend Droplets. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you - set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be - set to ``udp``. When using UDP, the load balancer requires that you set - up a health check with a port that uses TCP, HTTP, or HTTPS to work - properly. Required. Known values are: "http", "https", "http2", "tcp", - and "udp". - "certificate_id": "str", # Optional. The ID of the TLS - certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to the - backend Droplets. - } - ] - } - - # response body for status code(s): 404 + # response body for status code(s): 400, 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -177634,27 +184550,13 @@ async def add_forwarding_rules( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_load_balancers_add_forwarding_rules_request( - lb_id=lb_id, - content_type=content_type, - json=_json, - content=_content, + _request = build_microvm_checkpoints_delete_request( + checkpoint_id=checkpoint_id, headers=_headers, params=_params, ) @@ -177669,7 +184571,7 @@ async def add_forwarding_rules( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [204, 400, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore @@ -177688,6 +184590,22 @@ async def add_forwarding_rules( "int", response.headers.get("ratelimit-reset") ) + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -177710,35 +184628,32 @@ async def add_forwarding_rules( return deserialized # type: ignore @overload - async def remove_forwarding_rules( + async def create( self, - lb_id: str, - body: JSON, + microvm_id: str, + body: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Remove Forwarding Rules from a Load Balancer. + """Create a checkpoint of a MicroVM. - To remove forwarding rules from a load balancer instance, send a DELETE - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the - body of the request, there should be a ``forwarding_rules`` attribute containing - an array of rules to be removed. + To create a checkpoint of a running or paused MicroVM, send a POST request to + ``/v2/microvms/{microvm_id}/checkpoints``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + The capture runs in the background and does not change the MicroVM's state. Poll + ``GET /v2/microvms/checkpoints/{checkpoint_id}`` until ``status`` is ``CHECKPOINT_AVAILABLE``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :param body: Default value is None. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -177746,120 +184661,136 @@ async def remove_forwarding_rules( # JSON input template you can fill out and use as your body input. body = { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port on which - the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for traffic to - the load balancer. The possible values are: ``http``"" , ``https``"" , - ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the - ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to - ``udp``. When using UDP, the load balancer requires that you set up a - health check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing the port on the - backend Droplets to which the load balancer will send traffic. Required. - "target_protocol": "str", # The protocol used for traffic - from the load balancer to the backend Droplets. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you - set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be - set to ``udp``. When using UDP, the load balancer requires that you set - up a health check with a port that uses TCP, HTTP, or HTTPS to work - properly. Required. Known values are: "http", "https", "http2", "tcp", - and "udp". - "certificate_id": "str", # Optional. The ID of the TLS - certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to the - backend Droplets. - } - ] + "name": "str" # Optional. A name for the checkpoint. If you omit it, a name + such as ``checkpoint-20260929-143559`` is generated. } - # response body for status code(s): 404 + # response body for status code(s): 201 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "checkpoint": { + "created_at": "2020-02-20 00:00:00", # Optional. When the checkpoint + was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the checkpoint's + disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the checkpoint's + memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM the + checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If you do not + set one, a name such as ``checkpoint-20260929-143559`` is generated. + "region": "str", # Optional. The slug of the checkpoint's region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "status": "str" # Optional. The checkpoint's status. You can create + MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. Known + values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ @overload - async def remove_forwarding_rules( + async def create( self, - lb_id: str, - body: IO[bytes], + microvm_id: str, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Remove Forwarding Rules from a Load Balancer. + """Create a checkpoint of a MicroVM. - To remove forwarding rules from a load balancer instance, send a DELETE - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the - body of the request, there should be a ``forwarding_rules`` attribute containing - an array of rules to be removed. + To create a checkpoint of a running or paused MicroVM, send a POST request to + ``/v2/microvms/{microvm_id}/checkpoints``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + The capture runs in the background and does not change the MicroVM's state. Poll + ``GET /v2/microvms/checkpoints/{checkpoint_id}`` until ``status`` is ``CHECKPOINT_AVAILABLE``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :param body: Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 + # response body for status code(s): 201 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "checkpoint": { + "created_at": "2020-02-20 00:00:00", # Optional. When the checkpoint + was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the checkpoint's + disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the checkpoint's + memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM the + checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If you do not + set one, a name such as ``checkpoint-20260929-143559`` is generated. + "region": "str", # Optional. The slug of the checkpoint's region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "status": "str" # Optional. The checkpoint's status. You can create + MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. Known + values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ @distributed_trace_async - async def remove_forwarding_rules( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> Optional[JSON]: + async def create( + self, + microvm_id: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> JSON: # pylint: disable=line-too-long - """Remove Forwarding Rules from a Load Balancer. + """Create a checkpoint of a MicroVM. - To remove forwarding rules from a load balancer instance, send a DELETE - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the - body of the request, there should be a ``forwarding_rules`` attribute containing - an array of rules to be removed. + To create a checkpoint of a running or paused MicroVM, send a POST request to + ``/v2/microvms/{microvm_id}/checkpoints``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + The capture runs in the background and does not change the MicroVM's state. Poll + ``GET /v2/microvms/checkpoints/{checkpoint_id}`` until ``status`` is ``CHECKPOINT_AVAILABLE``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. :type body: JSON or IO[bytes] - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -177867,47 +184798,43 @@ async def remove_forwarding_rules( # JSON input template you can fill out and use as your body input. body = { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port on which - the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for traffic to - the load balancer. The possible values are: ``http``"" , ``https``"" , - ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the - ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to - ``udp``. When using UDP, the load balancer requires that you set up a - health check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing the port on the - backend Droplets to which the load balancer will send traffic. Required. - "target_protocol": "str", # The protocol used for traffic - from the load balancer to the backend Droplets. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you - set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be - set to ``udp``. When using UDP, the load balancer requires that you set - up a health check with a port that uses TCP, HTTP, or HTTPS to work - properly. Required. Known values are: "http", "https", "http2", "tcp", - and "udp". - "certificate_id": "str", # Optional. The ID of the TLS - certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to the - backend Droplets. - } - ] + "name": "str" # Optional. A name for the checkpoint. If you omit it, a name + such as ``checkpoint-20260929-143559`` is generated. } - # response body for status code(s): 404 + # response body for status code(s): 201 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "checkpoint": { + "created_at": "2020-02-20 00:00:00", # Optional. When the checkpoint + was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the checkpoint's + disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the checkpoint's + memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM the + checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If you do not + set one, a name such as ``checkpoint-20260929-143559`` is generated. + "region": "str", # Optional. The slug of the checkpoint's region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "status": "str" # Optional. The checkpoint's status. You can create + MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. Known + values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -177929,7 +184856,7 @@ async def remove_forwarding_rules( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -177937,10 +184864,13 @@ async def remove_forwarding_rules( if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + if body is not None: + _json = body + else: + _json = None - _request = build_load_balancers_remove_forwarding_rules_request( - lb_id=lb_id, + _request = build_microvm_checkpoints_create_request( + microvm_id=microvm_id, content_type=content_type, json=_json, content=_content, @@ -177958,15 +184888,30 @@ async def remove_forwarding_rules( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [201, 400, 404]: if _stream: await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -177977,6 +184922,11 @@ async def remove_forwarding_rules( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -177994,9 +184944,9 @@ async def remove_forwarding_rules( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore class MonitoringOperations: # pylint: disable=too-many-public-methods @@ -289209,7 +296159,7 @@ async def list_scenario_library_scenarios( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -289618,7 +296568,7 @@ async def create_scenario_set( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -289837,7 +296787,7 @@ async def create_scenario_set( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -290911,7 +297861,7 @@ async def update_scenario_set( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -291142,7 +298092,7 @@ async def update_scenario_set( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -292033,7 +298983,7 @@ async def list_scenarios( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -292750,12 +299700,12 @@ async def list_simulation_runs( * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not yet executing. - * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. - * SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. + * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. + * SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was cancelled. - * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an attached evaluation is running. + * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run @@ -292836,16 +299786,16 @@ async def list_simulation_runs( actor who triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that + have finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that - have finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the @@ -292870,11 +299820,11 @@ async def list_simulation_runs( wall-clock duration across the run, in seconds. "verdict_counts": { "failure_count": 0, # Optional. Number of - journeys with a FAILURE verdict. + episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number - of journeys with an INCONCLUSIVE verdict. + of episodes with an INCONCLUSIVE verdict. "success_count": 0 # Optional. Number of - journeys with a SUCCESS verdict. + episodes with a SUCCESS verdict. } }, "run_uuid": "str", # Optional. UUID of the run. @@ -292885,12 +299835,12 @@ async def list_simulation_runs( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, - not yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are - executing. * SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished + not yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are + executing. * SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was cancelled. * - SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an attached + SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -292901,7 +299851,7 @@ async def list_simulation_runs( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -293077,323 +300027,7 @@ async def create_simulation_run( } }, "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's - exploration_budget. - "judge_model_uuid": "str", # Optional. Optional model override for the - judge. Platform default when unset. - "max_turns": 0, # Optional. Optional run-level turn budget. When set, - overrides each scenario's max_turns. - "name": "str", # Optional. Optional run name. - "scenario_set_uuid": "str", # Optional. UUID of the existing scenario set to - execute. The set must be ready. - "user_simulator_config": {}, # Optional. Optional user simulator model - settings such as temperature and max_tokens. - "user_simulator_model_uuid": "str" # Optional. Optional model override for - the user simulator. Platform default when unset. - } - - # response body for status code(s): 200 - response == { - "simulation_run": { - "agent_config": { - "agent_deployment_uuid": "str", # Optional. Optional agent - deployment to run. Defaults to the agent's current deployment when unset. - "agent_uuid": "str", # Optional. UUID of the agent to - exercise as the candidate. - "name": "str" # Optional. Display name of the candidate - agent. Persisted with the run. - }, - "created_at": "2020-02-20 00:00:00", # Optional. Time created at. - "created_by_user_email": "str", # Optional. Email of the user who - triggered this run. - "created_by_user_id": "str", # Optional. User id of the actor who - triggered this run. - "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. - Unset unless the run has been deleted. - "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run - reserved for this simulation, when the create request included - evaluation_config. Empty when no evaluation is attached. - "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's - exploration_budget. - "failure_reason": "str", # Optional. Human-readable explanation of a - terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). - "judge_model_name": "str", # Optional. Display name of the judge - model (from the model catalog). - "judge_model_uuid": "str", # Optional. Model used by the judge. - "max_turns": 0, # Optional. Optional run-level turn budget. When - set, overrides each scenario's max_turns. - "name": "str", # Optional. Optional run name. - "result_summary": { - "token_usage": { - "candidate_agent_tokens": "str", # Optional. Tokens - consumed by the candidate agent. - "generator_tokens": "str", # Optional. Tokens - consumed by the scenario generator. - "judge_tokens": "str", # Optional. Tokens consumed - by the judge. - "simulator_tokens": "str", # Optional. Tokens - consumed by the user simulator. - "total_tokens": "str" # Optional. Total tokens - across all actors. - }, - "total_duration_sec": "str", # Optional. Total wall-clock - duration across the run, in seconds. - "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys - with a FAILURE verdict. - "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys - with a SUCCESS verdict. - } - }, - "run_uuid": "str", # Optional. UUID of the run. - "scenario_count": 0, # Optional. Number of scenarios in the scenario - set for this run. - "scenario_set_uuid": "str", # Optional. UUID of the scenario set - being executed (must exist at run create). - "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default - value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a - simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * - SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a - timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an - attached evaluation is running. Only reachable when the create request - included evaluation_config. When the evaluation reaches a terminal status, - its outcome is reflected in the simulation run status. * - SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL: The simulation or its attached - evaluation completed with a mixture of successful and failed results. Known - values are: "SIMULATION_RUN_STATUS_UNSPECIFIED", - "SIMULATION_RUN_STATUS_PENDING", "SIMULATION_RUN_STATUS_RUNNING", - "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", - "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and - "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of - exploration budgets). - "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated - at. - "user_simulator_config": {}, # Optional. Optional user simulator - model settings such as temperature and max_tokens. - "user_simulator_model_name": "str", # Optional. Display name of the - user simulator model (from the model catalog). - "user_simulator_model_uuid": "str", # Optional. Model used by the - user simulator. - "workflow_uuid": "str" # Optional. Identifier of the workflow - executing this run. - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ - - @overload - async def create_simulation_run( - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Create Simulation Run. - - To create a simulation run, send a POST request to ``/v2/gen-ai/simulation_runs``. The scenario - set must be ready. Judge and user simulator models are optional and use platform defaults when - omitted. The run is returned in the pending state. - - :param body: Default value is None. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "simulation_run": { - "agent_config": { - "agent_deployment_uuid": "str", # Optional. Optional agent - deployment to run. Defaults to the agent's current deployment when unset. - "agent_uuid": "str", # Optional. UUID of the agent to - exercise as the candidate. - "name": "str" # Optional. Display name of the candidate - agent. Persisted with the run. - }, - "created_at": "2020-02-20 00:00:00", # Optional. Time created at. - "created_by_user_email": "str", # Optional. Email of the user who - triggered this run. - "created_by_user_id": "str", # Optional. User id of the actor who - triggered this run. - "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. - Unset unless the run has been deleted. - "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run - reserved for this simulation, when the create request included - evaluation_config. Empty when no evaluation is attached. - "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's - exploration_budget. - "failure_reason": "str", # Optional. Human-readable explanation of a - terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). - "judge_model_name": "str", # Optional. Display name of the judge - model (from the model catalog). - "judge_model_uuid": "str", # Optional. Model used by the judge. - "max_turns": 0, # Optional. Optional run-level turn budget. When - set, overrides each scenario's max_turns. - "name": "str", # Optional. Optional run name. - "result_summary": { - "token_usage": { - "candidate_agent_tokens": "str", # Optional. Tokens - consumed by the candidate agent. - "generator_tokens": "str", # Optional. Tokens - consumed by the scenario generator. - "judge_tokens": "str", # Optional. Tokens consumed - by the judge. - "simulator_tokens": "str", # Optional. Tokens - consumed by the user simulator. - "total_tokens": "str" # Optional. Total tokens - across all actors. - }, - "total_duration_sec": "str", # Optional. Total wall-clock - duration across the run, in seconds. - "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys - with a FAILURE verdict. - "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys - with a SUCCESS verdict. - } - }, - "run_uuid": "str", # Optional. UUID of the run. - "scenario_count": 0, # Optional. Number of scenarios in the scenario - set for this run. - "scenario_set_uuid": "str", # Optional. UUID of the scenario set - being executed (must exist at run create). - "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default - value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a - simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * - SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a - timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an - attached evaluation is running. Only reachable when the create request - included evaluation_config. When the evaluation reaches a terminal status, - its outcome is reflected in the simulation run status. * - SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL: The simulation or its attached - evaluation completed with a mixture of successful and failed results. Known - values are: "SIMULATION_RUN_STATUS_UNSPECIFIED", - "SIMULATION_RUN_STATUS_PENDING", "SIMULATION_RUN_STATUS_RUNNING", - "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", - "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and - "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of - exploration budgets). - "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated - at. - "user_simulator_config": {}, # Optional. Optional user simulator - model settings such as temperature and max_tokens. - "user_simulator_model_name": "str", # Optional. Display name of the - user simulator model (from the model catalog). - "user_simulator_model_uuid": "str", # Optional. Model used by the - user simulator. - "workflow_uuid": "str" # Optional. Identifier of the workflow - executing this run. - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ - - @distributed_trace_async - async def create_simulation_run( - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Create Simulation Run. - - To create a simulation run, send a POST request to ``/v2/gen-ai/simulation_runs``. The scenario - set must be ready. Judge and user simulator models are optional and use platform defaults when - omitted. The run is returned in the pending state. - - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "agent_config": { - "agent_deployment_uuid": "str", # Optional. Optional agent - deployment to run. Defaults to the agent's current deployment when unset. - "agent_uuid": "str", # Optional. UUID of the agent to exercise as - the candidate. - "name": "str" # Optional. Display name of the candidate agent. - Persisted with the run. - }, - "evaluation_config": { - "metric_uuids": [ - "str" # Optional. Evaluation metric UUIDs (from the - evaluation metrics catalog). Must be simulation-eligible (multi-turn) - metrics; the create request is rejected if any UUID is unknown or - ineligible. - ], - "star_metric": { - "metric_uuid": "str", # Optional. Optional configuration - that opts a simulation run into an evaluation. When included on the - create-run request, the platform reserves a model_evaluation_run linked - to this simulation run and dispatches the evaluation automatically after - the simulation finishes. The evaluation reuses the simulation run's - judge_model_uuid. - "name": "str", # Optional. Optional configuration that opts - a simulation run into an evaluation. When included on the create-run - request, the platform reserves a model_evaluation_run linked to this - simulation run and dispatches the evaluation automatically after the - simulation finishes. The evaluation reuses the simulation run's - judge_model_uuid. - "success_threshold": 0.0, # Optional. The success threshold - for the star metric. This is a value that the metric must reach to be - considered successful. - "success_threshold_pct": 0 # Optional. The success threshold - for the star metric. This is a percentage value between 0 and 100. - } - }, - "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "judge_model_uuid": "str", # Optional. Optional model override for the judge. Platform default when unset. @@ -293426,16 +300060,151 @@ async def create_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have + "judge_model_name": "str", # Optional. Display name of the judge + model (from the model catalog). + "judge_model_uuid": "str", # Optional. Model used by the judge. + "max_turns": 0, # Optional. Optional run-level turn budget. When + set, overrides each scenario's max_turns. + "name": "str", # Optional. Optional run name. + "result_summary": { + "token_usage": { + "candidate_agent_tokens": "str", # Optional. Tokens + consumed by the candidate agent. + "generator_tokens": "str", # Optional. Tokens + consumed by the scenario generator. + "judge_tokens": "str", # Optional. Tokens consumed + by the judge. + "simulator_tokens": "str", # Optional. Tokens + consumed by the user simulator. + "total_tokens": "str" # Optional. Total tokens + across all actors. + }, + "total_duration_sec": "str", # Optional. Total wall-clock + duration across the run, in seconds. + "verdict_counts": { + "failure_count": 0, # Optional. Number of episodes + with a FAILURE verdict. + "inconclusive_count": 0, # Optional. Number of + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes + with a SUCCESS verdict. + } + }, + "run_uuid": "str", # Optional. UUID of the run. + "scenario_count": 0, # Optional. Number of scenarios in the scenario + set for this run. + "scenario_set_uuid": "str", # Optional. UUID of the scenario set + being executed (must exist at run create). + "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default + value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a + simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * + SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a + timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an + attached evaluation is running. Only reachable when the create request + included evaluation_config. When the evaluation reaches a terminal status, + its outcome is reflected in the simulation run status. * + SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL: The simulation or its attached + evaluation completed with a mixture of successful and failed results. Known + values are: "SIMULATION_RUN_STATUS_UNSPECIFIED", + "SIMULATION_RUN_STATUS_PENDING", "SIMULATION_RUN_STATUS_RUNNING", + "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", + "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and + "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". + "total_episodes": 0, # Optional. Total number of episodes (sum of + exploration budgets). + "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated + at. + "user_simulator_config": {}, # Optional. Optional user simulator + model settings such as temperature and max_tokens. + "user_simulator_model_name": "str", # Optional. Display name of the + user simulator model (from the model catalog). + "user_simulator_model_uuid": "str", # Optional. Model used by the + user simulator. + "workflow_uuid": "str" # Optional. Identifier of the workflow + executing this run. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def create_simulation_run( + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create Simulation Run. + + To create a simulation run, send a POST request to ``/v2/gen-ai/simulation_runs``. The scenario + set must be ready. Judge and user simulator models are optional and use platform defaults when + omitted. The run is returned in the pending state. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "simulation_run": { + "agent_config": { + "agent_deployment_uuid": "str", # Optional. Optional agent + deployment to run. Defaults to the agent's current deployment when unset. + "agent_uuid": "str", # Optional. UUID of the agent to + exercise as the candidate. + "name": "str" # Optional. Display name of the candidate + agent. Persisted with the run. + }, + "created_at": "2020-02-20 00:00:00", # Optional. Time created at. + "created_by_user_email": "str", # Optional. Email of the user who + triggered this run. + "created_by_user_id": "str", # Optional. User id of the actor who + triggered this run. + "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. + Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have finished (successfully or not). + "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run + reserved for this simulation, when the create request included + evaluation_config. Empty when no evaluation is attached. + "exploration_budget": 0, # Optional. Optional run-level + episodes-per-scenario override. When set, overrides each scenario's + exploration_budget. + "failure_reason": "str", # Optional. Human-readable explanation of a + terminal FAILED status. Empty otherwise. "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -293458,11 +300227,11 @@ async def create_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -293474,11 +300243,11 @@ async def create_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -293489,7 +300258,188 @@ async def create_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of + exploration budgets). + "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated + at. + "user_simulator_config": {}, # Optional. Optional user simulator + model settings such as temperature and max_tokens. + "user_simulator_model_name": "str", # Optional. Display name of the + user simulator model (from the model catalog). + "user_simulator_model_uuid": "str", # Optional. Model used by the + user simulator. + "workflow_uuid": "str" # Optional. Identifier of the workflow + executing this run. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def create_simulation_run( + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create Simulation Run. + + To create a simulation run, send a POST request to ``/v2/gen-ai/simulation_runs``. The scenario + set must be ready. Judge and user simulator models are optional and use platform defaults when + omitted. The run is returned in the pending state. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "agent_config": { + "agent_deployment_uuid": "str", # Optional. Optional agent + deployment to run. Defaults to the agent's current deployment when unset. + "agent_uuid": "str", # Optional. UUID of the agent to exercise as + the candidate. + "name": "str" # Optional. Display name of the candidate agent. + Persisted with the run. + }, + "evaluation_config": { + "metric_uuids": [ + "str" # Optional. Evaluation metric UUIDs (from the + evaluation metrics catalog). Must be simulation-eligible (multi-turn) + metrics; the create request is rejected if any UUID is unknown or + ineligible. + ], + "star_metric": { + "metric_uuid": "str", # Optional. Optional configuration + that opts a simulation run into an evaluation. When included on the + create-run request, the platform reserves a model_evaluation_run linked + to this simulation run and dispatches the evaluation automatically after + the simulation finishes. The evaluation reuses the simulation run's + judge_model_uuid. + "name": "str", # Optional. Optional configuration that opts + a simulation run into an evaluation. When included on the create-run + request, the platform reserves a model_evaluation_run linked to this + simulation run and dispatches the evaluation automatically after the + simulation finishes. The evaluation reuses the simulation run's + judge_model_uuid. + "success_threshold": 0.0, # Optional. The success threshold + for the star metric. This is a value that the metric must reach to be + considered successful. + "success_threshold_pct": 0 # Optional. The success threshold + for the star metric. This is a percentage value between 0 and 100. + } + }, + "exploration_budget": 0, # Optional. Optional run-level + episodes-per-scenario override. When set, overrides each scenario's + exploration_budget. + "judge_model_uuid": "str", # Optional. Optional model override for the + judge. Platform default when unset. + "max_turns": 0, # Optional. Optional run-level turn budget. When set, + overrides each scenario's max_turns. + "name": "str", # Optional. Optional run name. + "scenario_set_uuid": "str", # Optional. UUID of the existing scenario set to + execute. The set must be ready. + "user_simulator_config": {}, # Optional. Optional user simulator model + settings such as temperature and max_tokens. + "user_simulator_model_uuid": "str" # Optional. Optional model override for + the user simulator. Platform default when unset. + } + + # response body for status code(s): 200 + response == { + "simulation_run": { + "agent_config": { + "agent_deployment_uuid": "str", # Optional. Optional agent + deployment to run. Defaults to the agent's current deployment when unset. + "agent_uuid": "str", # Optional. UUID of the agent to + exercise as the candidate. + "name": "str" # Optional. Display name of the candidate + agent. Persisted with the run. + }, + "created_at": "2020-02-20 00:00:00", # Optional. Time created at. + "created_by_user_email": "str", # Optional. Email of the user who + triggered this run. + "created_by_user_id": "str", # Optional. User id of the actor who + triggered this run. + "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. + Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). + "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run + reserved for this simulation, when the create request included + evaluation_config. Empty when no evaluation is attached. + "exploration_budget": 0, # Optional. Optional run-level + episodes-per-scenario override. When set, overrides each scenario's + exploration_budget. + "failure_reason": "str", # Optional. Human-readable explanation of a + terminal FAILED status. Empty otherwise. + "judge_model_name": "str", # Optional. Display name of the judge + model (from the model catalog). + "judge_model_uuid": "str", # Optional. Model used by the judge. + "max_turns": 0, # Optional. Optional run-level turn budget. When + set, overrides each scenario's max_turns. + "name": "str", # Optional. Optional run name. + "result_summary": { + "token_usage": { + "candidate_agent_tokens": "str", # Optional. Tokens + consumed by the candidate agent. + "generator_tokens": "str", # Optional. Tokens + consumed by the scenario generator. + "judge_tokens": "str", # Optional. Tokens consumed + by the judge. + "simulator_tokens": "str", # Optional. Tokens + consumed by the user simulator. + "total_tokens": "str" # Optional. Total tokens + across all actors. + }, + "total_duration_sec": "str", # Optional. Total wall-clock + duration across the run, in seconds. + "verdict_counts": { + "failure_count": 0, # Optional. Number of episodes + with a FAILURE verdict. + "inconclusive_count": 0, # Optional. Number of + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes + with a SUCCESS verdict. + } + }, + "run_uuid": "str", # Optional. UUID of the run. + "scenario_count": 0, # Optional. Number of scenarios in the scenario + set for this run. + "scenario_set_uuid": "str", # Optional. UUID of the scenario set + being executed (must exist at run create). + "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default + value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a + simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * + SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a + timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an + attached evaluation is running. Only reachable when the create request + included evaluation_config. When the evaluation reaches a terminal status, + its outcome is reflected in the simulation run status. * + SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL: The simulation or its attached + evaluation completed with a mixture of successful and failed results. Known + values are: "SIMULATION_RUN_STATUS_UNSPECIFIED", + "SIMULATION_RUN_STATUS_PENDING", "SIMULATION_RUN_STATUS_RUNNING", + "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", + "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and + "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -293629,17 +300579,17 @@ async def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: response == { "scenario_results": [ { - "journeys_finished": 0, # Optional. Journeys that have + "episodes_finished": 0, # Optional. Episodes that have finished (successfully or not). "scenario_uuid": "str", # Optional. UUID of the scenario. - "total_journeys": 0, # Optional. Total journeys for this + "total_episodes": 0, # Optional. Total episodes for this scenario (its exploration budget). "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } } @@ -293660,16 +300610,16 @@ async def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -293692,11 +300642,11 @@ async def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -293708,11 +300658,11 @@ async def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -293723,7 +300673,7 @@ async def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -293882,16 +300832,16 @@ async def update_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -293914,11 +300864,11 @@ async def update_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -293930,11 +300880,11 @@ async def update_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -293945,7 +300895,7 @@ async def update_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -294021,16 +300971,16 @@ async def update_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -294053,11 +301003,11 @@ async def update_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -294069,11 +301019,11 @@ async def update_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -294084,7 +301034,7 @@ async def update_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -294161,16 +301111,16 @@ async def update_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -294193,11 +301143,11 @@ async def update_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -294209,11 +301159,11 @@ async def update_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -294224,7 +301174,7 @@ async def update_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -294515,16 +301465,16 @@ async def patch_cancel_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -294547,11 +301497,11 @@ async def patch_cancel_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -294563,11 +301513,11 @@ async def patch_cancel_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -294578,7 +301528,7 @@ async def patch_cancel_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -294654,16 +301604,16 @@ async def patch_cancel_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -294686,11 +301636,11 @@ async def patch_cancel_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -294702,11 +301652,11 @@ async def patch_cancel_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -294717,7 +301667,7 @@ async def patch_cancel_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -294793,16 +301743,16 @@ async def patch_cancel_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -294825,11 +301775,11 @@ async def patch_cancel_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -294841,11 +301791,11 @@ async def patch_cancel_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -294856,7 +301806,7 @@ async def patch_cancel_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -294978,7 +301928,7 @@ async def patch_cancel_simulation_run( return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def list_simulation_journeys( + async def list_simulation_episodes( self, run_uuid: str, *, @@ -294988,17 +301938,17 @@ async def list_simulation_journeys( statuses: Optional[List[str]] = None, verdicts: Optional[List[str]] = None, search: Optional[str] = None, - sort_by: str = "SIMULATION_JOURNEY_SORT_FIELD_UNSPECIFIED", + sort_by: str = "SIMULATION_EPISODE_SORT_FIELD_UNSPECIFIED", sort_direction: str = "SORT_DIRECTION_UNSPECIFIED", **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """List Simulation Journeys. + """List Simulation Episodes. - To list the journeys within a simulation run, send a GET request to - ``/v2/gen-ai/simulation_runs/{run_uuid}/journeys``. + To list the episodes within a simulation run, send a GET request to + ``/v2/gen-ai/simulation_runs/{run_uuid}/episodes``. - :param run_uuid: UUID of the run whose journeys to list. Required. + :param run_uuid: UUID of the run whose episodes to list. Required. :type run_uuid: str :keyword scenario_uuid: Optional filter by scenario. Default value is None. :paramtype scenario_uuid: str @@ -295009,22 +301959,22 @@ async def list_simulation_journeys( :keyword statuses: Filter by one or more statuses. Empty means no status filter. - * SIMULATION_JOURNEY_STATUS_RUNNING: The journey is executing and a trajectory is available to + * SIMULATION_EPISODE_STATUS_RUNNING: The episode is executing and a trajectory is available to retrieve. - * SIMULATION_JOURNEY_STATUS_FINISHED: The journey reached a stop condition and produced a + * SIMULATION_EPISODE_STATUS_FINISHED: The episode reached a stop condition and produced a verdict. - * SIMULATION_JOURNEY_STATUS_FAILED: The journey failed because of a cancel, timeout, or error. - * SIMULATION_JOURNEY_STATUS_PREPARING: The journey is allocated but its trajectory is not + * SIMULATION_EPISODE_STATUS_FAILED: The episode failed because of a cancel, timeout, or error. + * SIMULATION_EPISODE_STATUS_PREPARING: The episode is allocated but its trajectory is not available yet. Default value is None. :paramtype statuses: list[str] :keyword verdicts: Filter by one or more verdicts. Empty means no verdict filter. - * SIMULATION_JOURNEY_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping + * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. - * SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy the stopping + * SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy the stopping criteria. - * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached + * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). Default value is None. :paramtype verdicts: list[str] :keyword search: Free-text search across scenario_uuid and session_id @@ -295033,14 +301983,14 @@ async def list_simulation_journeys( :keyword sort_by: Field to sort by. Defaults to scenario ordering when unspecified. - * SIMULATION_JOURNEY_SORT_FIELD_SCENARIO: Sort by scenario_uuid then journey_index. Default. - * SIMULATION_JOURNEY_SORT_FIELD_CREATED_AT: Sort by creation date. - * SIMULATION_JOURNEY_SORT_FIELD_STATUS: Sort by journey status using lifecycle order. - * SIMULATION_JOURNEY_SORT_FIELD_VERDICT: Sort by verdict (nulls last). Known values are: - "SIMULATION_JOURNEY_SORT_FIELD_UNSPECIFIED", "SIMULATION_JOURNEY_SORT_FIELD_SCENARIO", - "SIMULATION_JOURNEY_SORT_FIELD_CREATED_AT", "SIMULATION_JOURNEY_SORT_FIELD_STATUS", and - "SIMULATION_JOURNEY_SORT_FIELD_VERDICT". Default value is - "SIMULATION_JOURNEY_SORT_FIELD_UNSPECIFIED". + * SIMULATION_EPISODE_SORT_FIELD_SCENARIO: Sort by scenario_uuid then episode_index. Default. + * SIMULATION_EPISODE_SORT_FIELD_CREATED_AT: Sort by creation date. + * SIMULATION_EPISODE_SORT_FIELD_STATUS: Sort by episode status using lifecycle order. + * SIMULATION_EPISODE_SORT_FIELD_VERDICT: Sort by verdict (nulls last). Known values are: + "SIMULATION_EPISODE_SORT_FIELD_UNSPECIFIED", "SIMULATION_EPISODE_SORT_FIELD_SCENARIO", + "SIMULATION_EPISODE_SORT_FIELD_CREATED_AT", "SIMULATION_EPISODE_SORT_FIELD_STATUS", and + "SIMULATION_EPISODE_SORT_FIELD_VERDICT". Default value is + "SIMULATION_EPISODE_SORT_FIELD_UNSPECIFIED". :paramtype sort_by: str :keyword sort_direction: Sort direction. Defaults to ascending when unspecified. Known values are: "SORT_DIRECTION_UNSPECIFIED", "SORT_DIRECTION_ASC", and "SORT_DIRECTION_DESC". Default @@ -295070,39 +302020,39 @@ async def list_simulation_journeys( "str" # Optional. Verdicts available for filtering this list request. ], - "journeys": [ + "episodes": [ { "created_at": "2020-02-20 00:00:00", # Optional. Time created at. "duration_sec": "str", # Optional. Wall-clock time taken for - the journey to complete, in seconds. + the episode to complete, in seconds. + "episode_index": 0, # Optional. Zero-based index of this + episode within its scenario's exploration budget. + "episode_uuid": "str", # Optional. UUID of the episode. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journey_index": 0, # Optional. Zero-based index of this - journey within its scenario's exploration budget. - "journey_uuid": "str", # Optional. UUID of the journey. "judge_reasoning": "str", # Optional. Optional judge reasoning for the verdict. - "run_uuid": "str", # Optional. UUID of the run this journey + "run_uuid": "str", # Optional. UUID of the run this episode belongs to. "scenario_uuid": "str", # Optional. UUID of the scenario - this journey executed. + this episode executed. "session_id": "str", # Optional. Session identifier for this - journey. - "status": "SIMULATION_JOURNEY_STATUS_UNSPECIFIED", # - Optional. Default value is "SIMULATION_JOURNEY_STATUS_UNSPECIFIED". - Lifecycle status of a single journey. * - SIMULATION_JOURNEY_STATUS_RUNNING: The journey is executing and a + episode. + "status": "SIMULATION_EPISODE_STATUS_UNSPECIFIED", # + Optional. Default value is "SIMULATION_EPISODE_STATUS_UNSPECIFIED". + Lifecycle status of a single episode. * + SIMULATION_EPISODE_STATUS_RUNNING: The episode is executing and a trajectory is available to retrieve. * - SIMULATION_JOURNEY_STATUS_FINISHED: The journey reached a stop condition - and produced a verdict. * SIMULATION_JOURNEY_STATUS_FAILED: The journey + SIMULATION_EPISODE_STATUS_FINISHED: The episode reached a stop condition + and produced a verdict. * SIMULATION_EPISODE_STATUS_FAILED: The episode failed because of a cancel, timeout, or error. * - SIMULATION_JOURNEY_STATUS_PREPARING: The journey is allocated but its + SIMULATION_EPISODE_STATUS_PREPARING: The episode is allocated but its trajectory is not available yet. Known values are: - "SIMULATION_JOURNEY_STATUS_UNSPECIFIED", - "SIMULATION_JOURNEY_STATUS_RUNNING", - "SIMULATION_JOURNEY_STATUS_FINISHED", "SIMULATION_JOURNEY_STATUS_FAILED", - and "SIMULATION_JOURNEY_STATUS_PREPARING". + "SIMULATION_EPISODE_STATUS_UNSPECIFIED", + "SIMULATION_EPISODE_STATUS_RUNNING", + "SIMULATION_EPISODE_STATUS_FINISHED", "SIMULATION_EPISODE_STATUS_FAILED", + and "SIMULATION_EPISODE_STATUS_PREPARING". "token_usage": { "candidate_agent_tokens": "str", # Optional. Tokens consumed by the candidate agent. @@ -295116,25 +302066,25 @@ async def list_simulation_journeys( across all actors. }, "trajectory_bucket_name": "str", # Optional. Object storage - bucket holding the trajectory JSON. Set when the journey finishes. + bucket holding the trajectory JSON. Set when the episode finishes. "trajectory_bucket_region": "str", # Optional. Object - storage bucket region for the trajectory JSON. Set when the journey + storage bucket region for the trajectory JSON. Set when the episode finishes. "trajectory_spaces_key": "str", # Optional. Object storage - key for the trajectory JSON. Set when the journey finishes. + key for the trajectory JSON. Set when the episode finishes. "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. - "verdict": "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED" # - Optional. Default value is "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED". The - judge's verdict for a journey. * SIMULATION_JOURNEY_VERDICT_SUCCESS: + "verdict": "SIMULATION_EPISODE_VERDICT_UNSPECIFIED" # + Optional. Default value is "SIMULATION_EPISODE_VERDICT_UNSPECIFIED". The + judge's verdict for an episode. * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. * - SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy - the stopping criteria. * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No + SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy + the stopping criteria. * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). - Known values are: "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED", - "SIMULATION_JOURNEY_VERDICT_SUCCESS", - "SIMULATION_JOURNEY_VERDICT_FAILURE", and - "SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE". + Known values are: "SIMULATION_EPISODE_VERDICT_UNSPECIFIED", + "SIMULATION_EPISODE_VERDICT_SUCCESS", + "SIMULATION_EPISODE_VERDICT_FAILURE", and + "SIMULATION_EPISODE_VERDICT_INCONCLUSIVE". } ], "links": { @@ -295181,7 +302131,7 @@ async def list_simulation_journeys( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_genai_list_simulation_journeys_request( + _request = build_genai_list_simulation_episodes_request( run_uuid=run_uuid, scenario_uuid=scenario_uuid, page=page, @@ -295250,19 +302200,19 @@ async def list_simulation_journeys( return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_simulation_journey( - self, run_uuid: str, journey_uuid: str, **kwargs: Any + async def get_simulation_episode( + self, run_uuid: str, episode_uuid: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Retrieve Simulation Journey. + """Retrieve Simulation Episode. - To retrieve a single journey, send a GET request to - ``/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}``. + To retrieve a single episode, send a GET request to + ``/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}``. - :param run_uuid: UUID of the run the journey belongs to. Required. + :param run_uuid: UUID of the run the episode belongs to. Required. :type run_uuid: str - :param journey_uuid: UUID of the journey. Required. - :type journey_uuid: str + :param episode_uuid: UUID of the episode. Required. + :type episode_uuid: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -295272,35 +302222,35 @@ async def get_simulation_journey( # response body for status code(s): 200 response == { - "journey": { + "episode": { "created_at": "2020-02-20 00:00:00", # Optional. Time created at. "duration_sec": "str", # Optional. Wall-clock time taken for the - journey to complete, in seconds. + episode to complete, in seconds. + "episode_index": 0, # Optional. Zero-based index of this episode + within its scenario's exploration budget. + "episode_uuid": "str", # Optional. UUID of the episode. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journey_index": 0, # Optional. Zero-based index of this journey - within its scenario's exploration budget. - "journey_uuid": "str", # Optional. UUID of the journey. "judge_reasoning": "str", # Optional. Optional judge reasoning for the verdict. - "run_uuid": "str", # Optional. UUID of the run this journey belongs + "run_uuid": "str", # Optional. UUID of the run this episode belongs to. "scenario_uuid": "str", # Optional. UUID of the scenario this - journey executed. + episode executed. "session_id": "str", # Optional. Session identifier for this - journey. - "status": "SIMULATION_JOURNEY_STATUS_UNSPECIFIED", # Optional. - Default value is "SIMULATION_JOURNEY_STATUS_UNSPECIFIED". Lifecycle status of - a single journey. * SIMULATION_JOURNEY_STATUS_RUNNING: The journey is + episode. + "status": "SIMULATION_EPISODE_STATUS_UNSPECIFIED", # Optional. + Default value is "SIMULATION_EPISODE_STATUS_UNSPECIFIED". Lifecycle status of + a single episode. * SIMULATION_EPISODE_STATUS_RUNNING: The episode is executing and a trajectory is available to retrieve. * - SIMULATION_JOURNEY_STATUS_FINISHED: The journey reached a stop condition and - produced a verdict. * SIMULATION_JOURNEY_STATUS_FAILED: The journey failed + SIMULATION_EPISODE_STATUS_FINISHED: The episode reached a stop condition and + produced a verdict. * SIMULATION_EPISODE_STATUS_FAILED: The episode failed because of a cancel, timeout, or error. * - SIMULATION_JOURNEY_STATUS_PREPARING: The journey is allocated but its + SIMULATION_EPISODE_STATUS_PREPARING: The episode is allocated but its trajectory is not available yet. Known values are: - "SIMULATION_JOURNEY_STATUS_UNSPECIFIED", "SIMULATION_JOURNEY_STATUS_RUNNING", - "SIMULATION_JOURNEY_STATUS_FINISHED", "SIMULATION_JOURNEY_STATUS_FAILED", and - "SIMULATION_JOURNEY_STATUS_PREPARING". + "SIMULATION_EPISODE_STATUS_UNSPECIFIED", "SIMULATION_EPISODE_STATUS_RUNNING", + "SIMULATION_EPISODE_STATUS_FINISHED", "SIMULATION_EPISODE_STATUS_FAILED", and + "SIMULATION_EPISODE_STATUS_PREPARING". "token_usage": { "candidate_agent_tokens": "str", # Optional. Tokens consumed by the candidate agent. @@ -295314,23 +302264,23 @@ async def get_simulation_journey( actors. }, "trajectory_bucket_name": "str", # Optional. Object storage bucket - holding the trajectory JSON. Set when the journey finishes. + holding the trajectory JSON. Set when the episode finishes. "trajectory_bucket_region": "str", # Optional. Object storage bucket - region for the trajectory JSON. Set when the journey finishes. + region for the trajectory JSON. Set when the episode finishes. "trajectory_spaces_key": "str", # Optional. Object storage key for - the trajectory JSON. Set when the journey finishes. + the trajectory JSON. Set when the episode finishes. "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. - "verdict": "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED" # Optional. - Default value is "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED". The judge's - verdict for a journey. * SIMULATION_JOURNEY_VERDICT_SUCCESS: The candidate + "verdict": "SIMULATION_EPISODE_VERDICT_UNSPECIFIED" # Optional. + Default value is "SIMULATION_EPISODE_VERDICT_UNSPECIFIED". The judge's + verdict for an episode. * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. * - SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy the - stopping criteria. * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No conclusive + SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy the + stopping criteria. * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). Known values - are: "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED", - "SIMULATION_JOURNEY_VERDICT_SUCCESS", "SIMULATION_JOURNEY_VERDICT_FAILURE", - and "SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE". + are: "SIMULATION_EPISODE_VERDICT_UNSPECIFIED", + "SIMULATION_EPISODE_VERDICT_SUCCESS", "SIMULATION_EPISODE_VERDICT_FAILURE", + and "SIMULATION_EPISODE_VERDICT_INCONCLUSIVE". } } # response body for status code(s): 404 @@ -295363,9 +302313,9 @@ async def get_simulation_journey( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_genai_get_simulation_journey_request( + _request = build_genai_get_simulation_episode_request( run_uuid=run_uuid, - journey_uuid=journey_uuid, + episode_uuid=episode_uuid, headers=_headers, params=_params, ) @@ -295425,20 +302375,20 @@ async def get_simulation_journey( return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_simulation_journey_trajectory( - self, run_uuid: str, journey_uuid: str, **kwargs: Any + async def get_simulation_episode_trajectory( + self, run_uuid: str, episode_uuid: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Retrieve Journey Trajectory. + """Retrieve Episode Trajectory. - To retrieve a journey's live trajectory, send a GET request to - ``/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}/trajectory``. Poll while the - journey is running to watch turn-by-turn progress. + To retrieve an episode's live trajectory, send a GET request to + ``/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}/trajectory``. Poll while the + episode is running to watch turn-by-turn progress. - :param run_uuid: UUID of the run the journey belongs to. Required. + :param run_uuid: UUID of the run the episode belongs to. Required. :type run_uuid: str - :param journey_uuid: UUID of the journey. Required. - :type journey_uuid: str + :param episode_uuid: UUID of the episode. Required. + :type episode_uuid: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -295450,12 +302400,18 @@ async def get_simulation_journey_trajectory( response == { "trajectory": { "agent_id": "str", # Optional. Identifier of the candidate agent - under test for this journey. + under test for this episode. "completed_at": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "duration_sec": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live + progress. + "episode_index": 0, # Optional. Turn-by-turn trajectory for one + episode. Poll this resource while the episode is running to watch live + progress. + "episode_uuid": "str", # Optional. Turn-by-turn trajectory for one + episode. Poll this resource while the episode is running to watch live progress. "evaluation_metrics": [ { @@ -295486,13 +302442,7 @@ async def get_simulation_journey_trajectory( } ], "failure_reason": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live - progress. - "journey_index": 0, # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live - progress. - "journey_uuid": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "judge": { "criteria_pass_fail": [ @@ -295507,19 +302457,19 @@ async def get_simulation_journey_trajectory( ], "reasoning": "str", # Optional. Judge output embedded in the trajectory JSON. - "verdict": "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED" # - Optional. Default value is "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED". The - judge's verdict for a journey. * SIMULATION_JOURNEY_VERDICT_SUCCESS: + "verdict": "SIMULATION_EPISODE_VERDICT_UNSPECIFIED" # + Optional. Default value is "SIMULATION_EPISODE_VERDICT_UNSPECIFIED". The + judge's verdict for an episode. * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. * - SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy - the stopping criteria. * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No + SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy + the stopping criteria. * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). - Known values are: "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED", - "SIMULATION_JOURNEY_VERDICT_SUCCESS", - "SIMULATION_JOURNEY_VERDICT_FAILURE", and - "SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE". + Known values are: "SIMULATION_EPISODE_VERDICT_UNSPECIFIED", + "SIMULATION_EPISODE_VERDICT_SUCCESS", + "SIMULATION_EPISODE_VERDICT_FAILURE", and + "SIMULATION_EPISODE_VERDICT_INCONCLUSIVE". }, - "max_turns": 0, # Optional. Turn budget configured for this journey + "max_turns": 0, # Optional. Turn budget configured for this episode (per-scenario max_turns, after any run-level override). Compare with turn_count to see how many of the budgeted turns actually ran. "messages": [ @@ -295558,26 +302508,26 @@ async def get_simulation_journey_trajectory( } ], "run_uuid": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "scenario_uuid": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "session_id": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "started_at": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "status": "SIMULATION_TRAJECTORY_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_TRAJECTORY_STATUS_UNSPECIFIED". Lifecycle status - of the trajectory. Distinct from journey status: the trajectory is updated on - every turn while the journey is executing. * - SIMULATION_TRAJECTORY_STATUS_RUNNING: The journey loop is in progress; + of the trajectory. Distinct from episode status: the trajectory is updated on + every turn while the episode is executing. * + SIMULATION_TRAJECTORY_STATUS_RUNNING: The episode loop is in progress; messages may grow on each poll. * SIMULATION_TRAJECTORY_STATUS_COMPLETED: The - journey reached a stop condition and the trajectory is complete. * - SIMULATION_TRAJECTORY_STATUS_FAILED: The journey failed before or during - execution. * SIMULATION_TRAJECTORY_STATUS_CANCELLED: The journey was + episode reached a stop condition and the trajectory is complete. * + SIMULATION_TRAJECTORY_STATUS_FAILED: The episode failed before or during + execution. * SIMULATION_TRAJECTORY_STATUS_CANCELLED: The episode was cancelled. Known values are: "SIMULATION_TRAJECTORY_STATUS_UNSPECIFIED", "SIMULATION_TRAJECTORY_STATUS_RUNNING", "SIMULATION_TRAJECTORY_STATUS_COMPLETED", @@ -295596,18 +302546,18 @@ async def get_simulation_journey_trajectory( actors. }, "turn_count": 0, # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. - "verdict": "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED" # Optional. - Default value is "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED". The judge's - verdict for a journey. * SIMULATION_JOURNEY_VERDICT_SUCCESS: The candidate + "verdict": "SIMULATION_EPISODE_VERDICT_UNSPECIFIED" # Optional. + Default value is "SIMULATION_EPISODE_VERDICT_UNSPECIFIED". The judge's + verdict for an episode. * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. * - SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy the - stopping criteria. * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No conclusive + SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy the + stopping criteria. * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). Known values - are: "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED", - "SIMULATION_JOURNEY_VERDICT_SUCCESS", "SIMULATION_JOURNEY_VERDICT_FAILURE", - and "SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE". + are: "SIMULATION_EPISODE_VERDICT_UNSPECIFIED", + "SIMULATION_EPISODE_VERDICT_SUCCESS", "SIMULATION_EPISODE_VERDICT_FAILURE", + and "SIMULATION_EPISODE_VERDICT_INCONCLUSIVE". } } # response body for status code(s): 404 @@ -295640,9 +302590,9 @@ async def get_simulation_journey_trajectory( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_genai_get_simulation_journey_trajectory_request( + _request = build_genai_get_simulation_episode_trajectory_request( run_uuid=run_uuid, - journey_uuid=journey_uuid, + episode_uuid=episode_uuid, headers=_headers, params=_params, ) @@ -295702,19 +302652,19 @@ async def get_simulation_journey_trajectory( return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_simulation_journey_trajectory_url( - self, run_uuid: str, journey_uuid: str, **kwargs: Any + async def get_simulation_episode_trajectory_url( + self, run_uuid: str, episode_uuid: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Retrieve Journey Trajectory Download URL. + """Retrieve Episode Trajectory Download URL. - To retrieve a presigned download URL for a journey's trajectory, send a GET request to - ``/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}/trajectory_url``. + To retrieve a presigned download URL for an episode's trajectory, send a GET request to + ``/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}/trajectory_url``. - :param run_uuid: UUID of the run the journey belongs to. Required. + :param run_uuid: UUID of the run the episode belongs to. Required. :type run_uuid: str - :param journey_uuid: UUID of the journey. Required. - :type journey_uuid: str + :param episode_uuid: UUID of the episode. Required. + :type episode_uuid: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -295758,9 +302708,9 @@ async def get_simulation_journey_trajectory_url( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_genai_get_simulation_journey_trajectory_url_request( + _request = build_genai_get_simulation_episode_trajectory_url_request( run_uuid=run_uuid, - journey_uuid=journey_uuid, + episode_uuid=episode_uuid, headers=_headers, params=_params, ) diff --git a/src/pydo/operations/__init__.py b/src/pydo/operations/__init__.py index 163af5e7..ba9e9863 100644 --- a/src/pydo/operations/__init__.py +++ b/src/pydo/operations/__init__.py @@ -38,8 +38,11 @@ from ._operations import ImagesOperations from ._operations import ImageActionsOperations from ._operations import InsightsOperations +from ._operations import SignalsOperations from ._operations import KubernetesOperations from ._operations import LoadBalancersOperations +from ._operations import MicrovmsOperations +from ._operations import MicrovmCheckpointsOperations from ._operations import MonitoringOperations from ._operations import NfsOperations from ._operations import OrganizationsOperations @@ -112,8 +115,11 @@ "ImagesOperations", "ImageActionsOperations", "InsightsOperations", + "SignalsOperations", "KubernetesOperations", "LoadBalancersOperations", + "MicrovmsOperations", + "MicrovmCheckpointsOperations", "MonitoringOperations", "NfsOperations", "OrganizationsOperations", diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index 8ec49bf3..02c6a908 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -7756,6 +7756,452 @@ def build_insights_post_logs_search_request(region: str, **kwargs: Any) -> HttpR return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) +def build_insights_post_traces_search_request( # pylint: disable=name-too-long + region: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json, text/plain") + + # Construct URL + _url = "/v2/insights/query/{region}/traces/search" + path_format_arguments = { + "region": _SERIALIZER.url("region", region, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_insights_get_trace_request( + region: str, + trace_id: str, + *, + from_parameter: Optional[str] = None, + to: Optional[str] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json, text/plain") + + # Construct URL + _url = "/v2/insights/query/{region}/traces/{trace_id}" + path_format_arguments = { + "region": _SERIALIZER.url("region", region, "str"), + "trace_id": _SERIALIZER.url("trace_id", trace_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if from_parameter is not None: + _params["from"] = _SERIALIZER.query("from_parameter", from_parameter, "str") + if to is not None: + _params["to"] = _SERIALIZER.query("to", to, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_insights_post_spans_search_request(region: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/insights/query/{region}/spans/search" + path_format_arguments = { + "region": _SERIALIZER.url("region", region, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_signals_list_consents_request( + *, source: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/consent" + + # Construct parameters + if source is not None: + _params["source"] = _SERIALIZER.query("source", source, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_signals_update_team_consent_request( # pylint: disable=name-too-long + *, source: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/consent" + + # Construct parameters + _params["source"] = _SERIALIZER.query("source", source, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="PUT", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_signals_get_consent_request(agent_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/consent/{agent_id}" + path_format_arguments = { + "agent_id": _SERIALIZER.url("agent_id", agent_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_signals_update_consent_request(agent_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/consent/{agent_id}" + path_format_arguments = { + "agent_id": _SERIALIZER.url("agent_id", agent_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) + + +def build_signals_list_agent_sessions_request( # pylint: disable=name-too-long + agent_id: str, + *, + limit: int = 20, + after: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + signal_type: Optional[str] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/agents/{agent_id}/sessions" + path_format_arguments = { + "agent_id": _SERIALIZER.url("agent_id", agent_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query( + "limit", limit, "int", maximum=100, minimum=1 + ) + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if start_time is not None: + _params["start_time"] = _SERIALIZER.query("start_time", start_time, "iso-8601") + if end_time is not None: + _params["end_time"] = _SERIALIZER.query("end_time", end_time, "iso-8601") + if signal_type is not None: + _params["signal_type"] = _SERIALIZER.query("signal_type", signal_type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_signals_list_session_dialogues_request( # pylint: disable=name-too-long + session_id: str, + *, + limit: int = 20, + after: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + signal_type: Optional[str] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/sessions/{session_id}/dialogues" + path_format_arguments = { + "session_id": _SERIALIZER.url("session_id", session_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query( + "limit", limit, "int", maximum=100, minimum=1 + ) + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if start_time is not None: + _params["start_time"] = _SERIALIZER.query("start_time", start_time, "iso-8601") + if end_time is not None: + _params["end_time"] = _SERIALIZER.query("end_time", end_time, "iso-8601") + if signal_type is not None: + _params["signal_type"] = _SERIALIZER.query("signal_type", signal_type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_signals_list_exports_request( + *, limit: int = 20, after: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/exports" + + # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query( + "limit", limit, "int", maximum=100, minimum=1 + ) + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_signals_create_export_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/exports" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_signals_get_export_options_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/exports/options" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_signals_get_export_request(export_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/exports/{export_id}" + path_format_arguments = { + "export_id": _SERIALIZER.url("export_id", export_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_signals_get_export_download_request( # pylint: disable=name-too-long + export_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/exports/{export_id}/download" + path_format_arguments = { + "export_id": _SERIALIZER.url("export_id", export_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_signals_list_deletions_request( + *, limit: int = 20, after: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/deletions" + + # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query( + "limit", limit, "int", maximum=100, minimum=1 + ) + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_signals_create_deletion_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/deletions" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_signals_get_deletion_request(deletion_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v1/signals/deletions/{deletion_id}" + path_format_arguments = { + "deletion_id": _SERIALIZER.url("deletion_id", deletion_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + def build_kubernetes_list_clusters_request( *, per_page: int = 20, page: int = 1, **kwargs: Any ) -> HttpRequest: @@ -8702,6 +9148,319 @@ def build_load_balancers_remove_forwarding_rules_request( # pylint: disable=nam return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) +def build_microvms_list_request( + *, + page: int = 1, + per_page: int = 25, + region: Optional[str] = None, + name: Optional[str] = None, + tag_name: Optional[str] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms" + + # Construct parameters + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int", minimum=1) + if per_page is not None: + _params["per_page"] = _SERIALIZER.query( + "per_page", per_page, "int", maximum=200, minimum=1 + ) + if region is not None: + _params["region"] = _SERIALIZER.query("region", region, "str") + if name is not None: + _params["name"] = _SERIALIZER.query("name", name, "str") + if tag_name is not None: + _params["tag_name"] = _SERIALIZER.query("tag_name", tag_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_microvms_create_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_microvms_get_options_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/options" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_microvms_get_request(microvm_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/{microvm_id}" + path_format_arguments = { + "microvm_id": _SERIALIZER.url("microvm_id", microvm_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_microvms_delete_request(microvm_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/{microvm_id}" + path_format_arguments = { + "microvm_id": _SERIALIZER.url("microvm_id", microvm_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + + +def build_microvms_post_pause_request(microvm_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/{microvm_id}/pause" + path_format_arguments = { + "microvm_id": _SERIALIZER.url("microvm_id", microvm_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_microvms_post_resume_request(microvm_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/{microvm_id}/resume" + path_format_arguments = { + "microvm_id": _SERIALIZER.url("microvm_id", microvm_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_microvms_run_command_request(microvm_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/{microvm_id}/exec" + path_format_arguments = { + "microvm_id": _SERIALIZER.url("microvm_id", microvm_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_microvms_get_console_request( + microvm_id: str, *, rows: int = 24, cols: int = 80, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/{microvm_id}/console" + path_format_arguments = { + "microvm_id": _SERIALIZER.url("microvm_id", microvm_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if rows is not None: + _params["rows"] = _SERIALIZER.query( + "rows", rows, "int", maximum=65535, minimum=1 + ) + if cols is not None: + _params["cols"] = _SERIALIZER.query( + "cols", cols, "int", maximum=65535, minimum=1 + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_microvm_checkpoints_list_request( + *, + page: int = 1, + per_page: int = 25, + microvm_id: Optional[str] = None, + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/checkpoints" + + # Construct parameters + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int", minimum=1) + if per_page is not None: + _params["per_page"] = _SERIALIZER.query( + "per_page", per_page, "int", maximum=200, minimum=1 + ) + if microvm_id is not None: + _params["microvm_id"] = _SERIALIZER.query("microvm_id", microvm_id, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_microvm_checkpoints_get_request( + checkpoint_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/checkpoints/{checkpoint_id}" + path_format_arguments = { + "checkpoint_id": _SERIALIZER.url("checkpoint_id", checkpoint_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_microvm_checkpoints_delete_request( + checkpoint_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/checkpoints/{checkpoint_id}" + path_format_arguments = { + "checkpoint_id": _SERIALIZER.url("checkpoint_id", checkpoint_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + + +def build_microvm_checkpoints_create_request( + microvm_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/microvms/{microvm_id}/checkpoints" + path_format_arguments = { + "microvm_id": _SERIALIZER.url("microvm_id", microvm_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + def build_monitoring_list_alert_policy_request( # pylint: disable=name-too-long *, per_page: int = 20, page: int = 1, **kwargs: Any ) -> HttpRequest: @@ -18466,7 +19225,7 @@ def build_genai_patch_cancel_simulation_run_request( # pylint: disable=name-too return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) -def build_genai_list_simulation_journeys_request( # pylint: disable=name-too-long +def build_genai_list_simulation_episodes_request( # pylint: disable=name-too-long run_uuid: str, *, scenario_uuid: Optional[str] = None, @@ -18475,7 +19234,7 @@ def build_genai_list_simulation_journeys_request( # pylint: disable=name-too-lo statuses: Optional[List[str]] = None, verdicts: Optional[List[str]] = None, search: Optional[str] = None, - sort_by: str = "SIMULATION_JOURNEY_SORT_FIELD_UNSPECIFIED", + sort_by: str = "SIMULATION_EPISODE_SORT_FIELD_UNSPECIFIED", sort_direction: str = "SORT_DIRECTION_UNSPECIFIED", **kwargs: Any, ) -> HttpRequest: @@ -18485,7 +19244,7 @@ def build_genai_list_simulation_journeys_request( # pylint: disable=name-too-lo accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/v2/gen-ai/simulation_runs/{run_uuid}/journeys" + _url = "/v2/gen-ai/simulation_runs/{run_uuid}/episodes" path_format_arguments = { "run_uuid": _SERIALIZER.url("run_uuid", run_uuid, "str"), } @@ -18522,18 +19281,18 @@ def build_genai_list_simulation_journeys_request( # pylint: disable=name-too-lo ) -def build_genai_get_simulation_journey_request( # pylint: disable=name-too-long - run_uuid: str, journey_uuid: str, **kwargs: Any +def build_genai_get_simulation_episode_request( # pylint: disable=name-too-long + run_uuid: str, episode_uuid: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}" + _url = "/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}" path_format_arguments = { "run_uuid": _SERIALIZER.url("run_uuid", run_uuid, "str"), - "journey_uuid": _SERIALIZER.url("journey_uuid", journey_uuid, "str"), + "episode_uuid": _SERIALIZER.url("episode_uuid", episode_uuid, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -18544,18 +19303,18 @@ def build_genai_get_simulation_journey_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_genai_get_simulation_journey_trajectory_request( # pylint: disable=name-too-long - run_uuid: str, journey_uuid: str, **kwargs: Any +def build_genai_get_simulation_episode_trajectory_request( # pylint: disable=name-too-long + run_uuid: str, episode_uuid: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}/trajectory" + _url = "/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}/trajectory" path_format_arguments = { "run_uuid": _SERIALIZER.url("run_uuid", run_uuid, "str"), - "journey_uuid": _SERIALIZER.url("journey_uuid", journey_uuid, "str"), + "episode_uuid": _SERIALIZER.url("episode_uuid", episode_uuid, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -18566,8 +19325,8 @@ def build_genai_get_simulation_journey_trajectory_request( # pylint: disable=na return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) -def build_genai_get_simulation_journey_trajectory_url_request( # pylint: disable=name-too-long - run_uuid: str, journey_uuid: str, **kwargs: Any +def build_genai_get_simulation_episode_trajectory_url_request( # pylint: disable=name-too-long + run_uuid: str, episode_uuid: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -18575,11 +19334,11 @@ def build_genai_get_simulation_journey_trajectory_url_request( # pylint: disabl # Construct URL _url = ( - "/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}/trajectory_url" + "/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}/trajectory_url" ) path_format_arguments = { "run_uuid": _SERIALIZER.url("run_uuid", run_uuid, "str"), - "journey_uuid": _SERIALIZER.url("journey_uuid", journey_uuid, "str"), + "episode_uuid": _SERIALIZER.url("episode_uuid", episode_uuid, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -42150,7 +42909,8 @@ def create( }, "project_id": "str" # Optional. The ID of the project the app should be assigned to. If omitted, it will be assigned to your default project. - :code:`
`:code:`
`Requires ``project:assign_resource`` scope. + :code:`
`:code:`
`Requires ``project:assign_resource`` and + ``project:update`` scopes. } # response body for status code(s): 200 @@ -58873,7 +59633,8 @@ def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: }, "project_id": "str" # Optional. The ID of the project the app should be assigned to. If omitted, it will be assigned to your default project. - :code:`
`:code:`
`Requires ``project:assign_resource`` scope. + :code:`
`:code:`
`Requires ``project:assign_resource`` and + ``project:update`` scopes. } # response body for status code(s): 200 @@ -184637,42 +185398,249 @@ def post_logs_search( return cast(JSON, deserialized) # type: ignore + @overload + def post_traces_search( + self, + region: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Union[JSON, str]: + # pylint: disable=line-too-long + """Search traces. -class KubernetesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. + To search traces in a region, send a POST request to + ``/v2/insights/query/{region}/traces/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + Each result is one trace, aggregated from all of its spans in the time range. A trace is + included when at least one of its spans matches ``filter``. The time range must not exceed 7 + days (\\ ``168h``\\ ). ``pagination.limit`` defaults to 100 (also used when ``limit`` is + ``0``\\ ) and must be between 0 and 1000. Results are ordered by ``started`` descending unless + ``orderBy`` is set. + JSON field names are camelCase (\\ ``timeRange``\\ , ``orderBy``\\ , ``hasMore``\\ , + ``traceId``\\ ). Unknown request properties, invalid filters, and out-of-range values are + rejected with ``400``. + Each request searches a single region; there is no multi-region search. Supported regions are + ``ams2``\\ , ``ams3``\\ , ``atl1``\\ , ``blr1``\\ , ``fra1``\\ , ``lon1``\\ , ``mem1``\\ , + ``nyc1``\\ , ``nyc2``\\ , ``nyc3``\\ , ``ric1``\\ , ``sfo1``\\ , ``sfo2``\\ , ``sfo3``\\ , + ``sgp1``\\ , ``syd1``\\ , and ``tor1``. Requests time out after 60 seconds. + Errors produced by the traces service (\\ ``400``\\ ) have a ``text/plain`` body containing a + short message. Authentication and authorization errors (\\ ``401``\\ , ``403``\\ ), rate + limiting (\\ ``429``\\ ), and routing errors (for example, ``404`` for an unknown region) come + from the API gateway and use the standard JSON error object with ``id`` and ``message``. + ``403`` is also returned for accounts that are in a trial or not in good standing. If the + regional traces backend cannot be reached, the response is ``502`` with a ``text/plain`` body. - Instead, you should access the following operations through - :class:`~pydo.GeneratedClient`'s - :attr:`kubernetes` attribute. - """ + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or str + :rtype: JSON or str + :raises ~azure.core.exceptions.HttpResponseError: - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = ( - input_args.pop(0) if input_args else kwargs.pop("deserializer") - ) + Example: + .. code-block:: python - @distributed_trace - def list_clusters( - self, *, per_page: int = 20, page: int = 1, **kwargs: Any - ) -> JSON: + # JSON input template you can fill out and use as your body input. + body = { + "timeRange": { + "from": { + "absolute": "str", # Optional. An absolute timestamp, either + RFC3339 (with optional fractional seconds) or a Unix epoch integer as a + decimal string. Epoch precision is inferred from magnitude: seconds, + milliseconds, microseconds, or nanoseconds. + "relative": "str" # Optional. A time relative to now. Use + ``now`` for the current time, a bare duration such as ``15m`` or ``24h`` + to look back from now, or an offset such as ``now-2h`` or ``now+30m``. + Supported units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``"" ; + decimal amounts such as ``1.5h`` are allowed. + }, + "to": { + "absolute": "str", # Optional. An absolute timestamp, either + RFC3339 (with optional fractional seconds) or a Unix epoch integer as a + decimal string. Epoch precision is inferred from magnitude: seconds, + milliseconds, microseconds, or nanoseconds. + "relative": "str" # Optional. A time relative to now. Use + ``now`` for the current time, a bare duration such as ``15m`` or ``24h`` + to look back from now, or an offset such as ``now-2h`` or ``now+30m``. + Supported units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``"" ; + decimal amounts such as ``1.5h`` are allowed. + } + }, + "filter": { + "expressions": [ + ... + ], + "field": { + "name": "str", # The field name. Without ``scope``"" , these + names (case-insensitive) resolve to built-in span columns: `traceId` + (`trace.id`, `trace_id`), `spanId` (`span.id`, `span_id`), `parentSpanId` + (`parent.span.id`, `parent_span_id`), `startTime` (`start_time`, + `timestamp`), `endTime` (`end_time`), `durationNs` (`duration`, in + nanoseconds), `name` (`span.name`), `kind` (`span.kind`), `statusCode` + (`status.code`, `status_code`), `statusMessage` (`status.message`, + `status_message`), and `serviceName` (`service.name`, `service_name`). + Any other name is looked up as a span attribute, falling back to a + resource attribute. With `scope` set, `name` is always treated as an + attribute key. Attribute keys may contain only letters, digits, and `.`, + `_`, `-`, `/`, `:`, `@`. In traces ``orderBy``"" , ``name`` must be a + trace-level sort field instead; see the ``orderBy`` field description. + Required. + "scope": "str" # Optional. Restricts the lookup to one + attribute map (case-insensitive). ``resource`` (or + ``resource.attributes``"" ) reads resource attributes; ``attribute`` (or + ``attributes``"" , ``span.attributes``"" ) reads span attributes. Omit to + use the built-in column mapping described for ``name``. Ignored in traces + ``orderBy``. Known values are: "resource", "resource.attributes", + "attribute", "attributes", and "span.attributes". + }, + "operator": "str", # Optional. The comparison operator for a + ``condition`` node. Matching is case-insensitive, and the symbol forms + ``=``"" , ``!=``"" , ``>``"" , ``>=``"" , ``<``"" , and ``<=`` are accepted + as aliases for ``eq``"" , ``neq``"" , ``gt``"" , ``gte``"" , ``lt``"" , and + ``lte``. ``exists`` matches spans where the field is present and non-empty + and ignores ``value``. ``in`` requires an array ``value`` with 1 to 100 + entries. ``neq`` on string fields also matches spans where the field is + absent. Known values are: "eq", "neq", "in", "exists", "gt", "gte", "lt", and + "lte". + "query": "str", # Optional. The search string for a ``text_search`` + node. Leading and trailing whitespace is trimmed; the trimmed string must be + non-empty. + "type": "condition", # Optional. Default value is "condition". The + node type. Matching is case-insensitive. Known values are: "condition", + "and", "or", "not", and "text_search". + "value": {} + }, + "orderBy": [ + { + "field": { + "name": "str", # The field name. Without ``scope``"" + , these names (case-insensitive) resolve to built-in span columns: + `traceId` (`trace.id`, `trace_id`), `spanId` (`span.id`, `span_id`), + `parentSpanId` (`parent.span.id`, `parent_span_id`), `startTime` + (`start_time`, `timestamp`), `endTime` (`end_time`), `durationNs` + (`duration`, in nanoseconds), `name` (`span.name`), `kind` + (`span.kind`), `statusCode` (`status.code`, `status_code`), + `statusMessage` (`status.message`, `status_message`), and + `serviceName` (`service.name`, `service_name`). Any other name is + looked up as a span attribute, falling back to a resource attribute. + With `scope` set, `name` is always treated as an attribute key. + Attribute keys may contain only letters, digits, and `.`, `_`, `-`, + `/`, `:`, `@`. In traces ``orderBy``"" , ``name`` must be a + trace-level sort field instead; see the ``orderBy`` field + description. Required. + "scope": "str" # Optional. Restricts the lookup to + one attribute map (case-insensitive). ``resource`` (or + ``resource.attributes``"" ) reads resource attributes; ``attribute`` + (or ``attributes``"" , ``span.attributes``"" ) reads span attributes. + Omit to use the built-in column mapping described for ``name``. + Ignored in traces ``orderBy``. Known values are: "resource", + "resource.attributes", "attribute", "attributes", and + "span.attributes". + }, + "direction": "desc" # Optional. Default value is "desc". The + sort direction (case-insensitive). Defaults to ``desc``. Known values + are: "asc" and "desc". + } + ], + "pagination": { + "limit": 100 # Optional. Default value is 100. Maximum number of + traces to return. Omitted or ``0`` uses the default of 100. Negative values + or values above 1000 return ``400``"" ; they are not clamped. + } + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "traceId": "str", # The trace identifier. Required. + "durationNs": 0, # Optional. Wall-clock duration of the + trace in nanoseconds. + "errorCount": 0, # Optional. The number of spans in the + trace with an ``Error`` status code. Omitted when zero. + "serviceName": "str", # Optional. The service that emitted + the root span. Omitted when the root span has no service.name resource + attribute. + "spanCount": 0, # Optional. The number of spans in the + trace. + "spanNames": [ + "str" # Optional. The distinct span names present in + the trace. + ], + "started": "2020-02-20 00:00:00", # Optional. The start time + of the earliest span in the trace, in RFC 3339 format. + "status": "str" # Optional. The rolled-up status of the + trace. ``Error`` if any span has an ``Error`` status code, otherwise + ``Ok``. Known values are: "Ok" and "Error". + } + ], + "pagination": { + "hasMore": bool # Whether more results matched the query than were + returned. Required. + } + } + # response body for status code(s): 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def post_traces_search( + self, + region: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Union[JSON, str]: # pylint: disable=line-too-long - """List All Kubernetes Clusters. + """Search traces. - To list all of the Kubernetes clusters on your account, send a GET request - to ``/v2/kubernetes/clusters``. + To search traces in a region, send a POST request to + ``/v2/insights/query/{region}/traces/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + Each result is one trace, aggregated from all of its spans in the time range. A trace is + included when at least one of its spans matches ``filter``. The time range must not exceed 7 + days (\\ ``168h``\\ ). ``pagination.limit`` defaults to 100 (also used when ``limit`` is + ``0``\\ ) and must be between 0 and 1000. Results are ordered by ``started`` descending unless + ``orderBy`` is set. + JSON field names are camelCase (\\ ``timeRange``\\ , ``orderBy``\\ , ``hasMore``\\ , + ``traceId``\\ ). Unknown request properties, invalid filters, and out-of-range values are + rejected with ``400``. + Each request searches a single region; there is no multi-region search. Supported regions are + ``ams2``\\ , ``ams3``\\ , ``atl1``\\ , ``blr1``\\ , ``fra1``\\ , ``lon1``\\ , ``mem1``\\ , + ``nyc1``\\ , ``nyc2``\\ , ``nyc3``\\ , ``ric1``\\ , ``sfo1``\\ , ``sfo2``\\ , ``sfo3``\\ , + ``sgp1``\\ , ``syd1``\\ , and ``tor1``. Requests time out after 60 seconds. + Errors produced by the traces service (\\ ``400``\\ ) have a ``text/plain`` body containing a + short message. Authentication and authorization errors (\\ ``401``\\ , ``403``\\ ), rate + limiting (\\ ``429``\\ ), and routing errors (for example, ``404`` for an unknown region) come + from the API gateway and use the standard JSON error object with ``id`` and ``message``. + ``403`` is also returned for accounts that are in a trial or not in good standing. If the + regional traces backend cannot be reached, the response is ``502`` with a ``text/plain`` body. - :keyword per_page: Number of items returned per page. Default value is 20. - :paramtype per_page: int - :keyword page: Which 'page' of paginated results to return. Default value is 1. - :paramtype page: int - :return: JSON object - :rtype: JSON + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or str + :rtype: JSON or str :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -184680,272 +185648,237 @@ def list_clusters( # response body for status code(s): 200 response == { - "meta": { - "total": 0 # Optional. Number of objects returned by the request. + "data": [ + { + "traceId": "str", # The trace identifier. Required. + "durationNs": 0, # Optional. Wall-clock duration of the + trace in nanoseconds. + "errorCount": 0, # Optional. The number of spans in the + trace with an ``Error`` status code. Omitted when zero. + "serviceName": "str", # Optional. The service that emitted + the root span. Omitted when the root span has no service.name resource + attribute. + "spanCount": 0, # Optional. The number of spans in the + trace. + "spanNames": [ + "str" # Optional. The distinct span names present in + the trace. + ], + "started": "2020-02-20 00:00:00", # Optional. The start time + of the earliest span in the trace, in RFC 3339 format. + "status": "str" # Optional. The rolled-up status of the + trace. ``Error`` if any span has an ``Error`` status code, otherwise + ``Ok``. Known values are: "Ok" and "Error". + } + ], + "pagination": { + "hasMore": bool # Whether more results matched the query than were + returned. Required. + } + } + # response body for status code(s): 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def post_traces_search( + self, region: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Union[JSON, str]: + # pylint: disable=line-too-long + """Search traces. + + To search traces in a region, send a POST request to + ``/v2/insights/query/{region}/traces/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + Each result is one trace, aggregated from all of its spans in the time range. A trace is + included when at least one of its spans matches ``filter``. The time range must not exceed 7 + days (\\ ``168h``\\ ). ``pagination.limit`` defaults to 100 (also used when ``limit`` is + ``0``\\ ) and must be between 0 and 1000. Results are ordered by ``started`` descending unless + ``orderBy`` is set. + JSON field names are camelCase (\\ ``timeRange``\\ , ``orderBy``\\ , ``hasMore``\\ , + ``traceId``\\ ). Unknown request properties, invalid filters, and out-of-range values are + rejected with ``400``. + Each request searches a single region; there is no multi-region search. Supported regions are + ``ams2``\\ , ``ams3``\\ , ``atl1``\\ , ``blr1``\\ , ``fra1``\\ , ``lon1``\\ , ``mem1``\\ , + ``nyc1``\\ , ``nyc2``\\ , ``nyc3``\\ , ``ric1``\\ , ``sfo1``\\ , ``sfo2``\\ , ``sfo3``\\ , + ``sgp1``\\ , ``syd1``\\ , and ``tor1``. Requests time out after 60 seconds. + Errors produced by the traces service (\\ ``400``\\ ) have a ``text/plain`` body containing a + short message. Authentication and authorization errors (\\ ``401``\\ , ``403``\\ ), rate + limiting (\\ ``429``\\ ), and routing errors (for example, ``404`` for an unknown region) come + from the API gateway and use the standard JSON error object with ``id`` and ``message``. + ``403`` is also returned for accounts that are in a trial or not in good standing. If the + regional traces backend cannot be reached, the response is ``502`` with a ``text/plain`` body. + + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object or str + :rtype: JSON or str + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "timeRange": { + "from": { + "absolute": "str", # Optional. An absolute timestamp, either + RFC3339 (with optional fractional seconds) or a Unix epoch integer as a + decimal string. Epoch precision is inferred from magnitude: seconds, + milliseconds, microseconds, or nanoseconds. + "relative": "str" # Optional. A time relative to now. Use + ``now`` for the current time, a bare duration such as ``15m`` or ``24h`` + to look back from now, or an offset such as ``now-2h`` or ``now+30m``. + Supported units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``"" ; + decimal amounts such as ``1.5h`` are allowed. + }, + "to": { + "absolute": "str", # Optional. An absolute timestamp, either + RFC3339 (with optional fractional seconds) or a Unix epoch integer as a + decimal string. Epoch precision is inferred from magnitude: seconds, + milliseconds, microseconds, or nanoseconds. + "relative": "str" # Optional. A time relative to now. Use + ``now`` for the current time, a bare duration such as ``15m`` or ``24h`` + to look back from now, or an offset such as ``now-2h`` or ``now+30m``. + Supported units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``"" ; + decimal amounts such as ``1.5h`` are allowed. + } }, - "kubernetes_clusters": [ + "filter": { + "expressions": [ + ... + ], + "field": { + "name": "str", # The field name. Without ``scope``"" , these + names (case-insensitive) resolve to built-in span columns: `traceId` + (`trace.id`, `trace_id`), `spanId` (`span.id`, `span_id`), `parentSpanId` + (`parent.span.id`, `parent_span_id`), `startTime` (`start_time`, + `timestamp`), `endTime` (`end_time`), `durationNs` (`duration`, in + nanoseconds), `name` (`span.name`), `kind` (`span.kind`), `statusCode` + (`status.code`, `status_code`), `statusMessage` (`status.message`, + `status_message`), and `serviceName` (`service.name`, `service_name`). + Any other name is looked up as a span attribute, falling back to a + resource attribute. With `scope` set, `name` is always treated as an + attribute key. Attribute keys may contain only letters, digits, and `.`, + `_`, `-`, `/`, `:`, `@`. In traces ``orderBy``"" , ``name`` must be a + trace-level sort field instead; see the ``orderBy`` field description. + Required. + "scope": "str" # Optional. Restricts the lookup to one + attribute map (case-insensitive). ``resource`` (or + ``resource.attributes``"" ) reads resource attributes; ``attribute`` (or + ``attributes``"" , ``span.attributes``"" ) reads span attributes. Omit to + use the built-in column mapping described for ``name``. Ignored in traces + ``orderBy``. Known values are: "resource", "resource.attributes", + "attribute", "attributes", and "span.attributes". + }, + "operator": "str", # Optional. The comparison operator for a + ``condition`` node. Matching is case-insensitive, and the symbol forms + ``=``"" , ``!=``"" , ``>``"" , ``>=``"" , ``<``"" , and ``<=`` are accepted + as aliases for ``eq``"" , ``neq``"" , ``gt``"" , ``gte``"" , ``lt``"" , and + ``lte``. ``exists`` matches spans where the field is present and non-empty + and ignores ``value``. ``in`` requires an array ``value`` with 1 to 100 + entries. ``neq`` on string fields also matches spans where the field is + absent. Known values are: "eq", "neq", "in", "exists", "gt", "gte", "lt", and + "lte". + "query": "str", # Optional. The search string for a ``text_search`` + node. Leading and trailing whitespace is trimmed; the trimmed string must be + non-empty. + "type": "condition", # Optional. Default value is "condition". The + node type. Matching is case-insensitive. Known values are: "condition", + "and", "or", "not", and "text_search". + "value": {} + }, + "orderBy": [ { - "name": "str", # A human-readable name for a Kubernetes - cluster. Required. - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean - value indicating whether auto-scaling is enabled for this node - pool. - "count": 0, # Optional. The number of - Droplet instances in the node pool. - "gpu_partition_mode": "str", # Optional. The - AMD GPU partition mode for this node pool. Only applicable to AMD - GPU sizes that support partitioning. Immutable after the node - pool is created. When omitted, the GPUs in the pool are left - unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" - and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that - can be used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of - key/value mappings specifying labels to apply to all nodes in a - pool. Labels will automatically be applied to all existing nodes - and any subsequent nodes added to the pool. Note that when a - label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum - number of nodes that this node pool can be auto-scaled to. The - value will be ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum - number of nodes that this node pool can be auto-scaled to. The - value will be ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable - name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 - 00:00:00", # Optional. A time value given in ISO8601 - combined date and time format that represents when the - node was created. - "droplet_id": "str", # - Optional. The ID of the Droplet used for the worker node. - "id": "str", # Optional. A - unique ID that can be used to identify and reference the - node. - "name": "str", # Optional. - An automatically generated, human-readable name for the - node. - "status": { - "state": "str" # - Optional. A string indicating the current status of - the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 - 00:00:00" # Optional. A time value given in ISO8601 - combined date and time format that represents when the - node was last updated. - } - ], - "size": "str", # Optional. The slug - identifier for the type of Droplet used as workers in the node - pool. - "tags": [ - "str" # Optional. An array - containing the tags applied to the node pool. All node pools - are automatically tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. - How the node reacts to pods that it won't tolerate. - Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values - are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if - the value of the ``key`` field is "special" and the value - of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. - An arbitrary string. The ``key`` and ``value`` fields of - the ``taint`` object form a key-value pair. For example, - if the value of the ``key`` field is "special" and the - value of the ``value`` field is "gpu", the key value pair - would be ``special=gpu``. - } - ] - } - ], - "region": "str", # The slug identifier for the region where - the Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), - the latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available - versions. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the - AMD Device Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the - AMD GPU Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the - AMD GPU DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether the cluster will be automatically - upgraded to new patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used - by cluster-autoscaler. The autoscaler will apply each expander - from the provided list to narrow down the selection of node types - created to scale up, until either a single node type is left, or - the list of expanders is exhausted. If this flag is unset, - autoscaler will use its default expander ``random``. Passing an - empty list ("" *not* ``null``"" ) will unset any previous - expander customizations. Available expanders: * ``random``"" : - Randomly selects a node group to scale. * `priority`: Selects the - node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in - the least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used - to customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. - Used to customize when cluster autoscaler scales down non-empty nodes - by setting the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP - addresses for the overlay network of the Kubernetes cluster in CIDR - notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public - addresses (IPv4 or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the - control plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the - CoreDNS Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the Kubernetes cluster was created. - "endpoint": "str", # Optional. The base URL of the API - server on the Kubernetes master node. - "ha": False, # Optional. Default value is False. A boolean - value indicating whether the control plane is run in a highly available - configuration in the cluster. Highly available control planes incur less - downtime. The property cannot be disabled. When omitted on create, the - default is version-dependent; for DOKS 1.36.0 and later, the default is - true; for earlier versions, the default is false. - "id": "str", # Optional. A unique ID that can be used to - identify and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the - Kubernetes master node. This will not be set if high availability is - configured on the cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is - False. A boolean value indicating whether worker nodes in the cluster are - not assigned public IP addresses. When omitted on create, the default - value is false. When enabled, a NAT gateway must exist in the VPC where - the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance - window policy. May be one of ``monday`` through ``sunday``"" , or - ``any`` to indicate an arbitrary week day. Known values are: "any", - "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", - and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in - UTC of the maintenance window policy in 24-hour clock format / HH:MM - notation (e.g., ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the - NFS CSI plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the - Nvidia GPU Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the - NVIDIA GPU DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the - RDMA shared device plugin is enabled. - }, - "registries": [ - "str" # Optional. An array of integrated DOCR - registries. - ], - "registry_enabled": bool, # Optional. A read-only boolean - value indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable - IP addresses for services running in the Kubernetes cluster in CIDR - notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is - False. Indicates whether SSO authentication is enabled for the - cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL - for the identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is - False. Indicates whether any non-SSO forms of authentication are - disallowed. Can only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message - providing additional information about the current cluster state. - "state": "str" # Optional. A string indicating the - current status of the cluster. Known values are: "running", - "provisioning", "degraded", "error", "deleted", "upgrading", and - "deleting". + "field": { + "name": "str", # The field name. Without ``scope``"" + , these names (case-insensitive) resolve to built-in span columns: + `traceId` (`trace.id`, `trace_id`), `spanId` (`span.id`, `span_id`), + `parentSpanId` (`parent.span.id`, `parent_span_id`), `startTime` + (`start_time`, `timestamp`), `endTime` (`end_time`), `durationNs` + (`duration`, in nanoseconds), `name` (`span.name`), `kind` + (`span.kind`), `statusCode` (`status.code`, `status_code`), + `statusMessage` (`status.message`, `status_message`), and + `serviceName` (`service.name`, `service_name`). Any other name is + looked up as a span attribute, falling back to a resource attribute. + With `scope` set, `name` is always treated as an attribute key. + Attribute keys may contain only letters, digits, and `.`, `_`, `-`, + `/`, `:`, `@`. In traces ``orderBy``"" , ``name`` must be a + trace-level sort field instead; see the ``orderBy`` field + description. Required. + "scope": "str" # Optional. Restricts the lookup to + one attribute map (case-insensitive). ``resource`` (or + ``resource.attributes``"" ) reads resource attributes; ``attribute`` + (or ``attributes``"" , ``span.attributes``"" ) reads span attributes. + Omit to use the built-in column mapping described for ``name``. + Ignored in traces ``orderBy``. Known values are: "resource", + "resource.attributes", "attribute", "attributes", and + "span.attributes". }, - "surge_upgrade": False, # Optional. Default value is False. - A boolean value indicating whether surge upgrade is enabled/disabled for - the cluster. Surge upgrade makes cluster upgrades fast and reliable by - bringing up new nodes before destroying the outdated nodes. - "tags": [ - "str" # Optional. An array of tags applied to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the Kubernetes cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID - of the VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC - subnet worker nodes are attached to. When unset, the default subnet for - the VPC is used.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "direction": "desc" # Optional. Default value is "desc". The + sort direction (case-insensitive). Defaults to ``desc``. Known values + are: "asc" and "desc". } ], - "links": { - "pages": {} + "pagination": { + "limit": 100 # Optional. Default value is 100. Maximum number of + traces to return. Omitted or ``0`` uses the default of 100. Negative values + or values above 1000 return ``400``"" ; they are not clamped. + } + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "traceId": "str", # The trace identifier. Required. + "durationNs": 0, # Optional. Wall-clock duration of the + trace in nanoseconds. + "errorCount": 0, # Optional. The number of spans in the + trace with an ``Error`` status code. Omitted when zero. + "serviceName": "str", # Optional. The service that emitted + the root span. Omitted when the root span has no service.name resource + attribute. + "spanCount": 0, # Optional. The number of spans in the + trace. + "spanNames": [ + "str" # Optional. The distinct span names present in + the trace. + ], + "started": "2020-02-20 00:00:00", # Optional. The start time + of the earliest span in the trace, in RFC 3339 format. + "status": "str" # Optional. The rolled-up status of the + trace. ``Error`` if any span has an ``Error`` status code, otherwise + ``Ok``. Known values are: "Ok" and "Error". + } + ], + "pagination": { + "hasMore": bool # Whether more results matched the query than were + returned. Required. } } + # response body for status code(s): 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -184960,14 +185893,27 @@ def list_clusters( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Union[JSON, str]] = kwargs.pop("cls", None) - _request = build_kubernetes_list_clusters_request( - per_page=per_page, - page=page, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_insights_post_traces_search_request( + region=region, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -184982,50 +185928,389 @@ def list_clusters( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 400, 403, 404, 404, 502]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 502: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(Union[JSON, str], deserialized), response_headers) # type: ignore + + return cast(Union[JSON, str], deserialized) # type: ignore + + @distributed_trace + def get_trace( + self, + region: str, + trace_id: str, + *, + from_parameter: Optional[str] = None, + to: Optional[str] = None, + **kwargs: Any, + ) -> Union[JSON, str]: + # pylint: disable=line-too-long + """Retrieve an existing trace. + + To retrieve a single trace and all of its spans, send a GET request to + ``/v2/insights/query/{region}/traces/{trace_id}``. + Only spans that started within the lookup window are returned. The window defaults to the last + 7 days and can be narrowed with the ``from`` and ``to`` query parameters; it must not exceed 7 + days, and ``from`` must not be after ``to``. Spans are returned ordered by start time. At most + 10,000 spans are returned; ``truncated`` is ``true`` when the trace has more. + A trace ID with no spans in the window returns ``404``\\ , as do malformed or uppercase trace + IDs. A trace is only resolvable in the region that ingested it; querying another region also + returns ``404``. + Supported regions are ``ams2``\\ , ``ams3``\\ , ``atl1``\\ , ``blr1``\\ , ``fra1``\\ , + ``lon1``\\ , ``mem1``\\ , ``nyc1``\\ , ``nyc2``\\ , ``nyc3``\\ , ``ric1``\\ , ``sfo1``\\ , + ``sfo2``\\ , ``sfo3``\\ , ``sgp1``\\ , ``syd1``\\ , and ``tor1``. Requests time out after 60 + seconds. + Errors produced by the traces service (\\ ``400``\\ , and ``404`` when no trace is found) have + a ``text/plain`` body containing a short message. Authentication and authorization errors (\\ + ``401``\\ , ``403``\\ ), rate limiting (\\ ``429``\\ ), and routing errors (for example, + ``404`` for an unknown region) come from the API gateway and use the standard JSON error object + with ``id`` and ``message``. ``403`` is also returned for accounts that are in a trial or not + in good standing. If the regional traces backend cannot be reached, the response is ``502`` + with a ``text/plain`` body. + JSON field names are camelCase (\\ ``traceId``\\ , ``spanId``\\ , ``startTime``\\ , + ``endTime``\\ , ``durationNs``\\ , ``serviceName``\\ , ``statusCode``\\ , ``parentSpanId``\\ ). + + :param region: The datacenter region slug for the query. Required. + :type region: str + :param trace_id: The OpenTelemetry trace ID to retrieve, as 32 lowercase hexadecimal + characters. IDs are matched exactly; an ID with no spans in the lookup window returns ``404``. + Malformed or uppercase IDs are not rejected with ``400``\\ ; they also return ``404``. + Required. + :type trace_id: str + :keyword from_parameter: Start of the trace lookup window. Accepts a relative time (\\ + ``now``\\ , a bare duration such as ``24h`` to look back from now, or ``now-2h``\\ ) or an + absolute time (RFC3339, or a Unix epoch integer in seconds, milliseconds, microseconds, or + nanoseconds). Defaults to 7 days before now. Default value is None. + :paramtype from_parameter: str + :keyword to: End of the trace lookup window, in the same formats as ``from``. Defaults to now. + Default value is None. + :paramtype to: str + :return: JSON object or str + :rtype: JSON or str + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "spans": [ + { + "spanId": "str", # The span identifier. Required. + "traceId": "str", # The trace this span belongs to. + Required. + "attributes": { + "str": "str" # Optional. Span attributes. Omitted + when empty. + }, + "durationNs": 0, # Optional. Span duration in nanoseconds. + "endTime": "2020-02-20 00:00:00", # Optional. The span end + time. + "kind": "str", # Optional. The OpenTelemetry span kind as a + string, for example ``Server``"" , ``Client``"" , or ``Internal``. + "name": "str", # Optional. The span name, typically the + operation being performed. + "parentSpanId": "str", # Optional. The parent span + identifier. Omitted for the root span. + "resource": { + "str": "str" # Optional. Resource attributes + associated with the span. + }, + "serviceName": "str", # Optional. The service that emitted + the span. Omitted when the span has no service.name resource attribute. + "startTime": "2020-02-20 00:00:00", # Optional. The span + start time. + "statusCode": "str", # Optional. The OpenTelemetry span + status code as a string: ``Unset``"" , ``Ok``"" , or ``Error``. + "statusMessage": "str" # Optional. The status description. + Omitted when empty. + } + ], + "traceId": "str", # Optional. The trace identifier. + "truncated": bool # Optional. True when the trace has more spans than were + returned in this response. Omitted when false. + } + # response body for status code(s): 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Union[JSON, str]] = kwargs.pop("cls", None) + + _request = build_insights_get_trace_request( + region=region, + trace_id=trace_id, + from_parameter=from_parameter, + to=to, + headers=_headers, + params=_params, ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) ) - if response.content: - deserialized = response.json() - else: - deserialized = None + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 403, 404, 404, 502]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 502: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(Union[JSON, str], deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return cast(Union[JSON, str], deserialized) # type: ignore @overload - def create_cluster( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + def post_spans_search( + self, + region: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Create a New Kubernetes Cluster. - - To create a new Kubernetes cluster, send a POST request to - ``/v2/kubernetes/clusters``. The request must contain at least one node pool - with at least one worker. + """Search spans. - The request may contain a maintenance window policy describing a time period - when disruptive maintenance tasks may be carried out. Omitting the policy - implies that a window will be chosen automatically. See - `here `_ - for details. + To search spans in a region, send a POST request to + ``/v2/insights/query/{region}/spans/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + The time range must not exceed 7 days. ``pagination.limit`` defaults to 100 and must be between + 1 and 1000. Results are ordered by ``startTime`` descending by default. Cursor-based pagination + is not yet supported; ``pagination.hasMore`` indicates whether additional spans matched beyond + the returned page. + :param region: The datacenter region slug for the query. Required. + :type region: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -185040,507 +186325,751 @@ def create_cluster( # JSON input template you can fill out and use as your body input. body = { - "name": "str", # A human-readable name for a Kubernetes cluster. Required. - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean value indicating - whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in - the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes that - support partitioning. Immutable after the node pool is created. When - omitted, the GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to - identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings - specifying labels to apply to all nodes in a pool. Labels will - automatically be applied to all existing nodes and any subsequent nodes - added to the pool. Note that when a label is removed, it is not deleted - from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that - this node pool can be auto-scaled to. The value will be ``0`` if - ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that - this node pool can be auto-scaled to. The value will be ``0`` if - ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for the - node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # - Optional. A time value given in ISO8601 combined date and time - format that represents when the node was created. - "droplet_id": "str", # Optional. The ID of - the Droplet used for the worker node. - "id": "str", # Optional. A unique ID that - can be used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # - Optional. A time value given in ISO8601 combined date and time - format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type - of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags - applied to the node pool. All node pools are automatically tagged - ``k8s``"" , ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node - reacts to pods that it won't tolerate. Available effect values - are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary - string. The ``key`` and ``value`` fields of the ``taint`` object - form a key-value pair. For example, if the value of the ``key`` - field is "special" and the value of the ``value`` field is "gpu", - the key value pair would be ``special=gpu``. - "value": "str" # Optional. An arbitrary - string. The ``key`` and ``value`` fields of the ``taint`` object - form a key-value pair. For example, if the value of the ``key`` - field is "special" and the value of the ``value`` field is "gpu", - the key value pair would be ``special=gpu``. - } - ] + "timeRange": { + "from": { + "absolute": "str", # Optional. An absolute timestamp. + Accepts an RFC3339/RFC3339Nano string or a Unix timestamp (seconds, + milliseconds, microseconds, or nanoseconds) encoded as a decimal string. + "relative": "str" # Optional. A relative time. Use ``now`` + for the current time, a bare duration such as ``1h`` or ``7d`` to look + back from now, or an offset such as ``now-15m`` or ``now+30m``. Supported + units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``. + }, + "to": { + "absolute": "str", # Optional. An absolute timestamp. + Accepts an RFC3339/RFC3339Nano string or a Unix timestamp (seconds, + milliseconds, microseconds, or nanoseconds) encoded as a decimal string. + "relative": "str" # Optional. A relative time. Use ``now`` + for the current time, a bare duration such as ``1h`` or ``7d`` to look + back from now, or an offset such as ``now-15m`` or ``now+30m``. Supported + units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``. } - ], - "region": "str", # The slug identifier for the region where the Kubernetes - cluster is located. Required. - "version": "str", # The slug identifier for the version of Kubernetes used - for the cluster. If set to a minor version (e.g. "1.14"), the latest version - within it will be used (e.g. "1.14.6-do.1"); if set to "latest", the latest - published version will be used. See the ``/v2/kubernetes/options`` endpoint to - find all currently available versions. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device Metrics - Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU Device - Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver - is enabled. }, - "auto_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether the cluster will be automatically upgraded to new patch - releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to scale - up, until either a single node type is left, or the list of expanders is - exhausted. If this flag is unset, autoscaler will use its default - expander ``random``. Passing an empty list ("" *not* ``null``"" ) will - unset any previous expander customizations. Available expanders: * - ``random``"" : Randomly selects a node group to scale. * `priority`: - Selects the node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to customize how - long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting the - node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for the - overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 or - CIDR) allowed to access the control plane. + "filter": { + "type": "str", # The node kind. Required. Known values are: + "condition", "and", "or", "not", and "text_search". + "expressions": [ + ... ], - "enabled": bool # Optional. Indicates whether the control plane - firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS Cluster - Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the Kubernetes cluster - was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the control plane - is run in a highly available configuration in the cluster. Highly available - control planes incur less downtime. The property cannot be disabled. When omitted - on create, the default is version-dependent; for DOKS 1.36.0 and later, the - default is true; for earlier versions, the default is false. - "id": "str", # Optional. A unique ID that can be used to identify and - reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes master - node. This will not be set if high availability is configured on the cluster - (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A boolean - value indicating whether worker nodes in the cluster are not assigned public IP - addresses. When omitted on create, the default value is false. When enabled, a - NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window policy. - May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an - arbitrary week day. Known values are: "any", "monday", "tuesday", - "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the maintenance - window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI plugin is - enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU Device - Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA - Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI - registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA shared device - plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value indicating - if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the routing-agent - component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP addresses - for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID registered with - the identity provider. Required when ``enabled`` is ``true``. - "enabled": False, # Optional. Default value is False. Indicates - whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. Indicates - whether any non-SSO forms of authentication are disallowed. Can only be set - to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current status of - the cluster. Known values are: "running", "provisioning", "degraded", - "error", "deleted", "upgrading", and "deleting". + "field": { + "name": "str", # The field name. Well-known span fields + include ``traceId``"" , ``spanId``"" , ``parentSpanId``"" , + ``startTime``"" , ``endTime``"" , ``durationNs``"" , ``name``"" , + ``serviceName``"" , ``kind``"" , ``statusCode``"" , and + ``statusMessage``. Any other value is treated as a span or resource + attribute key. Required. + "scope": "str" # Optional. Optional attribute scope. Use + ``resource`` to match a resource attribute or ``attributes`` to match a + span attribute. Omit for well-known fields or to search both attribute + maps. Known values are: "resource" and "attributes". + }, + "operator": "str", # Optional. The comparison operator for a + ``condition`` node. Known values are: "eq", "neq", "gt", "gte", "lt", "lte", + "in", and "exists". + "query": "str", # Optional. The substring to match for a + ``text_search`` node. + "value": {} }, - "surge_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether surge upgrade is enabled/disabled for the cluster. Surge - upgrade makes cluster upgrades fast and reliable by bringing up new nodes before - destroying the outdated nodes. - "tags": [ - "str" # Optional. An array of tags to apply to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` and - ``tag:create`` scope, as well as ``tag:delete`` if existing tags are getting - removed. + "orderBy": [ + { + "field": { + "name": "str", # The field name. Well-known span + fields include ``traceId``"" , ``spanId``"" , ``parentSpanId``"" , + ``startTime``"" , ``endTime``"" , ``durationNs``"" , ``name``"" , + ``serviceName``"" , ``kind``"" , ``statusCode``"" , and + ``statusMessage``. Any other value is treated as a span or resource + attribute key. Required. + "scope": "str" # Optional. Optional attribute scope. + Use ``resource`` to match a resource attribute or ``attributes`` to + match a span attribute. Omit for well-known fields or to search both + attribute maps. Known values are: "resource" and "attributes". + }, + "direction": "str" # Optional. The sort direction. Defaults + to ``desc`` when omitted. Known values are: "asc" and "desc". + } ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the Kubernetes cluster - was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the VPC to - which the Kubernetes cluster is assigned.:code:`
`:code:`
`Requires - ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet to attach - worker nodes to. When omitted on create, the default subnet for the VPC is used. - This value cannot be changed after the cluster is created. ``vpc_uuid`` must - also be set. :code:`
`:code:`
`Requires ``vpc:read`` scope. + "pagination": { + "limit": 100 # Optional. Default value is 100. Maximum number of + spans to return. Defaults to 100 and must be between 1 and 1000. + } } - # response body for status code(s): 201 + # response body for status code(s): 200 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] - } - ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". + "data": [ + { + "attributes": { + "str": "str" # Optional. Span attributes. + }, + "durationNs": 0, # Optional. The span duration in + nanoseconds. + "endTime": "2020-02-20 00:00:00", # Optional. The span end + time. + "kind": "str", # Optional. The span kind. + "name": "str", # Optional. The span name. + "parentSpanId": "str", # Optional. The parent span + identifier. Omitted for root spans. + "region": "str", # Optional. The datacenter region slug the + span was queried from. + "resource": { + "str": "str" # Optional. Resource attributes + associated with the span. + }, + "serviceName": "str", # Optional. The name of the service + that emitted the span. + "spanId": "str", # Optional. The span identifier. + "startTime": "2020-02-20 00:00:00", # Optional. The span + start time. + "statusCode": "str", # Optional. The span status code. + "statusMessage": "str", # Optional. The span status message. + Omitted when empty. + "traceId": "str" # Optional. The trace identifier the span + belongs to. + } + ], + "pagination": { + "hasMore": bool # Optional. Whether more spans matched than were + returned in this page. Cursor-based continuation is not yet supported. + } + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def post_spans_search( + self, + region: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Search spans. + + To search spans in a region, send a POST request to + ``/v2/insights/query/{region}/spans/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + The time range must not exceed 7 days. ``pagination.limit`` defaults to 100 and must be between + 1 and 1000. Results are ordered by ``startTime`` descending by default. Cursor-based pagination + is not yet supported; ``pagination.hasMore`` indicates whether additional spans matched beyond + the returned page. + + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "data": [ + { + "attributes": { + "str": "str" # Optional. Span attributes. + }, + "durationNs": 0, # Optional. The span duration in + nanoseconds. + "endTime": "2020-02-20 00:00:00", # Optional. The span end + time. + "kind": "str", # Optional. The span kind. + "name": "str", # Optional. The span name. + "parentSpanId": "str", # Optional. The parent span + identifier. Omitted for root spans. + "region": "str", # Optional. The datacenter region slug the + span was queried from. + "resource": { + "str": "str" # Optional. Resource attributes + associated with the span. + }, + "serviceName": "str", # Optional. The name of the service + that emitted the span. + "spanId": "str", # Optional. The span identifier. + "startTime": "2020-02-20 00:00:00", # Optional. The span + start time. + "statusCode": "str", # Optional. The span status code. + "statusMessage": "str", # Optional. The span status message. + Omitted when empty. + "traceId": "str" # Optional. The trace identifier the span + belongs to. + } + ], + "pagination": { + "hasMore": bool # Optional. Whether more spans matched than were + returned in this page. Cursor-based continuation is not yet supported. + } + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def post_spans_search( + self, region: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Search spans. + + To search spans in a region, send a POST request to + ``/v2/insights/query/{region}/spans/search`` with a JSON body describing the time range, + optional filter, ordering, and pagination. + The time range must not exceed 7 days. ``pagination.limit`` defaults to 100 and must be between + 1 and 1000. Results are ordered by ``startTime`` descending by default. Cursor-based pagination + is not yet supported; ``pagination.hasMore`` indicates whether additional spans matched beyond + the returned page. + + :param region: The datacenter region slug for the query. Required. + :type region: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "timeRange": { + "from": { + "absolute": "str", # Optional. An absolute timestamp. + Accepts an RFC3339/RFC3339Nano string or a Unix timestamp (seconds, + milliseconds, microseconds, or nanoseconds) encoded as a decimal string. + "relative": "str" # Optional. A relative time. Use ``now`` + for the current time, a bare duration such as ``1h`` or ``7d`` to look + back from now, or an offset such as ``now-15m`` or ``now+30m``. Supported + units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``. }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. - "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "to": { + "absolute": "str", # Optional. An absolute timestamp. + Accepts an RFC3339/RFC3339Nano string or a Unix timestamp (seconds, + milliseconds, microseconds, or nanoseconds) encoded as a decimal string. + "relative": "str" # Optional. A relative time. Use ``now`` + for the current time, a bare duration such as ``1h`` or ``7d`` to look + back from now, or an offset such as ``now-15m`` or ``now+30m``. Supported + units are ``s``"" , ``m``"" , ``h``"" , ``d``"" , and ``w``. + } + }, + "filter": { + "type": "str", # The node kind. Required. Known values are: + "condition", "and", "or", "not", and "text_search". + "expressions": [ + ... ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "field": { + "name": "str", # The field name. Well-known span fields + include ``traceId``"" , ``spanId``"" , ``parentSpanId``"" , + ``startTime``"" , ``endTime``"" , ``durationNs``"" , ``name``"" , + ``serviceName``"" , ``kind``"" , ``statusCode``"" , and + ``statusMessage``. Any other value is treated as a span or resource + attribute key. Required. + "scope": "str" # Optional. Optional attribute scope. Use + ``resource`` to match a resource attribute or ``attributes`` to match a + span attribute. Omit for well-known fields or to search both attribute + maps. Known values are: "resource" and "attributes". + }, + "operator": "str", # Optional. The comparison operator for a + ``condition`` node. Known values are: "eq", "neq", "gt", "gte", "lt", "lte", + "in", and "exists". + "query": "str", # Optional. The substring to match for a + ``text_search`` node. + "value": {} + }, + "orderBy": [ + { + "field": { + "name": "str", # The field name. Well-known span + fields include ``traceId``"" , ``spanId``"" , ``parentSpanId``"" , + ``startTime``"" , ``endTime``"" , ``durationNs``"" , ``name``"" , + ``serviceName``"" , ``kind``"" , ``statusCode``"" , and + ``statusMessage``. Any other value is treated as a span or resource + attribute key. Required. + "scope": "str" # Optional. Optional attribute scope. + Use ``resource`` to match a resource attribute or ``attributes`` to + match a span attribute. Omit for well-known fields or to search both + attribute maps. Known values are: "resource" and "attributes". + }, + "direction": "str" # Optional. The sort direction. Defaults + to ``desc`` when omitted. Known values are: "asc" and "desc". + } + ], + "pagination": { + "limit": 100 # Optional. Default value is 100. Maximum number of + spans to return. Defaults to 100 and must be between 1 and 1000. + } + } + + # response body for status code(s): 200 + response == { + "data": [ + { + "attributes": { + "str": "str" # Optional. Span attributes. + }, + "durationNs": 0, # Optional. The span duration in + nanoseconds. + "endTime": "2020-02-20 00:00:00", # Optional. The span end + time. + "kind": "str", # Optional. The span kind. + "name": "str", # Optional. The span name. + "parentSpanId": "str", # Optional. The parent span + identifier. Omitted for root spans. + "region": "str", # Optional. The datacenter region slug the + span was queried from. + "resource": { + "str": "str" # Optional. Resource attributes + associated with the span. + }, + "serviceName": "str", # Optional. The name of the service + that emitted the span. + "spanId": "str", # Optional. The span identifier. + "startTime": "2020-02-20 00:00:00", # Optional. The span + start time. + "statusCode": "str", # Optional. The span status code. + "statusMessage": "str", # Optional. The span status message. + Omitted when empty. + "traceId": "str" # Optional. The trace identifier the span + belongs to. + } + ], + "pagination": { + "hasMore": bool # Optional. Whether more spans matched than were + returned in this page. Cursor-based continuation is not yet supported. + } + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_insights_post_spans_search_request( + region=region, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 403, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + +class SignalsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`signals` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace + def list_consents(self, *, source: Optional[str] = None, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """List All Consent Records. + + To list all signals consent records for your team, send a GET request to + ``/v1/consent``. Each record indicates whether signals collection is enabled + for a source: per-environment records (\\ ``source: agent``\\ ) for Harness Runtime, and + the team-level record (\\ ``source: inference``\\ ) for Serverless Inference chat + completions. + + Pass ``?source=agent`` or ``?source=inference`` to return only that source's + records. When filtered, the response also echoes the ``source``. + + :keyword source: Filter consent records by source. ``agent`` returns per-environment records + (Harness Runtime); ``inference`` returns the team-level record for Serverless Inference chat + completions. When omitted, records for all sources are returned. Known values are: "agent" and + "inference". Default value is None. + :paramtype source: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "consents": [ + { + "agent_id": "str", # The unique identifier of the + environment. For Harness Runtime, this is the Environment Config ID. + Empty for team-level records ("" ``source: inference``"" ), which are not + tied to an environment. Required. + "enabled": bool, # Whether signals collection is enabled for + this source. Required. + "id": 0, # The unique numeric identifier for the consent + record. Required. + "source": "str", # The source this consent applies to. + ``agent`` is per-environment consent for Harness Runtime; ``inference`` + is team-level consent for Serverless Inference chat completions. + Required. Known values are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. + Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in + ISO8601 combined date and time format. Required. + } + ], + "source": "str" # Optional. Echoes the ``source`` filter when the request + was filtered by source. Omitted when the list was not filtered. Known values are: + "agent" and "inference". + } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_consents_request( + source=source, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def update_team_consent( + self, + body: JSON, + *, + source: str, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Team-Level Consent. + + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. + + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. + + :param body: Required. + :type body: JSON + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this source. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. } } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ @overload - def create_cluster( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + def update_team_consent( + self, + body: IO[bytes], + *, + source: str, + content_type: str = "application/json", + **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Create a New Kubernetes Cluster. + """Update Team-Level Consent. - To create a new Kubernetes cluster, send a POST request to - ``/v2/kubernetes/clusters``. The request must contain at least one node pool - with at least one worker. + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. - The request may contain a maintenance window policy describing a time period - when disruptive maintenance tasks may be carried out. Omitting the policy - implies that a window will be chosen automatically. See - `here `_ - for details. + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. :param body: Required. :type body: IO[bytes] + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -185551,274 +187080,6963 @@ def create_cluster( Example: .. code-block:: python - # response body for status code(s): 201 + # response body for status code(s): 200 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. Required. - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] - } - ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. - "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. - ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def update_team_consent( + self, body: Union[JSON, IO[bytes]], *, source: str, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Team-Level Consent. + + To enable or disable signals collection for a source that is consented at + the team level, send a PUT request to ``/v1/consent?source=inference`` with + an ``enabled`` boolean in the request body. Currently the only team-level + source is ``inference``\\ , which covers Serverless Inference chat completions + made by your team. + + To revoke consent, send the same request with ``enabled`` set to ``false``. + The ``source`` query parameter is required. Per-environment consent for Harness + Runtime environments is managed with ``PUT /v1/consent/{agent_id}`` instead. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword source: The consent source to update. Only team-level sources are accepted on this + endpoint; currently ``inference`` (Serverless Inference chat completions). Per-environment + consent (\\ ``agent``\\ ) is managed with ``PUT /v1/consent/{agent_id}`` instead. "inference" + Required. + :paramtype source: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this source. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. } } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_update_team_consent_request( + source=source, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_consent(self, agent_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Consent for an Environment. + + To retrieve the consent record for a specific environment, send a GET + request to ``/v1/consent/{agent_id}``. The response includes an ``enabled`` + field indicating whether signals collection is on for this environment. + + This endpoint only serves per-environment (\\ ``source: agent``\\ ) records. Team-level + inference consent is read from ``GET /v1/consent?source=inference``. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "agent_id": "str", # The unique identifier of the environment. For Harness + Runtime, this is the Environment Config ID. Required. + "enabled": bool, # Whether signals collection is enabled for this + environment. Required. + "source": "str", # The source this consent applies to. Always ``agent`` for + per-environment records returned by this endpoint. Required. "agent" + "team_id": 0, # The team ID that owns this consent record. Required. + "id": 0, # Optional. The unique numeric identifier for the consent record. + "updated_at": "2020-02-20 00:00:00" # Optional. A time value given in + ISO8601 combined date and time format. + } + # response body for status code(s): 400, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_consent_request( + agent_id=agent_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def update_consent( + self, + agent_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this environment. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def update_consent( + self, + agent_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def update_consent( + self, agent_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Consent for an Environment. + + To enable or disable signals collection for a specific environment, send a + PUT request to ``/v1/consent/{agent_id}`` with an ``enabled`` boolean in the + request body. + + This endpoint only manages per-environment (\\ ``source: agent``\\ ) consent. To manage + team-level consent for Serverless Inference, use + ``PUT /v1/consent?source=inference`` instead. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "enabled": bool # Whether to enable signals collection for this environment. + Required. + } + + # response body for status code(s): 200 + response == { + "consent": { + "agent_id": "str", # The unique identifier of the environment. For + Harness Runtime, this is the Environment Config ID. Empty for team-level + records ("" ``source: inference``"" ), which are not tied to an environment. + Required. + "enabled": bool, # Whether signals collection is enabled for this + source. Required. + "id": 0, # The unique numeric identifier for the consent record. + Required. + "source": "str", # The source this consent applies to. ``agent`` is + per-environment consent for Harness Runtime; ``inference`` is team-level + consent for Serverless Inference chat completions. Required. Known values + are: "agent" and "inference". + "team_id": 0, # The team ID that owns this consent record. Required. + "updated_at": "2020-02-20 00:00:00" # A time value given in ISO8601 + combined date and time format. Required. + } + } + # response body for status code(s): 400, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_update_consent_request( + agent_id=agent_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def list_agent_sessions( + self, + agent_id: str, + *, + limit: int = 20, + after: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + signal_type: Optional[str] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List Sessions for an Environment. + + To list signals sessions for a specific environment, send a GET request to + ``/v1/signals/agents/{agent_id}/sessions``. Results are paginated using cursor-based + pagination with ``limit`` and ``after`` parameters. + + :param agent_id: A unique identifier for an environment. For Harness Runtime, this is the + Environment Config ID. Required. + :type agent_id: str + :keyword limit: Maximum number of items to return per page. Default value is 20. + :paramtype limit: int + :keyword after: An opaque cursor string returned from a previous page. Pass this value to + retrieve the next page of results. Default value is None. + :paramtype after: str + :keyword start_time: Filter results to those occurring at or after this timestamp (RFC 3339). + Default value is None. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Filter results to those occurring at or before this timestamp (RFC 3339). + Default value is None. + :paramtype end_time: ~datetime.datetime + :keyword signal_type: Filter results by signal type. Use the export options endpoint to list + available signal types. Default value is None. + :paramtype signal_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "edges": [ + { + "cursor": "str", # Optional. An opaque cursor for + pagination. + "node": { + "session_id": "str", # The unique identifier for the + session. Required. + "duration_seconds": 0.0, # Optional. The duration of + the session in seconds. + "signal_count": 0, # Optional. The number of signals + detected in this session. + "started_at": "2020-02-20 00:00:00", # Optional. + When the session started. + "total_turns": 0 # Optional. The total number of + conversation turns in this session. + } + } + ], + "page_info": { + "has_next_page": bool # Optional. Whether there are more results + after this page. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_agent_sessions_request( + agent_id=agent_id, + limit=limit, + after=after, + start_time=start_time, + end_time=end_time, + signal_type=signal_type, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def list_session_dialogues( + self, + session_id: str, + *, + limit: int = 20, + after: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + signal_type: Optional[str] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List Dialogues for a Session. + + To list the dialogue turns within a specific session, send a GET request to + ``/v1/signals/sessions/{session_id}/dialogues``. Each dialogue represents a + single turn of conversation between a user and the environment, along with + any signals detected. Results are paginated using cursor-based pagination. + + :param session_id: A unique identifier for a signals session. Required. + :type session_id: str + :keyword limit: Maximum number of items to return per page. Default value is 20. + :paramtype limit: int + :keyword after: An opaque cursor string returned from a previous page. Pass this value to + retrieve the next page of results. Default value is None. + :paramtype after: str + :keyword start_time: Filter results to those occurring at or after this timestamp (RFC 3339). + Default value is None. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Filter results to those occurring at or before this timestamp (RFC 3339). + Default value is None. + :paramtype end_time: ~datetime.datetime + :keyword signal_type: Filter results by signal type. Use the export options endpoint to list + available signal types. Default value is None. + :paramtype signal_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "edges": [ + { + "cursor": "str", # Optional. An opaque cursor for + pagination. + "node": { + "id": "str", # The unique identifier for the + dialogue. Required. + "run_status": "str", # Optional. The execution + status of this dialogue turn. + "sequence": 0, # Optional. The sequence number of + this dialogue within the session. + "signals": [ + "str" # Optional. A list of signal types + detected in this dialogue. + ], + "user_message": "str" # Optional. The user's message + in this dialogue turn. + } + } + ], + "page_info": { + "has_next_page": bool # Optional. Whether there are more results + after this page. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_session_dialogues_request( + session_id=session_id, + limit=limit, + after=after, + start_time=start_time, + end_time=end_time, + signal_type=signal_type, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def list_exports( + self, *, limit: int = 20, after: Optional[str] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Export Jobs. + + To list signals export jobs for your team, send a GET request to + ``/v1/signals/exports``. Results are paginated using cursor-based pagination + with ``limit`` and ``after`` parameters. + + :keyword limit: Maximum number of items to return per page. Default value is 20. + :paramtype limit: int + :keyword after: An opaque cursor string returned from a previous page. Pass this value to + retrieve the next page of results. Default value is None. + :paramtype after: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "edges": [ + { + "cursor": "str", # Optional. An opaque cursor for + pagination. + "node": { + "agent_id": "str", # The environment whose data is + being exported. For Harness Runtime, this is the Environment Config + ID. Not meaningful for ``inference`` exports; use ``type`` to + distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export + was created. Required. + "export_id": "str", # The unique identifier for the + export job. Required. + "status": "str", # The current status of the export + job. Required. Known values are: "pending", "processing", "complete", + and "failed". + "completed_at": 0, # Optional. Unix timestamp when + the export completed, or null if still in progress. + "error_message": "str", # Optional. Error message if + the export failed, or null on success. + "expires_at": 0, # Optional. Unix timestamp when the + export download link expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session + IDs included in the export. + ], + "signal_type": [ + "str" # Optional. Signal types + included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. + ``agent`` covers one Harness Runtime environment; ``inference`` + covers the team's Serverless Inference Signals conversations. Known + values are: "agent" and "inference". + } + } + ], + "page_info": { + "has_next_page": bool # Optional. Whether there are more results + after this page. + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_exports_request( + limit=limit, + after=after, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def create_export( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create an Export Job. + + To create a new signals data export, send a POST request to + ``/v1/signals/exports``. To export one Harness Runtime environment, include its + ``agent_id`` (\\ ``type`` defaults to ``agent``\\ ). To export the team's Serverless + Inference Signals conversations, set ``type`` to ``inference`` and omit + ``agent_id``. You may optionally filter the export by ``signal_type``\\ , + ``session_ids``\\ , ``start_time``\\ , and ``end_time``. Use the export options endpoint + to discover available signal types. + + The export job runs asynchronously. Poll the get export endpoint to check + its status. When complete, use the download endpoint to retrieve a + pre-signed URL. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "agent_id": "str", # Optional. The environment whose data should be + exported. For Harness Runtime, this is the Environment Config ID. Required when + ``type`` is ``agent``"" ; must be omitted when ``type`` is ``inference``. + "end_time": "2020-02-20 00:00:00", # Optional. Include only sessions that + started at or before this timestamp. + "session_ids": [ + "str" # Optional. Optional list of specific session IDs to include + in the export. + ], + "signal_type": [ + "str" # Optional. Filter the export to only include the specified + signal types. Use the export options endpoint to list available values. + ], + "start_time": "2020-02-20 00:00:00", # Optional. Include only sessions that + started at or after this timestamp. + "type": "str" # Optional. The scope of the export. ``agent`` exports Signals + conversations for one Harness Runtime environment and requires ``agent_id``. + ``inference`` exports Serverless Inference Signals conversations for the whole + team (team-wide; omit ``agent_id``"" ). Defaults to ``agent`` when ``agent_id`` + is provided and to ``inference`` when it is omitted. Known values are: "agent" + and "inference". + } + + # response body for status code(s): 201 + response == { + "agent_id": "str", # The environment whose data is being exported. For + Harness Runtime, this is the Environment Config ID. Not meaningful for + ``inference`` exports; use ``type`` to distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export was created. Required. + "export_id": "str", # The unique identifier for the export job. Required. + "status": "str", # The current status of the export job. Required. Known + values are: "pending", "processing", "complete", and "failed". + "completed_at": 0, # Optional. Unix timestamp when the export completed, or + null if still in progress. + "error_message": "str", # Optional. Error message if the export failed, or + null on success. + "expires_at": 0, # Optional. Unix timestamp when the export download link + expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session IDs included in the + export. + ], + "signal_type": [ + "str" # Optional. Signal types included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. ``agent`` covers one + Harness Runtime environment; ``inference`` covers the team's Serverless Inference + Signals conversations. Known values are: "agent" and "inference". + } + # response body for status code(s): 400, 422 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def create_export( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create an Export Job. + + To create a new signals data export, send a POST request to + ``/v1/signals/exports``. To export one Harness Runtime environment, include its + ``agent_id`` (\\ ``type`` defaults to ``agent``\\ ). To export the team's Serverless + Inference Signals conversations, set ``type`` to ``inference`` and omit + ``agent_id``. You may optionally filter the export by ``signal_type``\\ , + ``session_ids``\\ , ``start_time``\\ , and ``end_time``. Use the export options endpoint + to discover available signal types. + + The export job runs asynchronously. Poll the get export endpoint to check + its status. When complete, use the download endpoint to retrieve a + pre-signed URL. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "agent_id": "str", # The environment whose data is being exported. For + Harness Runtime, this is the Environment Config ID. Not meaningful for + ``inference`` exports; use ``type`` to distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export was created. Required. + "export_id": "str", # The unique identifier for the export job. Required. + "status": "str", # The current status of the export job. Required. Known + values are: "pending", "processing", "complete", and "failed". + "completed_at": 0, # Optional. Unix timestamp when the export completed, or + null if still in progress. + "error_message": "str", # Optional. Error message if the export failed, or + null on success. + "expires_at": 0, # Optional. Unix timestamp when the export download link + expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session IDs included in the + export. + ], + "signal_type": [ + "str" # Optional. Signal types included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. ``agent`` covers one + Harness Runtime environment; ``inference`` covers the team's Serverless Inference + Signals conversations. Known values are: "agent" and "inference". + } + # response body for status code(s): 400, 422 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def create_export(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create an Export Job. + + To create a new signals data export, send a POST request to + ``/v1/signals/exports``. To export one Harness Runtime environment, include its + ``agent_id`` (\\ ``type`` defaults to ``agent``\\ ). To export the team's Serverless + Inference Signals conversations, set ``type`` to ``inference`` and omit + ``agent_id``. You may optionally filter the export by ``signal_type``\\ , + ``session_ids``\\ , ``start_time``\\ , and ``end_time``. Use the export options endpoint + to discover available signal types. + + The export job runs asynchronously. Poll the get export endpoint to check + its status. When complete, use the download endpoint to retrieve a + pre-signed URL. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "agent_id": "str", # Optional. The environment whose data should be + exported. For Harness Runtime, this is the Environment Config ID. Required when + ``type`` is ``agent``"" ; must be omitted when ``type`` is ``inference``. + "end_time": "2020-02-20 00:00:00", # Optional. Include only sessions that + started at or before this timestamp. + "session_ids": [ + "str" # Optional. Optional list of specific session IDs to include + in the export. + ], + "signal_type": [ + "str" # Optional. Filter the export to only include the specified + signal types. Use the export options endpoint to list available values. + ], + "start_time": "2020-02-20 00:00:00", # Optional. Include only sessions that + started at or after this timestamp. + "type": "str" # Optional. The scope of the export. ``agent`` exports Signals + conversations for one Harness Runtime environment and requires ``agent_id``. + ``inference`` exports Serverless Inference Signals conversations for the whole + team (team-wide; omit ``agent_id``"" ). Defaults to ``agent`` when ``agent_id`` + is provided and to ``inference`` when it is omitted. Known values are: "agent" + and "inference". + } + + # response body for status code(s): 201 + response == { + "agent_id": "str", # The environment whose data is being exported. For + Harness Runtime, this is the Environment Config ID. Not meaningful for + ``inference`` exports; use ``type`` to distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export was created. Required. + "export_id": "str", # The unique identifier for the export job. Required. + "status": "str", # The current status of the export job. Required. Known + values are: "pending", "processing", "complete", and "failed". + "completed_at": 0, # Optional. Unix timestamp when the export completed, or + null if still in progress. + "error_message": "str", # Optional. Error message if the export failed, or + null on success. + "expires_at": 0, # Optional. Unix timestamp when the export download link + expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session IDs included in the + export. + ], + "signal_type": [ + "str" # Optional. Signal types included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. ``agent`` covers one + Harness Runtime environment; ``inference`` covers the team's Serverless Inference + Signals conversations. Known values are: "agent" and "inference". + } + # response body for status code(s): 400, 422 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_create_export_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201, 400, 422]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 422: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_export_options(self, **kwargs: Any) -> JSON: + """Get Export Options. + + To retrieve the available filter options for creating an export, send a GET + request to ``/v1/signals/exports/options``. The response lists valid signal + types that can be used in the ``signal_type`` filter when creating an export. + + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "filters": { + "signal_type": [ + "str" # The list of valid signal type values that can be + used when creating an export. Required. + ] + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_export_options_request( + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_export(self, export_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Export Job. + + To retrieve the status and details of a signals export job, send a GET + request to ``/v1/signals/exports/{export_id}``. + + :param export_id: A unique identifier for an export job. Required. + :type export_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "agent_id": "str", # The environment whose data is being exported. For + Harness Runtime, this is the Environment Config ID. Not meaningful for + ``inference`` exports; use ``type`` to distinguish the export scope. Required. + "created_at": 0, # Unix timestamp when the export was created. Required. + "export_id": "str", # The unique identifier for the export job. Required. + "status": "str", # The current status of the export job. Required. Known + values are: "pending", "processing", "complete", and "failed". + "completed_at": 0, # Optional. Unix timestamp when the export completed, or + null if still in progress. + "error_message": "str", # Optional. Error message if the export failed, or + null on success. + "expires_at": 0, # Optional. Unix timestamp when the export download link + expires. + "filters": { + "session_ids": [ + "str" # Optional. Specific session IDs included in the + export. + ], + "signal_type": [ + "str" # Optional. Signal types included in the export. + ] + }, + "type": "str" # Optional. The scope of the export. ``agent`` covers one + Harness Runtime environment; ``inference`` covers the team's Serverless Inference + Signals conversations. Known values are: "agent" and "inference". + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_export_request( + export_id=export_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_export_download(self, export_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Get Export Download URL. + + To retrieve a pre-signed download URL for a completed export, send a GET + request to ``/v1/signals/exports/{export_id}/download``. The export must have + a ``complete`` status. The URL is temporary and will expire. + + :param export_id: A unique identifier for an export job. Required. + :type export_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "download_url": "str", # A temporary pre-signed URL to download the export + archive. Required. + "expires_at": 0 # Unix timestamp when the download URL expires. The URL is + valid for 15 minutes. Required. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_export_download_request( + export_id=export_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def list_deletions( + self, *, limit: int = 20, after: Optional[str] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List Data Deletion Jobs. + + To list signals data deletion jobs for your team, newest first, send a GET + request to ``/v1/signals/deletions``. Results are paginated using + cursor-based pagination with ``limit`` and ``after`` parameters. + + :keyword limit: Maximum number of items to return per page. Default value is 20. + :paramtype limit: int + :keyword after: An opaque cursor string returned from a previous page. Pass this value to + retrieve the next page of results. Default value is None. + :paramtype after: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "edges": [ + { + "cursor": "str", # Optional. An opaque cursor for + pagination. + "node": { + "created_at": 0, # Unix timestamp when the deletion + job was created. Required. + "deletion_id": "str", # The unique identifier for + the deletion job (ULID). Required. + "status": "str", # The current status of the + deletion job. Required. Known values are: "queued", "running", + "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. + Required. + "type": "str", # The scope of the deletion. + ``agent`` deletes Signals conversations for one Harness Runtime + environment. ``inference`` deletes Serverless Inference Signals + conversations for the whole team. Required. Known values are: "agent" + and "inference". + "agent_id": "str", # Optional. The Harness Runtime + Environment Config ID (agent UUID) whose conversations are being + deleted. Only present for ``agent`` deletions. + "completed_at": 0, # Optional. Unix timestamp when + the deletion finished, or null if still in progress. + "error_message": "str", # Optional. Error message if + the deletion failed, or null otherwise. + "started_at": 0 # Optional. Unix timestamp when + processing started, or null if still queued. + } + } + ], + "page_info": { + "end_cursor": "str", # Optional. Cursor of the last item. Pass as + ``after`` to fetch the next page. Present only when there are more results. + "has_next_page": bool # Optional. Whether there are more results + after this page. + } + } + # response body for status code(s): 400 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_list_deletions_request( + limit=limit, + after=after, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def create_deletion( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Data Deletion Job. + + To permanently delete Signals conversation data, send a POST request to + ``/v1/signals/deletions``. Deletion cannot be undone. + + Two deletion types are supported: + + + * ``agent`` — deletes Signals conversations for one Harness Runtime environment and + turns off collection for that environment. Requires ``agent_id``\\ , which is the + environment's Environment Config ID (the environment's ``agent_id``\\ ). On create, matching + conversations are hidden from Signals reads immediately. Wait until the + job is ``complete`` before enabling Signals for the environment again. + * ``inference`` — deletes Serverless Inference Signals conversations for your + whole team (team-wide; not limited to one endpoint or model) that were + collected at or before the deletion request, and turns off team inference + collection (\\ ``source=inference``\\ ). Do not send ``agent_id``. On create, + matching conversations are hidden from Signals reads immediately. + + The job runs asynchronously; poll the get endpoint until ``status`` is + ``complete`` or ``failed``. DigitalOcean may retry transient processing errors + while a job is still active. If a job ends as ``failed``\\ , matching + conversations stay hidden and collection stays off; send the same create + request again to retry. Earlier export files are not deleted and remain + available until they expire. + + Note: Deletion removes Signals conversation data for the requested scope. + Aggregated Insights or metrics charts may still show historical summary + datapoints after deletion. Those summaries are not the same as recoverable + conversation content. + + The endpoint is idempotent: if a queued or running job already exists for + the same target, it is returned with ``200 OK``. A new job returns + ``202 Accepted``. Each team can have a limited number of active jobs; + requests beyond that limit return ``429 Too Many Requests``. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "team_id": 0, # The team whose data should be deleted. Must match the + authenticated team. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment and requires ``agent_id``. + ``inference`` deletes Serverless Inference Signals conversations for the whole + team (team-wide; omit ``agent_id``"" ). Required. Known values are: "agent" and + "inference". + "agent_id": "str" # Optional. The Harness Runtime Environment Config ID of + the environment whose conversations should be deleted. This is the environment's + ``agent_id``. Required when ``type`` is ``agent``"" ; must be omitted when + ``type`` is ``inference``. + } + + # response body for status code(s): 200, 202 + response == { + "created_at": 0, # Unix timestamp when the deletion job was created. + Required. + "deletion_id": "str", # The unique identifier for the deletion job (ULID). + Required. + "status": "str", # The current status of the deletion job. Required. Known + values are: "queued", "running", "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment. ``inference`` deletes + Serverless Inference Signals conversations for the whole team. Required. Known + values are: "agent" and "inference". + "agent_id": "str", # Optional. The Harness Runtime Environment Config ID + (agent UUID) whose conversations are being deleted. Only present for ``agent`` + deletions. + "completed_at": 0, # Optional. Unix timestamp when the deletion finished, or + null if still in progress. + "error_message": "str", # Optional. Error message if the deletion failed, or + null otherwise. + "started_at": 0 # Optional. Unix timestamp when processing started, or null + if still queued. + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def create_deletion( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a Data Deletion Job. + + To permanently delete Signals conversation data, send a POST request to + ``/v1/signals/deletions``. Deletion cannot be undone. + + Two deletion types are supported: + + + * ``agent`` — deletes Signals conversations for one Harness Runtime environment and + turns off collection for that environment. Requires ``agent_id``\\ , which is the + environment's Environment Config ID (the environment's ``agent_id``\\ ). On create, matching + conversations are hidden from Signals reads immediately. Wait until the + job is ``complete`` before enabling Signals for the environment again. + * ``inference`` — deletes Serverless Inference Signals conversations for your + whole team (team-wide; not limited to one endpoint or model) that were + collected at or before the deletion request, and turns off team inference + collection (\\ ``source=inference``\\ ). Do not send ``agent_id``. On create, + matching conversations are hidden from Signals reads immediately. + + The job runs asynchronously; poll the get endpoint until ``status`` is + ``complete`` or ``failed``. DigitalOcean may retry transient processing errors + while a job is still active. If a job ends as ``failed``\\ , matching + conversations stay hidden and collection stays off; send the same create + request again to retry. Earlier export files are not deleted and remain + available until they expire. + + Note: Deletion removes Signals conversation data for the requested scope. + Aggregated Insights or metrics charts may still show historical summary + datapoints after deletion. Those summaries are not the same as recoverable + conversation content. + + The endpoint is idempotent: if a queued or running job already exists for + the same target, it is returned with ``200 OK``. A new job returns + ``202 Accepted``. Each team can have a limited number of active jobs; + requests beyond that limit return ``429 Too Many Requests``. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 202 + response == { + "created_at": 0, # Unix timestamp when the deletion job was created. + Required. + "deletion_id": "str", # The unique identifier for the deletion job (ULID). + Required. + "status": "str", # The current status of the deletion job. Required. Known + values are: "queued", "running", "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment. ``inference`` deletes + Serverless Inference Signals conversations for the whole team. Required. Known + values are: "agent" and "inference". + "agent_id": "str", # Optional. The Harness Runtime Environment Config ID + (agent UUID) whose conversations are being deleted. Only present for ``agent`` + deletions. + "completed_at": 0, # Optional. Unix timestamp when the deletion finished, or + null if still in progress. + "error_message": "str", # Optional. Error message if the deletion failed, or + null otherwise. + "started_at": 0 # Optional. Unix timestamp when processing started, or null + if still queued. + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def create_deletion(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create a Data Deletion Job. + + To permanently delete Signals conversation data, send a POST request to + ``/v1/signals/deletions``. Deletion cannot be undone. + + Two deletion types are supported: + + + * ``agent`` — deletes Signals conversations for one Harness Runtime environment and + turns off collection for that environment. Requires ``agent_id``\\ , which is the + environment's Environment Config ID (the environment's ``agent_id``\\ ). On create, matching + conversations are hidden from Signals reads immediately. Wait until the + job is ``complete`` before enabling Signals for the environment again. + * ``inference`` — deletes Serverless Inference Signals conversations for your + whole team (team-wide; not limited to one endpoint or model) that were + collected at or before the deletion request, and turns off team inference + collection (\\ ``source=inference``\\ ). Do not send ``agent_id``. On create, + matching conversations are hidden from Signals reads immediately. + + The job runs asynchronously; poll the get endpoint until ``status`` is + ``complete`` or ``failed``. DigitalOcean may retry transient processing errors + while a job is still active. If a job ends as ``failed``\\ , matching + conversations stay hidden and collection stays off; send the same create + request again to retry. Earlier export files are not deleted and remain + available until they expire. + + Note: Deletion removes Signals conversation data for the requested scope. + Aggregated Insights or metrics charts may still show historical summary + datapoints after deletion. Those summaries are not the same as recoverable + conversation content. + + The endpoint is idempotent: if a queued or running job already exists for + the same target, it is returned with ``200 OK``. A new job returns + ``202 Accepted``. Each team can have a limited number of active jobs; + requests beyond that limit return ``429 Too Many Requests``. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "team_id": 0, # The team whose data should be deleted. Must match the + authenticated team. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment and requires ``agent_id``. + ``inference`` deletes Serverless Inference Signals conversations for the whole + team (team-wide; omit ``agent_id``"" ). Required. Known values are: "agent" and + "inference". + "agent_id": "str" # Optional. The Harness Runtime Environment Config ID of + the environment whose conversations should be deleted. This is the environment's + ``agent_id``. Required when ``type`` is ``agent``"" ; must be omitted when + ``type`` is ``inference``. + } + + # response body for status code(s): 200, 202 + response == { + "created_at": 0, # Unix timestamp when the deletion job was created. + Required. + "deletion_id": "str", # The unique identifier for the deletion job (ULID). + Required. + "status": "str", # The current status of the deletion job. Required. Known + values are: "queued", "running", "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment. ``inference`` deletes + Serverless Inference Signals conversations for the whole team. Required. Known + values are: "agent" and "inference". + "agent_id": "str", # Optional. The Harness Runtime Environment Config ID + (agent UUID) whose conversations are being deleted. Only present for ``agent`` + deletions. + "completed_at": 0, # Optional. Unix timestamp when the deletion finished, or + null if still in progress. + "error_message": "str", # Optional. Error message if the deletion failed, or + null otherwise. + "started_at": 0 # Optional. Unix timestamp when processing started, or null + if still queued. + } + # response body for status code(s): 400, 403, 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_signals_create_deletion_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 400, 403, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 202: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_deletion(self, deletion_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve a Data Deletion Job. + + To retrieve the status of a signals data deletion job, send a GET request + to ``/v1/signals/deletions/{deletion_id}``. + + :param deletion_id: A unique identifier for a data deletion job. Required. + :type deletion_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "created_at": 0, # Unix timestamp when the deletion job was created. + Required. + "deletion_id": "str", # The unique identifier for the deletion job (ULID). + Required. + "status": "str", # The current status of the deletion job. Required. Known + values are: "queued", "running", "complete", and "failed". + "team_id": 0, # The team that owns the deletion job. Required. + "type": "str", # The scope of the deletion. ``agent`` deletes Signals + conversations for one Harness Runtime environment. ``inference`` deletes + Serverless Inference Signals conversations for the whole team. Required. Known + values are: "agent" and "inference". + "agent_id": "str", # Optional. The Harness Runtime Environment Config ID + (agent UUID) whose conversations are being deleted. Only present for ``agent`` + deletions. + "completed_at": 0, # Optional. Unix timestamp when the deletion finished, or + null if still in progress. + "error_message": "str", # Optional. Error message if the deletion failed, or + null otherwise. + "started_at": 0 # Optional. Unix timestamp when processing started, or null + if still queued. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_signals_get_deletion_request( + deletion_id=deletion_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + +class KubernetesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`kubernetes` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace + def list_clusters( + self, *, per_page: int = 20, page: int = 1, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List All Kubernetes Clusters. + + To list all of the Kubernetes clusters on your account, send a GET request + to ``/v2/kubernetes/clusters``. + + :keyword per_page: Number of items returned per page. Default value is 20. + :paramtype per_page: int + :keyword page: Which 'page' of paginated results to return. Default value is 1. + :paramtype page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "meta": { + "total": 0 # Optional. Number of objects returned by the request. + }, + "kubernetes_clusters": [ + { + "name": "str", # A human-readable name for a Kubernetes + cluster. Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean + value indicating whether auto-scaling is enabled for this node + pool. + "count": 0, # Optional. The number of + Droplet instances in the node pool. + "gpu_partition_mode": "str", # Optional. The + AMD GPU partition mode for this node pool. Only applicable to AMD + GPU sizes that support partitioning. Immutable after the node + pool is created. When omitted, the GPUs in the pool are left + unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" + and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that + can be used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of + key/value mappings specifying labels to apply to all nodes in a + pool. Labels will automatically be applied to all existing nodes + and any subsequent nodes added to the pool. Note that when a + label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum + number of nodes that this node pool can be auto-scaled to. The + value will be ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum + number of nodes that this node pool can be auto-scaled to. The + value will be ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable + name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 + 00:00:00", # Optional. A time value given in ISO8601 + combined date and time format that represents when the + node was created. + "droplet_id": "str", # + Optional. The ID of the Droplet used for the worker node. + "id": "str", # Optional. A + unique ID that can be used to identify and reference the + node. + "name": "str", # Optional. + An automatically generated, human-readable name for the + node. + "status": { + "state": "str" # + Optional. A string indicating the current status of + the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 + 00:00:00" # Optional. A time value given in ISO8601 + combined date and time format that represents when the + node was last updated. + } + ], + "size": "str", # Optional. The slug + identifier for the type of Droplet used as workers in the node + pool. + "tags": [ + "str" # Optional. An array + containing the tags applied to the node pool. All node pools + are automatically tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. + How the node reacts to pods that it won't tolerate. + Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values + are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if + the value of the ``key`` field is "special" and the value + of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. + An arbitrary string. The ``key`` and ``value`` fields of + the ``taint`` object form a key-value pair. For example, + if the value of the ``key`` field is "special" and the + value of the ``value`` field is "gpu", the key value pair + would be ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where + the Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), + the latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available + versions. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the + AMD Device Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the + AMD GPU Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the + AMD GPU DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether the cluster will be automatically + upgraded to new patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used + by cluster-autoscaler. The autoscaler will apply each expander + from the provided list to narrow down the selection of node types + created to scale up, until either a single node type is left, or + the list of expanders is exhausted. If this flag is unset, + autoscaler will use its default expander ``random``. Passing an + empty list ("" *not* ``null``"" ) will unset any previous + expander customizations. Available expanders: * ``random``"" : + Randomly selects a node group to scale. * `priority`: Selects the + node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in + the least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used + to customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. + Used to customize when cluster autoscaler scales down non-empty nodes + by setting the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP + addresses for the overlay network of the Kubernetes cluster in CIDR + notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public + addresses (IPv4 or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the + control plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the + CoreDNS Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the Kubernetes cluster was created. + "endpoint": "str", # Optional. The base URL of the API + server on the Kubernetes master node. + "ha": False, # Optional. Default value is False. A boolean + value indicating whether the control plane is run in a highly available + configuration in the cluster. Highly available control planes incur less + downtime. The property cannot be disabled. When omitted on create, the + default is version-dependent; for DOKS 1.36.0 and later, the default is + true; for earlier versions, the default is false. + "id": "str", # Optional. A unique ID that can be used to + identify and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the + Kubernetes master node. This will not be set if high availability is + configured on the cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is + False. A boolean value indicating whether worker nodes in the cluster are + not assigned public IP addresses. When omitted on create, the default + value is false. When enabled, a NAT gateway must exist in the VPC where + the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance + window policy. May be one of ``monday`` through ``sunday``"" , or + ``any`` to indicate an arbitrary week day. Known values are: "any", + "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", + and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in + UTC of the maintenance window policy in 24-hour clock format / HH:MM + notation (e.g., ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the + NFS CSI plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the + Nvidia GPU Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the + NVIDIA GPU DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the + RDMA shared device plugin is enabled. + }, + "registries": [ + "str" # Optional. An array of integrated DOCR + registries. + ], + "registry_enabled": bool, # Optional. A read-only boolean + value indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable + IP addresses for services running in the Kubernetes cluster in CIDR + notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is + False. Indicates whether SSO authentication is enabled for the + cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL + for the identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is + False. Indicates whether any non-SSO forms of authentication are + disallowed. Can only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message + providing additional information about the current cluster state. + "state": "str" # Optional. A string indicating the + current status of the cluster. Known values are: "running", + "provisioning", "degraded", "error", "deleted", "upgrading", and + "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. + A boolean value indicating whether surge upgrade is enabled/disabled for + the cluster. Surge upgrade makes cluster upgrades fast and reliable by + bringing up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags applied to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the Kubernetes cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID + of the VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC + subnet worker nodes are attached to. When unset, the default subnet for + the VPC is used.:code:`
`:code:`
`Requires ``vpc:read`` scope. + } + ], + "links": { + "pages": {} + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_list_clusters_request( + per_page=per_page, + page=page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def create_cluster( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Kubernetes Cluster. + + To create a new Kubernetes cluster, send a POST request to + ``/v2/kubernetes/clusters``. The request must contain at least one node pool + with at least one worker. + + The request may contain a maintenance window policy describing a time period + when disruptive maintenance tasks may be carried out. Omitting the policy + implies that a window will be chosen automatically. See + `here `_ + for details. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value indicating + whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in + the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes that + support partitioning. Immutable after the node pool is created. When + omitted, the GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to + identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings + specifying labels to apply to all nodes in a pool. Labels will + automatically be applied to all existing nodes and any subsequent nodes + added to the pool. Note that when a label is removed, it is not deleted + from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that + this node pool can be auto-scaled to. The value will be ``0`` if + ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that + this node pool can be auto-scaled to. The value will be ``0`` if + ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for the + node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # + Optional. A time value given in ISO8601 combined date and time + format that represents when the node was created. + "droplet_id": "str", # Optional. The ID of + the Droplet used for the worker node. + "id": "str", # Optional. A unique ID that + can be used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # + Optional. A time value given in ISO8601 combined date and time + format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type + of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags + applied to the node pool. All node pools are automatically tagged + ``k8s``"" , ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node + reacts to pods that it won't tolerate. Available effect values + are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary + string. The ``key`` and ``value`` fields of the ``taint`` object + form a key-value pair. For example, if the value of the ``key`` + field is "special" and the value of the ``value`` field is "gpu", + the key value pair would be ``special=gpu``. + "value": "str" # Optional. An arbitrary + string. The ``key`` and ``value`` fields of the ``taint`` object + form a key-value pair. For example, if the value of the ``key`` + field is "special" and the value of the ``value`` field is "gpu", + the key value pair would be ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the Kubernetes + cluster is located. Required. + "version": "str", # The slug identifier for the version of Kubernetes used + for the cluster. If set to a minor version (e.g. "1.14"), the latest version + within it will be used (e.g. "1.14.6-do.1"); if set to "latest", the latest + published version will be used. See the ``/v2/kubernetes/options`` endpoint to + find all currently available versions. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device Metrics + Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU Device + Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver + is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether the cluster will be automatically upgraded to new patch + releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to scale + up, until either a single node type is left, or the list of expanders is + exhausted. If this flag is unset, autoscaler will use its default + expander ``random``. Passing an empty list ("" *not* ``null``"" ) will + unset any previous expander customizations. Available expanders: * + ``random``"" : Randomly selects a node group to scale. * `priority`: + Selects the node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to customize how + long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting the + node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for the + overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 or + CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control plane + firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS Cluster + Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the Kubernetes cluster + was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the control plane + is run in a highly available configuration in the cluster. Highly available + control planes incur less downtime. The property cannot be disabled. When omitted + on create, the default is version-dependent; for DOKS 1.36.0 and later, the + default is true; for earlier versions, the default is false. + "id": "str", # Optional. A unique ID that can be used to identify and + reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes master + node. This will not be set if high availability is configured on the cluster + (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A boolean + value indicating whether worker nodes in the cluster are not assigned public IP + addresses. When omitted on create, the default value is false. When enabled, a + NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window policy. + May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an + arbitrary week day. Known values are: "any", "monday", "tuesday", + "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the maintenance + window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI plugin is + enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU Device + Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA + Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI + registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA shared device + plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value indicating + if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the routing-agent + component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP addresses + for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID registered with + the identity provider. Required when ``enabled`` is ``true``. + "enabled": False, # Optional. Default value is False. Indicates + whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. Indicates + whether any non-SSO forms of authentication are disallowed. Can only be set + to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current status of + the cluster. Known values are: "running", "provisioning", "degraded", + "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether surge upgrade is enabled/disabled for the cluster. Surge + upgrade makes cluster upgrades fast and reliable by bringing up new nodes before + destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` and + ``tag:create`` scope, as well as ``tag:delete`` if existing tags are getting + removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the Kubernetes cluster + was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the VPC to + which the Kubernetes cluster is assigned.:code:`
`:code:`
`Requires + ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet to attach + worker nodes to. When omitted on create, the default subnet for the VPC is used. + This value cannot be changed after the cluster is created. ``vpc_uuid`` must + also be set. :code:`
`:code:`
`Requires ``vpc:read`` scope. + } + + # response body for status code(s): 201 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + """ + + @overload + def create_cluster( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Kubernetes Cluster. + + To create a new Kubernetes cluster, send a POST request to + ``/v2/kubernetes/clusters``. The request must contain at least one node pool + with at least one worker. + + The request may contain a maintenance window policy describing a time period + when disruptive maintenance tasks may be carried out. Omitting the policy + implies that a window will be chosen automatically. See + `here `_ + for details. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + """ + + @distributed_trace + def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create a New Kubernetes Cluster. + + To create a new Kubernetes cluster, send a POST request to + ``/v2/kubernetes/clusters``. The request must contain at least one node pool + with at least one worker. + + The request may contain a maintenance window policy describing a time period + when disruptive maintenance tasks may be carried out. Omitting the policy + implies that a window will be chosen automatically. See + `here `_ + for details. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value indicating + whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in + the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes that + support partitioning. Immutable after the node pool is created. When + omitted, the GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to + identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings + specifying labels to apply to all nodes in a pool. Labels will + automatically be applied to all existing nodes and any subsequent nodes + added to the pool. Note that when a label is removed, it is not deleted + from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that + this node pool can be auto-scaled to. The value will be ``0`` if + ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that + this node pool can be auto-scaled to. The value will be ``0`` if + ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for the + node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # + Optional. A time value given in ISO8601 combined date and time + format that represents when the node was created. + "droplet_id": "str", # Optional. The ID of + the Droplet used for the worker node. + "id": "str", # Optional. A unique ID that + can be used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # + Optional. A time value given in ISO8601 combined date and time + format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type + of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags + applied to the node pool. All node pools are automatically tagged + ``k8s``"" , ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node + reacts to pods that it won't tolerate. Available effect values + are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary + string. The ``key`` and ``value`` fields of the ``taint`` object + form a key-value pair. For example, if the value of the ``key`` + field is "special" and the value of the ``value`` field is "gpu", + the key value pair would be ``special=gpu``. + "value": "str" # Optional. An arbitrary + string. The ``key`` and ``value`` fields of the ``taint`` object + form a key-value pair. For example, if the value of the ``key`` + field is "special" and the value of the ``value`` field is "gpu", + the key value pair would be ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the Kubernetes + cluster is located. Required. + "version": "str", # The slug identifier for the version of Kubernetes used + for the cluster. If set to a minor version (e.g. "1.14"), the latest version + within it will be used (e.g. "1.14.6-do.1"); if set to "latest", the latest + published version will be used. See the ``/v2/kubernetes/options`` endpoint to + find all currently available versions. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device Metrics + Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU Device + Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver + is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether the cluster will be automatically upgraded to new patch + releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to scale + up, until either a single node type is left, or the list of expanders is + exhausted. If this flag is unset, autoscaler will use its default + expander ``random``. Passing an empty list ("" *not* ``null``"" ) will + unset any previous expander customizations. Available expanders: * + ``random``"" : Randomly selects a node group to scale. * `priority`: + Selects the node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to customize how + long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting the + node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for the + overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 or + CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control plane + firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS Cluster + Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the Kubernetes cluster + was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the control plane + is run in a highly available configuration in the cluster. Highly available + control planes incur less downtime. The property cannot be disabled. When omitted + on create, the default is version-dependent; for DOKS 1.36.0 and later, the + default is true; for earlier versions, the default is false. + "id": "str", # Optional. A unique ID that can be used to identify and + reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes master + node. This will not be set if high availability is configured on the cluster + (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A boolean + value indicating whether worker nodes in the cluster are not assigned public IP + addresses. When omitted on create, the default value is false. When enabled, a + NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window policy. + May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an + arbitrary week day. Known values are: "any", "monday", "tuesday", + "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the maintenance + window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI plugin is + enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU Device + Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA + Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI + registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA shared device + plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value indicating + if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the routing-agent + component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP addresses + for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID registered with + the identity provider. Required when ``enabled`` is ``true``. + "enabled": False, # Optional. Default value is False. Indicates + whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. Indicates + whether any non-SSO forms of authentication are disallowed. Can only be set + to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current status of + the cluster. Known values are: "running", "provisioning", "degraded", + "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether surge upgrade is enabled/disabled for the cluster. Surge + upgrade makes cluster upgrades fast and reliable by bringing up new nodes before + destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` and + ``tag:create`` scope, as well as ``tag:delete`` if existing tags are getting + removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the Kubernetes cluster + was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the VPC to + which the Kubernetes cluster is assigned.:code:`
`:code:`
`Requires + ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet to attach + worker nodes to. When omitted on create, the default subnet for the VPC is used. + This value cannot be changed after the cluster is created. ``vpc_uuid`` must + also be set. :code:`
`:code:`
`Requires ``vpc:read`` scope. + } + + # response body for status code(s): 201 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_kubernetes_create_cluster_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Existing Kubernetes Cluster. + + To show information about an existing Kubernetes cluster, send a GET request + to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": False, # Optional. Default value is False. A boolean value + indicating whether the control plane is run in a highly available + configuration in the cluster. Highly available control planes incur less + downtime. The property cannot be disabled. When omitted on create, the + default is version-dependent; for DOKS 1.36.0 and later, the default is true; + for earlier versions, the default is false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registries": [ + "str" # Optional. An array of integrated DOCR registries. + ], + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags applied to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + worker nodes are attached to. When unset, the default subnet for the VPC is + used.:code:`
`:code:`
`Requires ``vpc:read`` scope. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_get_cluster_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def update_cluster( + self, + cluster_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a Kubernetes Cluster. + + To update a Kubernetes cluster, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the + attributes below. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device Metrics + Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU Device + Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver + is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether the cluster will be automatically upgraded to new patch + releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to scale + up, until either a single node type is left, or the list of expanders is + exhausted. If this flag is unset, autoscaler will use its default + expander ``random``. Passing an empty list ("" *not* ``null``"" ) will + unset any previous expander customizations. Available expanders: * + ``random``"" : Randomly selects a node group to scale. * `priority`: + Selects the node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to customize how + long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting the + node utilization threshold. + }, + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 or + CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control plane + firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS Cluster + Proportional Autoscaler add-on is enabled. + }, + "ha": bool, # Optional. A boolean value indicating whether the control plane + is run in a highly available configuration in the cluster. Highly available + control planes incur less downtime. The property cannot be disabled. When omitted + on create, the default is version-dependent; for DOKS 1.36.0 and later, the + default is true; for earlier versions, the default is false. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window policy. + May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an + arbitrary week day. Known values are: "any", "monday", "tuesday", + "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the maintenance + window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI plugin is + enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU Device + Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA + Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI + registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA shared device + plugin is enabled. + }, + "routing_agent": { + "enabled": bool # Optional. Indicates whether the routing-agent + component is enabled. + }, + "sso": { + "client_id": "str", # Optional. The OIDC client ID registered with + the identity provider. Required when ``enabled`` is ``true``. + "enabled": False, # Optional. Default value is False. Indicates + whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. Indicates + whether any non-SSO forms of authentication are disallowed. Can only be set + to ``true`` when ``enabled`` is ``true``. + }, + "surge_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether surge upgrade is enabled/disabled for the cluster. Surge + upgrade makes cluster upgrades fast and reliable by bringing up new nodes before + destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags applied to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. + ] + } + + # response body for status code(s): 202 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def update_cluster( + self, + cluster_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a Kubernetes Cluster. + + To update a Kubernetes cluster, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the + attributes below. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def update_cluster( + self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a Kubernetes Cluster. + + To update a Kubernetes cluster, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the + attributes below. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device Metrics + Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU Device + Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver + is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether the cluster will be automatically upgraded to new patch + releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to scale + up, until either a single node type is left, or the list of expanders is + exhausted. If this flag is unset, autoscaler will use its default + expander ``random``. Passing an empty list ("" *not* ``null``"" ) will + unset any previous expander customizations. Available expanders: * + ``random``"" : Randomly selects a node group to scale. * `priority`: + Selects the node group with the highest priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to customize how + long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting the + node utilization threshold. + }, + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 or + CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control plane + firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS Cluster + Proportional Autoscaler add-on is enabled. + }, + "ha": bool, # Optional. A boolean value indicating whether the control plane + is run in a highly available configuration in the cluster. Highly available + control planes incur less downtime. The property cannot be disabled. When omitted + on create, the default is version-dependent; for DOKS 1.36.0 and later, the + default is true; for earlier versions, the default is false. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window policy. + May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an + arbitrary week day. Known values are: "any", "monday", "tuesday", + "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the maintenance + window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI plugin is + enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU Device + Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA + Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI + registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA shared device + plugin is enabled. + }, + "routing_agent": { + "enabled": bool # Optional. Indicates whether the routing-agent + component is enabled. + }, + "sso": { + "client_id": "str", # Optional. The OIDC client ID registered with + the identity provider. Required when ``enabled`` is ``true``. + "enabled": False, # Optional. Default value is False. Indicates + whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. Indicates + whether any non-SSO forms of authentication are disallowed. Can only be set + to ``true`` when ``enabled`` is ``true``. + }, + "surge_upgrade": False, # Optional. Default value is False. A boolean value + indicating whether surge upgrade is enabled/disabled for the cluster. Surge + upgrade makes cluster upgrades fast and reliable by bringing up new nodes before + destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags applied to the Kubernetes + cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. + ] + } + + # response body for status code(s): 202 + response == { + "kubernetes_cluster": { + "name": "str", # A human-readable name for a Kubernetes cluster. + Required. + "node_pools": [ + { + "auto_scale": bool, # Optional. A boolean value + indicating whether auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet + instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU + partition mode for this node pool. Only applicable to AMD GPU sizes + that support partitioning. Immutable after the node pool is created. + When omitted, the GPUs in the pool are left unpartitioned. Known + values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be + used to identify and reference a specific node pool. + "labels": {}, # Optional. An object of key/value + mappings specifying labels to apply to all nodes in a pool. Labels + will automatically be applied to all existing nodes and any + subsequent nodes added to the pool. Note that when a label is + removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "min_nodes": 0, # Optional. The minimum number of + nodes that this node pool can be auto-scaled to. The value will be + ``0`` if ``auto_scale`` is set to ``false``. + "name": "str", # Optional. A human-readable name for + the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was created. + "droplet_id": "str", # Optional. The + ID of the Droplet used for the worker node. + "id": "str", # Optional. A unique ID + that can be used to identify and reference the node. + "name": "str", # Optional. An + automatically generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A + string indicating the current status of the node. Known + values are: "provisioning", "running", "draining", and + "deleting". + }, + "updated_at": "2020-02-20 00:00:00" + # Optional. A time value given in ISO8601 combined date and + time format that represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for + the type of Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the + tags applied to the node pool. All node pools are automatically + tagged ``k8s``"" , ``k8s-worker``"" , and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires + ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the + node reacts to pods that it won't tolerate. Available effect + values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and + ``NoExecute``. Known values are: "NoSchedule", + "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An + arbitrary string. The ``key`` and ``value`` fields of the + ``taint`` object form a key-value pair. For example, if the + value of the ``key`` field is "special" and the value of the + ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + ], + "region": "str", # The slug identifier for the region where the + Kubernetes cluster is located. Required. + "version": "str", # The slug identifier for the version of + Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the + latest version within it will be used (e.g. "1.14.6-do.1"); if set to + "latest", the latest published version will be used. See the + ``/v2/kubernetes/options`` endpoint to find all currently available versions. + Required. + "amd_gpu_device_metrics_exporter_plugin": { + "enabled": bool # Optional. Indicates whether the AMD Device + Metrics Exporter is enabled. + }, + "amd_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the AMD GPU + Device Plugin is enabled. + }, + "amd_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the AMD GPU + DRA Driver is enabled. + }, + "auto_upgrade": False, # Optional. Default value is False. A boolean + value indicating whether the cluster will be automatically upgraded to new + patch releases during its maintenance window. + "cluster_autoscaler_configuration": { + "expanders": [ + "str" # Optional. Customizes expanders used by + cluster-autoscaler. The autoscaler will apply each expander from the + provided list to narrow down the selection of node types created to + scale up, until either a single node type is left, or the list of + expanders is exhausted. If this flag is unset, autoscaler will use + its default expander ``random``. Passing an empty list ("" *not* + ``null``"" ) will unset any previous expander customizations. + Available expanders: * ``random``"" : Randomly selects a node group + to scale. * `priority`: Selects the node group with the highest + priority as per [user-provided + configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) + * ``least_waste``"" : Selects the node group that will result in the + least amount of idle resources. + ], + "scale_down_unneeded_time": "str", # Optional. Used to + customize how long a node is unneeded before being scaled down. + "scale_down_utilization_threshold": 0.0 # Optional. Used to + customize when cluster autoscaler scales down non-empty nodes by setting + the node utilization threshold. + }, + "cluster_subnet": "str", # Optional. The range of IP addresses for + the overlay network of the Kubernetes cluster in CIDR notation. + "control_plane_firewall": { + "allowed_addresses": [ + "str" # Optional. An array of public addresses (IPv4 + or CIDR) allowed to access the control plane. + ], + "enabled": bool # Optional. Indicates whether the control + plane firewall is enabled. + }, + "coredns_autoscaler": { + "enabled": bool # Optional. Indicates whether the CoreDNS + Cluster Proportional Autoscaler add-on is enabled. + }, + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was created. + "endpoint": "str", # Optional. The base URL of the API server on the + Kubernetes master node. + "ha": bool, # Optional. A boolean value indicating whether the + control plane is run in a highly available configuration in the cluster. + Highly available control planes incur less downtime. The property cannot be + disabled. When omitted on create, the default is version-dependent; for DOKS + 1.36.0 and later, the default is true; for earlier versions, the default is + false. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a Kubernetes cluster. + "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes + master node. This will not be set if high availability is configured on the + cluster (v1.21+). + "isolated_workers": False, # Optional. Default value is False. A + boolean value indicating whether worker nodes in the cluster are not assigned + public IP addresses. When omitted on create, the default value is false. When + enabled, a NAT gateway must exist in the VPC where the cluster is created. + "maintenance_policy": { + "day": "str", # Optional. The day of the maintenance window + policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to + indicate an arbitrary week day. Known values are: "any", "monday", + "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". + "duration": "str", # Optional. The duration of the + maintenance window policy in human-readable format. + "start_time": "str" # Optional. The start time in UTC of the + maintenance window policy in 24-hour clock format / HH:MM notation (e.g., + ``15:00``"" ). + }, + "nfs_csi_plugin": { + "enabled": bool # Optional. Indicates whether the NFS CSI + plugin is enabled. + }, + "nvidia_gpu_device_plugin": { + "enabled": bool # Optional. Indicates whether the Nvidia GPU + Device Plugin is enabled. + }, + "nvidia_gpu_dra_driver": { + "enabled": bool # Optional. Indicates whether the NVIDIA GPU + DRA Driver is enabled. + }, + "p2p_oci_registry_plugin": { + "enabled": bool # Optional. Indicates whether the + Peer-to-peer OCI registry component is enabled. + }, + "rdma_shared_dev_plugin": { + "enabled": bool # Optional. Indicates whether the RDMA + shared device plugin is enabled. + }, + "registry_enabled": bool, # Optional. A read-only boolean value + indicating if a container registry is integrated with the cluster. + "routing_agent": { + "enabled": bool # Optional. Indicates whether the + routing-agent component is enabled. + }, + "service_subnet": "str", # Optional. The range of assignable IP + addresses for services running in the Kubernetes cluster in CIDR notation. + "sso": { + "client_id": "str", # Optional. The OIDC client ID + registered with the identity provider. Required when ``enabled`` is + ``true``. + "enabled": False, # Optional. Default value is False. + Indicates whether SSO authentication is enabled for the cluster. + "issuer_url": "str", # Optional. The OIDC issuer URL for the + identity provider. Required when ``enabled`` is ``true``. + "required": False # Optional. Default value is False. + Indicates whether any non-SSO forms of authentication are disallowed. Can + only be set to ``true`` when ``enabled`` is ``true``. + }, + "status": { + "message": "str", # Optional. An optional message providing + additional information about the current cluster state. + "state": "str" # Optional. A string indicating the current + status of the cluster. Known values are: "running", "provisioning", + "degraded", "error", "deleted", "upgrading", and "deleting". + }, + "surge_upgrade": False, # Optional. Default value is False. A + boolean value indicating whether surge upgrade is enabled/disabled for the + cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing + up new nodes before destroying the outdated nodes. + "tags": [ + "str" # Optional. An array of tags to apply to the + Kubernetes cluster. All clusters are automatically tagged ``k8s`` and + ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are + getting removed. + ], + "updated_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the Kubernetes + cluster was last updated. + "vpc_uuid": "str", # Optional. A string specifying the UUID of the + VPC to which the Kubernetes cluster is + assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet + to attach worker nodes to. When omitted on create, the default subnet for the + VPC is used. This value cannot be changed after the cluster is created. + ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` + scope. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_kubernetes_update_cluster_request( + cluster_id=cluster_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 202: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def delete_cluster(self, cluster_id: str, **kwargs: Any) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete a Kubernetes Cluster. + + To delete a Kubernetes cluster and all services deployed to it, send a DELETE + request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID``. + + A 204 status code with no body will be returned in response to a successful + request. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_kubernetes_delete_cluster_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """List Associated Resources for Cluster Deletion. + + To list the associated billable resources that can be destroyed along with a cluster, send a + GET request to the + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources`` endpoint. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "load_balancers": [ + { + "id": "str", # Optional. The ID of a resource associated + with a Kubernetes cluster. + "name": "str" # Optional. The name of a resource associated + with a Kubernetes cluster. + } + ], + "volume_snapshots": [ + { + "id": "str", # Optional. The ID of a resource associated + with a Kubernetes cluster. + "name": "str" # Optional. The name of a resource associated + with a Kubernetes cluster. + } + ], + "volumes": [ + { + "id": "str", # Optional. The ID of a resource associated + with a Kubernetes cluster. + "name": "str" # Optional. The name of a resource associated + with a Kubernetes cluster. + } + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_list_associated_resources_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def destroy_associated_resources_selective( + self, + cluster_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Selectively Delete a Cluster and its Associated Resources. + + To delete a Kubernetes cluster along with a subset of its associated resources, + send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. + + The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or + ``volume_snapshots`` keys each set to an array of IDs for the associated + resources to be destroyed. + + The IDs can be found by querying the cluster's associated resources endpoint. + Any associated resource not included in the request will remain and continue + to accrue changes on your account. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "load_balancers": [ + "str" # Optional. A list of IDs for associated load balancers to + destroy along with the cluster. + ], + "volume_snapshots": [ + "str" # Optional. A list of IDs for associated volume snapshots to + destroy along with the cluster. + ], + "volumes": [ + "str" # Optional. A list of IDs for associated volumes to destroy + along with the cluster. + ] + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def destroy_associated_resources_selective( + self, + cluster_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Selectively Delete a Cluster and its Associated Resources. + + To delete a Kubernetes cluster along with a subset of its associated resources, + send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. + + The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or + ``volume_snapshots`` keys each set to an array of IDs for the associated + resources to be destroyed. + + The IDs can be found by querying the cluster's associated resources endpoint. + Any associated resource not included in the request will remain and continue + to accrue changes on your account. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def destroy_associated_resources_selective( + self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Selectively Delete a Cluster and its Associated Resources. + + To delete a Kubernetes cluster along with a subset of its associated resources, + send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. + + The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or + ``volume_snapshots`` keys each set to an array of IDs for the associated + resources to be destroyed. + + The IDs can be found by querying the cluster's associated resources endpoint. + Any associated resource not included in the request will remain and continue + to accrue changes on your account. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "load_balancers": [ + "str" # Optional. A list of IDs for associated load balancers to + destroy along with the cluster. + ], + "volume_snapshots": [ + "str" # Optional. A list of IDs for associated volume snapshots to + destroy along with the cluster. + ], + "volumes": [ + "str" # Optional. A list of IDs for associated volumes to destroy + along with the cluster. + ] + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_kubernetes_destroy_associated_resources_selective_request( + cluster_id=cluster_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def destroy_associated_resources_dangerous( + self, cluster_id: str, **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete a Cluster and All of its Associated Resources (Dangerous). + + To delete a Kubernetes cluster with all of its associated resources, send a + DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/dangerous``. + A 204 status code with no body will be returned in response to a successful request. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_kubernetes_destroy_associated_resources_dangerous_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_kubeconfig( + self, + cluster_id: str, + *, + expiry_seconds: int = 0, + type: Optional[str] = None, + **kwargs: Any, + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Retrieve the kubeconfig for a Kubernetes Cluster. + + This endpoint returns a kubeconfig file in YAML format. It can be used to + connect to and administer the cluster using the Kubernetes command line tool, + ``kubectl``\\ , or other programs supporting kubeconfig files (e.g., client libraries). + + The resulting kubeconfig file uses token-based authentication for clusters + supporting it, and certificate-based authentication otherwise. For a list of + supported versions and more information, see "\\ `How to Connect to a DigitalOcean + Kubernetes Cluster + `_\\ ". + + To retrieve a kubeconfig file for use with a Kubernetes cluster, send a GET + request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig``. + + Clusters supporting token-based authentication may define an expiration by + passing a duration in seconds as a query parameter to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig?expiry_seconds=$DURATION_IN_SECONDS``. + If not set or 0, then the token will have a 7 day expiry. The query parameter + has no impact for other kubeconfig types. + + Using an ``sso`` kubeconfig type requires ``doctl`` to be installed to handle the client side + of the OAuth2 flow. + + Kubernetes Roles granted to a user are derived from that user's + DigitalOcean role. Predefined roles (Owner, Member, Modifier etc.) have an automatic mapping + to Kubernetes roles. Custom roles are not automatically mapped to any Kubernetes roles, + and require `additional configuration + `_ + by a cluster administrator. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :keyword expiry_seconds: The duration in seconds that the returned Kubernetes credentials will + be valid. If not set or 0, the credentials will have a 7 day expiry. Default value is 0. + :paramtype expiry_seconds: int + :keyword type: The type of credentials to return in the kubeconfig. When omitted, the + default credential type for the cluster is used: ``sso`` for clusters with SSO enabled, + ``token`` for clusters without SSO enabled. Known values are: "token" and "sso". Default value + is None. + :paramtype type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_kubernetes_get_kubeconfig_request( + cluster_id=cluster_id, + expiry_seconds=expiry_seconds, + type=type, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_credentials( + self, cluster_id: str, *, expiry_seconds: int = 0, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Retrieve Credentials for a Kubernetes Cluster. + + This endpoint returns a JSON object . It can be used to programmatically + construct Kubernetes clients which cannot parse kubeconfig files. + + The resulting JSON object contains token-based authentication for clusters + supporting it, and certificate-based authentication otherwise. For a list of + supported versions and more information, see "\\ `How to Connect to a DigitalOcean + Kubernetes Cluster + `_\\ ". + + To retrieve credentials for accessing a Kubernetes cluster, send a GET + request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials``. + + Clusters supporting token-based authentication may define an expiration by + passing a duration in seconds as a query parameter to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials?expiry_seconds=$DURATION_IN_SECONDS``. + If not set or 0, then the token will have a 7 day expiry. The query parameter + has no impact in certificate-based authentication. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :keyword expiry_seconds: The duration in seconds that the returned Kubernetes credentials will + be valid. If not set or 0, the credentials will have a 7 day expiry. Default value is 0. + :paramtype expiry_seconds: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "certificate_authority_data": bytes("bytes", encoding="utf-8"), # Optional. + A base64 encoding of bytes representing the certificate authority data for + accessing the cluster. + "client_certificate_data": bytes("bytes", encoding="utf-8"), # Optional. A + base64 encoding of bytes representing the x509 client certificate data for access + the cluster. This is only returned for clusters without support for token-based + authentication. Newly created Kubernetes clusters do not return credentials + using certificate-based authentication. For additional information, `see here + `_. + "client_key_data": bytes("bytes", encoding="utf-8"), # Optional. A base64 + encoding of bytes representing the x509 client key data for access the cluster. + This is only returned for clusters without support for token-based + authentication. Newly created Kubernetes clusters do not return credentials + using certificate-based authentication. For additional information, `see here + `_. + "expires_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the access token + expires. + "server": "str", # Optional. The URL used to access the cluster API server. + "token": "str" # Optional. An access token used to authenticate with the + cluster. This is only returned for clusters with support for token-based + authentication. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_get_credentials_request( + cluster_id=cluster_id, + expiry_seconds=expiry_seconds, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Available Upgrades for an Existing Kubernetes Cluster. + + To determine whether a cluster can be upgraded, and the versions to which it + can be upgraded, send a GET request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "available_upgrade_versions": [ + { + "kubernetes_version": "str", # Optional. The upstream + version string for the version of Kubernetes provided by a given slug. + "slug": "str", # Optional. The slug identifier for an + available version of Kubernetes for use when creating or updating a + cluster. The string contains both the upstream version of Kubernetes as + well as the DigitalOcean revision. + "supported_features": [ + "str" # Optional. The features available with the + version of Kubernetes provided by a given slug. + ] + } + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_get_available_upgrades_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def upgrade_cluster( + self, + cluster_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Upgrade a Kubernetes Cluster. + + To immediately upgrade a Kubernetes cluster to a newer patch release of + Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. + The body of the request must specify a version attribute. + + Available upgrade versions for a cluster can be fetched from + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "version": "str" # Optional. The slug identifier for the version of + Kubernetes that the cluster will be upgraded to. + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def upgrade_cluster( + self, + cluster_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Upgrade a Kubernetes Cluster. + + To immediately upgrade a Kubernetes cluster to a newer patch release of + Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. + The body of the request must specify a version attribute. + + Available upgrade versions for a cluster can be fetched from + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ @distributed_trace - def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + def upgrade_cluster( + self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Create a New Kubernetes Cluster. + """Upgrade a Kubernetes Cluster. - To create a new Kubernetes cluster, send a POST request to - ``/v2/kubernetes/clusters``. The request must contain at least one node pool - with at least one worker. + To immediately upgrade a Kubernetes cluster to a newer patch release of + Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. + The body of the request must specify a version attribute. - The request may contain a maintenance window policy describing a time period - when disruptive maintenance tasks may be carried out. Omitting the policy - implies that a window will be chosen automatically. See - `here `_ - for details. + Available upgrade versions for a cluster can be fetched from + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -185826,7 +194044,129 @@ def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: # JSON input template you can fill out and use as your body input. body = { - "name": "str", # A human-readable name for a Kubernetes cluster. Required. + "version": "str" # Optional. The slug identifier for the version of + Kubernetes that the cluster will be upgraded to. + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_kubernetes_upgrade_cluster_request( + cluster_id=cluster_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 202: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_node_pools(self, cluster_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """List All Node Pools in a Kubernetes Clusters. + + To list all of the node pools in a Kubernetes clusters, send a GET request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools``. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { "node_pools": [ { "auto_scale": bool, # Optional. A boolean value indicating @@ -185902,410 +194242,583 @@ def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: } ] } - ], - "region": "str", # The slug identifier for the region where the Kubernetes - cluster is located. Required. - "version": "str", # The slug identifier for the version of Kubernetes used - for the cluster. If set to a minor version (e.g. "1.14"), the latest version - within it will be used (e.g. "1.14.6-do.1"); if set to "latest", the latest - published version will be used. See the ``/v2/kubernetes/options`` endpoint to - find all currently available versions. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device Metrics - Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU Device - Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver - is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether the cluster will be automatically upgraded to new patch - releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to scale - up, until either a single node type is left, or the list of expanders is - exhausted. If this flag is unset, autoscaler will use its default - expander ``random``. Passing an empty list ("" *not* ``null``"" ) will - unset any previous expander customizations. Available expanders: * - ``random``"" : Randomly selects a node group to scale. * `priority`: - Selects the node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to customize how - long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting the - node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for the - overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 or - CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control plane - firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS Cluster - Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the Kubernetes cluster - was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the control plane - is run in a highly available configuration in the cluster. Highly available - control planes incur less downtime. The property cannot be disabled. When omitted - on create, the default is version-dependent; for DOKS 1.36.0 and later, the - default is true; for earlier versions, the default is false. + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_kubernetes_list_node_pools_request( + cluster_id=cluster_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def add_node_pool( + self, + cluster_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Add a Node Pool to a Kubernetes Cluster. + + To add an additional node pool to a Kubernetes clusters, send a POST request + to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following + attributes. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode for this + node pool. Only applicable to AMD GPU sizes that support partitioning. Immutable + after the node pool is created. When omitted, the GPUs in the pool are left + unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". "id": "str", # Optional. A unique ID that can be used to identify and - reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes master - node. This will not be set if high availability is configured on the cluster - (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A boolean - value indicating whether worker nodes in the cluster are not assigned public IP - addresses. When omitted on create, the default value is false. When enabled, a - NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window policy. - May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an - arbitrary week day. Known values are: "any", "monday", "tuesday", - "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the maintenance - window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI plugin is - enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU Device - Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA - Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI - registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA shared device - plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value indicating - if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the routing-agent - component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP addresses - for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID registered with - the identity provider. Required when ``enabled`` is ``true``. - "enabled": False, # Optional. Default value is False. Indicates - whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. Indicates - whether any non-SSO forms of authentication are disallowed. Can only be set - to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current status of - the cluster. Known values are: "running", "provisioning", "degraded", - "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether surge upgrade is enabled/disabled for the cluster. Surge - upgrade makes cluster upgrades fast and reliable by bringing up new nodes before - destroying the outdated nodes. + reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying labels + to apply to all nodes in a pool. Labels will automatically be applied to all + existing nodes and any subsequent nodes added to the pool. Note that when a label + is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the node was created. + "droplet_id": "str", # Optional. The ID of the Droplet used + for the worker node. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the node. + "name": "str", # Optional. An automatically generated, + human-readable name for the node. + "status": { + "state": "str" # Optional. A string indicating the + current status of the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A time value + given in ISO8601 combined date and time format that represents when the + node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type of Droplet used + as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` and - ``tag:create`` scope, as well as ``tag:delete`` if existing tags are getting - removed. + "str" # Optional. An array containing the tags applied to the node + pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , + and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the Kubernetes cluster - was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the VPC to - which the Kubernetes cluster is assigned.:code:`
`:code:`
`Requires - ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet to attach - worker nodes to. When omitted on create, the default subnet for the VPC is used. - This value cannot be changed after the cluster is created. ``vpc_uuid`` must - also be set. :code:`
`:code:`
`Requires ``vpc:read`` scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to pods + that it won't tolerate. Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: + "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] } # response body for status code(s): 201 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def add_node_pool( + self, + cluster_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Add a Node Pool to a Kubernetes Cluster. + + To add an additional node pool to a Kubernetes clusters, send a POST request + to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following + attributes. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. + "id": "str", # Optional. A unique ID that can be + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def add_node_pool( + self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Add a Node Pool to a Kubernetes Cluster. + + To add an additional node pool to a Kubernetes clusters, send a POST request + to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following + attributes. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode for this + node pool. Only applicable to AMD GPU sizes that support partitioning. Immutable + after the node pool is created. When omitted, the GPUs in the pool are left + unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" and + "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify and + reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying labels + to apply to all nodes in a pool. Labels will automatically be applied to all + existing nodes and any subsequent nodes added to the pool. Note that when a label + is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the node was created. + "droplet_id": "str", # Optional. The ID of the Droplet used + for the worker node. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the node. + "name": "str", # Optional. An automatically generated, + human-readable name for the node. + "status": { + "state": "str" # Optional. A string indicating the + current status of the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A time value + given in ISO8601 combined date and time format that represents when the + node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type of Droplet used + as workers in the node pool. + "tags": [ + "str" # Optional. An array containing the tags applied to the node + pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , + and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to pods + that it won't tolerate. Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: + "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } + ] + } + + # response body for status code(s): 201 + response == { + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. + "id": "str", # Optional. A unique ID that can be + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. + } + ], + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -186336,7 +194849,8 @@ def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: else: _json = body - _request = build_kubernetes_create_cluster_request( + _request = build_kubernetes_add_node_pool_request( + cluster_id=cluster_id, content_type=content_type, json=_json, content=_content, @@ -186354,27 +194868,44 @@ def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [201, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore @@ -186382,15 +194913,18 @@ def create_cluster(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: + def get_node_pool(self, cluster_id: str, node_pool_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Retrieve an Existing Kubernetes Cluster. + """Retrieve a Node Pool for a Kubernetes Cluster. - To show information about an existing Kubernetes cluster, send a GET request - to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID``. + To show information about a specific node pool in a Kubernetes cluster, send + a GET request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID``. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -186400,249 +194934,76 @@ def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: # response body for status code(s): 200 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": False, # Optional. Default value is False. A boolean value - indicating whether the control plane is run in a highly available - configuration in the cluster. Highly available control planes incur less - downtime. The property cannot be disabled. When omitted on create, the - default is version-dependent; for DOKS 1.36.0 and later, the default is true; - for earlier versions, the default is false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registries": [ - "str" # Optional. An array of integrated DOCR registries. - ], - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags applied to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - worker nodes are attached to. When unset, the default subnet for the VPC is - used.:code:`
`:code:`
`Requires ``vpc:read`` scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } # response body for status code(s): 404 @@ -186675,8 +195036,9 @@ def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_cluster_request( + _request = build_kubernetes_get_node_pool_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, headers=_headers, params=_params, ) @@ -186736,23 +195098,28 @@ def get_cluster(self, cluster_id: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore @overload - def update_cluster( + def update_node_pool( self, cluster_id: str, + node_pool_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Update a Kubernetes Cluster. + """Update a Node Pool in a Kubernetes Cluster. - To update a Kubernetes cluster, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the - attributes below. + To update the name of a node pool, edit the tags applied to it, or adjust its + number of nodes, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the + following attributes. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -186767,362 +195134,141 @@ def update_cluster( # JSON input template you can fill out and use as your body input. body = { - "name": "str", # A human-readable name for a Kubernetes cluster. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device Metrics - Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU Device - Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver - is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether the cluster will be automatically upgraded to new patch - releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to scale - up, until either a single node type is left, or the list of expanders is - exhausted. If this flag is unset, autoscaler will use its default - expander ``random``. Passing an empty list ("" *not* ``null``"" ) will - unset any previous expander customizations. Available expanders: * - ``random``"" : Randomly selects a node group to scale. * `priority`: - Selects the node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to customize how - long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting the - node utilization threshold. - }, - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 or - CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control plane - firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS Cluster - Proportional Autoscaler add-on is enabled. - }, - "ha": bool, # Optional. A boolean value indicating whether the control plane - is run in a highly available configuration in the cluster. Highly available - control planes incur less downtime. The property cannot be disabled. When omitted - on create, the default is version-dependent; for DOKS 1.36.0 and later, the - default is true; for earlier versions, the default is false. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window policy. - May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an - arbitrary week day. Known values are: "any", "monday", "tuesday", - "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the maintenance - window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI plugin is - enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU Device - Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA - Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI - registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA shared device - plugin is enabled. - }, - "routing_agent": { - "enabled": bool # Optional. Indicates whether the routing-agent - component is enabled. - }, - "sso": { - "client_id": "str", # Optional. The OIDC client ID registered with - the identity provider. Required when ``enabled`` is ``true``. - "enabled": False, # Optional. Default value is False. Indicates - whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. Indicates - whether any non-SSO forms of authentication are disallowed. Can only be set - to ``true`` when ``enabled`` is ``true``. - }, - "surge_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether surge upgrade is enabled/disabled for the cluster. Surge - upgrade makes cluster upgrades fast and reliable by bringing up new nodes before - destroying the outdated nodes. + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node pool. + "id": "str", # Optional. A unique ID that can be used to identify and + reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying labels + to apply to all nodes in a pool. Labels will automatically be applied to all + existing nodes and any subsequent nodes added to the pool. Note that when a label + is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the node was created. + "droplet_id": "str", # Optional. The ID of the Droplet used + for the worker node. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the node. + "name": "str", # Optional. An automatically generated, + human-readable name for the node. + "status": { + "state": "str" # Optional. A string indicating the + current status of the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A time value + given in ISO8601 combined date and time format that represents when the + node was last updated. + } + ], "tags": [ - "str" # Optional. An array of tags applied to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. + "str" # Optional. An array containing the tags applied to the node + pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , + and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to pods + that it won't tolerate. Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: + "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } ] } # response body for status code(s): 202 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } # response body for status code(s): 404 @@ -187139,23 +195285,28 @@ def update_cluster( """ @overload - def update_cluster( + def update_node_pool( self, cluster_id: str, + node_pool_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Update a Kubernetes Cluster. + """Update a Node Pool in a Kubernetes Cluster. - To update a Kubernetes cluster, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the - attributes below. + To update the name of a node pool, edit the tags applied to it, or adjust its + number of nodes, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the + following attributes. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -187170,249 +195321,76 @@ def update_cluster( # response body for status code(s): 202 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } # response body for status code(s): 404 @@ -187429,18 +195407,26 @@ def update_cluster( """ @distributed_trace - def update_cluster( - self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + def update_node_pool( + self, + cluster_id: str, + node_pool_id: str, + body: Union[JSON, IO[bytes]], + **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Update a Kubernetes Cluster. + """Update a Node Pool in a Kubernetes Cluster. - To update a Kubernetes cluster, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID`` and specify one or more of the - attributes below. + To update the name of a node pool, edit the tags applied to it, or adjust its + number of nodes, send a PUT request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the + following attributes. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] :return: JSON object @@ -187452,362 +195438,141 @@ def update_cluster( # JSON input template you can fill out and use as your body input. body = { - "name": "str", # A human-readable name for a Kubernetes cluster. Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device Metrics - Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU Device - Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU DRA Driver - is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether the cluster will be automatically upgraded to new patch - releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to scale - up, until either a single node type is left, or the list of expanders is - exhausted. If this flag is unset, autoscaler will use its default - expander ``random``. Passing an empty list ("" *not* ``null``"" ) will - unset any previous expander customizations. Available expanders: * - ``random``"" : Randomly selects a node group to scale. * `priority`: - Selects the node group with the highest priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to customize how - long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting the - node utilization threshold. - }, - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 or - CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control plane - firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS Cluster - Proportional Autoscaler add-on is enabled. - }, - "ha": bool, # Optional. A boolean value indicating whether the control plane - is run in a highly available configuration in the cluster. Highly available - control planes incur less downtime. The property cannot be disabled. When omitted - on create, the default is version-dependent; for DOKS 1.36.0 and later, the - default is true; for earlier versions, the default is false. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window policy. - May be one of ``monday`` through ``sunday``"" , or ``any`` to indicate an - arbitrary week day. Known values are: "any", "monday", "tuesday", - "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the maintenance - window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI plugin is - enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU Device - Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU DRA - Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the Peer-to-peer OCI - registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA shared device - plugin is enabled. - }, - "routing_agent": { - "enabled": bool # Optional. Indicates whether the routing-agent - component is enabled. - }, - "sso": { - "client_id": "str", # Optional. The OIDC client ID registered with - the identity provider. Required when ``enabled`` is ``true``. - "enabled": False, # Optional. Default value is False. Indicates - whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. Indicates - whether any non-SSO forms of authentication are disallowed. Can only be set - to ``true`` when ``enabled`` is ``true``. - }, - "surge_upgrade": False, # Optional. Default value is False. A boolean value - indicating whether surge upgrade is enabled/disabled for the cluster. Surge - upgrade makes cluster upgrades fast and reliable by bringing up new nodes before - destroying the outdated nodes. + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node pool. + "id": "str", # Optional. A unique ID that can be used to identify and + reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying labels + to apply to all nodes in a pool. Labels will automatically be applied to all + existing nodes and any subsequent nodes added to the pool. Note that when a label + is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this node pool + can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to + ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ + { + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the node was created. + "droplet_id": "str", # Optional. The ID of the Droplet used + for the worker node. + "id": "str", # Optional. A unique ID that can be used to + identify and reference the node. + "name": "str", # Optional. An automatically generated, + human-readable name for the node. + "status": { + "state": "str" # Optional. A string indicating the + current status of the node. Known values are: "provisioning", + "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A time value + given in ISO8601 combined date and time format that represents when the + node was last updated. + } + ], "tags": [ - "str" # Optional. An array of tags applied to the Kubernetes - cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. + "str" # Optional. An array containing the tags applied to the node + pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , + and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` + scope. + ], + "taints": [ + { + "effect": "str", # Optional. How the node reacts to pods + that it won't tolerate. Available effect values are ``NoSchedule``"" , + ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: + "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The ``key`` + and ``value`` fields of the ``taint`` object form a key-value pair. For + example, if the value of the ``key`` field is "special" and the value of + the ``value`` field is "gpu", the key value pair would be + ``special=gpu``. + } ] } # response body for status code(s): 202 response == { - "kubernetes_cluster": { - "name": "str", # A human-readable name for a Kubernetes cluster. - Required. - "node_pools": [ + "node_pool": { + "auto_scale": bool, # Optional. A boolean value indicating whether + auto-scaling is enabled for this node pool. + "count": 0, # Optional. The number of Droplet instances in the node + pool. + "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode + for this node pool. Only applicable to AMD GPU sizes that support + partitioning. Immutable after the node pool is created. When omitted, the + GPUs in the pool are left unpartitioned. Known values are: + "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". + "id": "str", # Optional. A unique ID that can be used to identify + and reference a specific node pool. + "labels": {}, # Optional. An object of key/value mappings specifying + labels to apply to all nodes in a pool. Labels will automatically be applied + to all existing nodes and any subsequent nodes added to the pool. Note that + when a label is removed, it is not deleted from the nodes in the pool. + "max_nodes": 0, # Optional. The maximum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "min_nodes": 0, # Optional. The minimum number of nodes that this + node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is + set to ``false``. + "name": "str", # Optional. A human-readable name for the node pool. + "nodes": [ { - "auto_scale": bool, # Optional. A boolean value - indicating whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet - instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes - that support partitioning. Immutable after the node pool is created. - When omitted, the GPUs in the pool are left unpartitioned. Known - values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". + "created_at": "2020-02-20 00:00:00", # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was created. + "droplet_id": "str", # Optional. The ID of the + Droplet used for the worker node. "id": "str", # Optional. A unique ID that can be - used to identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value - mappings specifying labels to apply to all nodes in a pool. Labels - will automatically be applied to all existing nodes and any - subsequent nodes added to the pool. Note that when a label is - removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of - nodes that this node pool can be auto-scaled to. The value will be - ``0`` if ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for - the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was created. - "droplet_id": "str", # Optional. The - ID of the Droplet used for the worker node. - "id": "str", # Optional. A unique ID - that can be used to identify and reference the node. - "name": "str", # Optional. An - automatically generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A - string indicating the current status of the node. Known - values are: "provisioning", "running", "draining", and - "deleting". - }, - "updated_at": "2020-02-20 00:00:00" - # Optional. A time value given in ISO8601 combined date and - time format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for - the type of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the - tags applied to the node pool. All node pools are automatically - tagged ``k8s``"" , ``k8s-worker``"" , and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires - ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the - node reacts to pods that it won't tolerate. Available effect - values are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An - arbitrary string. The ``key`` and ``value`` fields of the - ``taint`` object form a key-value pair. For example, if the - value of the ``key`` field is "special" and the value of the - ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] + used to identify and reference the node. + "name": "str", # Optional. An automatically + generated, human-readable name for the node. + "status": { + "state": "str" # Optional. A string + indicating the current status of the node. Known values are: + "provisioning", "running", "draining", and "deleting". + }, + "updated_at": "2020-02-20 00:00:00" # Optional. A + time value given in ISO8601 combined date and time format that + represents when the node was last updated. } ], - "region": "str", # The slug identifier for the region where the - Kubernetes cluster is located. Required. - "version": "str", # The slug identifier for the version of - Kubernetes used for the cluster. If set to a minor version (e.g. "1.14"), the - latest version within it will be used (e.g. "1.14.6-do.1"); if set to - "latest", the latest published version will be used. See the - ``/v2/kubernetes/options`` endpoint to find all currently available versions. - Required. - "amd_gpu_device_metrics_exporter_plugin": { - "enabled": bool # Optional. Indicates whether the AMD Device - Metrics Exporter is enabled. - }, - "amd_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the AMD GPU - Device Plugin is enabled. - }, - "amd_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the AMD GPU - DRA Driver is enabled. - }, - "auto_upgrade": False, # Optional. Default value is False. A boolean - value indicating whether the cluster will be automatically upgraded to new - patch releases during its maintenance window. - "cluster_autoscaler_configuration": { - "expanders": [ - "str" # Optional. Customizes expanders used by - cluster-autoscaler. The autoscaler will apply each expander from the - provided list to narrow down the selection of node types created to - scale up, until either a single node type is left, or the list of - expanders is exhausted. If this flag is unset, autoscaler will use - its default expander ``random``. Passing an empty list ("" *not* - ``null``"" ) will unset any previous expander customizations. - Available expanders: * ``random``"" : Randomly selects a node group - to scale. * `priority`: Selects the node group with the highest - priority as per [user-provided - configuration](https://docs.digitalocean.com/products/kubernetes/how-to/autoscale/#configuring-priority-expander) - * ``least_waste``"" : Selects the node group that will result in the - least amount of idle resources. - ], - "scale_down_unneeded_time": "str", # Optional. Used to - customize how long a node is unneeded before being scaled down. - "scale_down_utilization_threshold": 0.0 # Optional. Used to - customize when cluster autoscaler scales down non-empty nodes by setting - the node utilization threshold. - }, - "cluster_subnet": "str", # Optional. The range of IP addresses for - the overlay network of the Kubernetes cluster in CIDR notation. - "control_plane_firewall": { - "allowed_addresses": [ - "str" # Optional. An array of public addresses (IPv4 - or CIDR) allowed to access the control plane. - ], - "enabled": bool # Optional. Indicates whether the control - plane firewall is enabled. - }, - "coredns_autoscaler": { - "enabled": bool # Optional. Indicates whether the CoreDNS - Cluster Proportional Autoscaler add-on is enabled. - }, - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was created. - "endpoint": "str", # Optional. The base URL of the API server on the - Kubernetes master node. - "ha": bool, # Optional. A boolean value indicating whether the - control plane is run in a highly available configuration in the cluster. - Highly available control planes incur less downtime. The property cannot be - disabled. When omitted on create, the default is version-dependent; for DOKS - 1.36.0 and later, the default is true; for earlier versions, the default is - false. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a Kubernetes cluster. - "ipv4": "str", # Optional. The public IPv4 address of the Kubernetes - master node. This will not be set if high availability is configured on the - cluster (v1.21+). - "isolated_workers": False, # Optional. Default value is False. A - boolean value indicating whether worker nodes in the cluster are not assigned - public IP addresses. When omitted on create, the default value is false. When - enabled, a NAT gateway must exist in the VPC where the cluster is created. - "maintenance_policy": { - "day": "str", # Optional. The day of the maintenance window - policy. May be one of ``monday`` through ``sunday``"" , or ``any`` to - indicate an arbitrary week day. Known values are: "any", "monday", - "tuesday", "wednesday", "thursday", "friday", "saturday", and "sunday". - "duration": "str", # Optional. The duration of the - maintenance window policy in human-readable format. - "start_time": "str" # Optional. The start time in UTC of the - maintenance window policy in 24-hour clock format / HH:MM notation (e.g., - ``15:00``"" ). - }, - "nfs_csi_plugin": { - "enabled": bool # Optional. Indicates whether the NFS CSI - plugin is enabled. - }, - "nvidia_gpu_device_plugin": { - "enabled": bool # Optional. Indicates whether the Nvidia GPU - Device Plugin is enabled. - }, - "nvidia_gpu_dra_driver": { - "enabled": bool # Optional. Indicates whether the NVIDIA GPU - DRA Driver is enabled. - }, - "p2p_oci_registry_plugin": { - "enabled": bool # Optional. Indicates whether the - Peer-to-peer OCI registry component is enabled. - }, - "rdma_shared_dev_plugin": { - "enabled": bool # Optional. Indicates whether the RDMA - shared device plugin is enabled. - }, - "registry_enabled": bool, # Optional. A read-only boolean value - indicating if a container registry is integrated with the cluster. - "routing_agent": { - "enabled": bool # Optional. Indicates whether the - routing-agent component is enabled. - }, - "service_subnet": "str", # Optional. The range of assignable IP - addresses for services running in the Kubernetes cluster in CIDR notation. - "sso": { - "client_id": "str", # Optional. The OIDC client ID - registered with the identity provider. Required when ``enabled`` is - ``true``. - "enabled": False, # Optional. Default value is False. - Indicates whether SSO authentication is enabled for the cluster. - "issuer_url": "str", # Optional. The OIDC issuer URL for the - identity provider. Required when ``enabled`` is ``true``. - "required": False # Optional. Default value is False. - Indicates whether any non-SSO forms of authentication are disallowed. Can - only be set to ``true`` when ``enabled`` is ``true``. - }, - "status": { - "message": "str", # Optional. An optional message providing - additional information about the current cluster state. - "state": "str" # Optional. A string indicating the current - status of the cluster. Known values are: "running", "provisioning", - "degraded", "error", "deleted", "upgrading", and "deleting". - }, - "surge_upgrade": False, # Optional. Default value is False. A - boolean value indicating whether surge upgrade is enabled/disabled for the - cluster. Surge upgrade makes cluster upgrades fast and reliable by bringing - up new nodes before destroying the outdated nodes. + "size": "str", # Optional. The slug identifier for the type of + Droplet used as workers in the node pool. "tags": [ - "str" # Optional. An array of tags to apply to the - Kubernetes cluster. All clusters are automatically tagged ``k8s`` and - ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - and ``tag:create`` scope, as well as ``tag:delete`` if existing tags are - getting removed. + "str" # Optional. An array containing the tags applied to + the node pool. All node pools are automatically tagged ``k8s``"" , + ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. + :code:`
`:code:`
`Requires ``tag:read`` scope. ], - "updated_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the Kubernetes - cluster was last updated. - "vpc_uuid": "str", # Optional. A string specifying the UUID of the - VPC to which the Kubernetes cluster is - assigned.:code:`
`:code:`
`Requires ``vpc:read`` scope. - "worker_subnet_uuid": "str" # Optional. The UUID of the VPC subnet - to attach worker nodes to. When omitted on create, the default subnet for the - VPC is used. This value cannot be changed after the cluster is created. - ``vpc_uuid`` must also be set. :code:`
`:code:`
`Requires ``vpc:read`` - scope. + "taints": [ + { + "effect": "str", # Optional. How the node reacts to + pods that it won't tolerate. Available effect values are + ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known + values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". + "key": "str", # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + "value": "str" # Optional. An arbitrary string. The + ``key`` and ``value`` fields of the ``taint`` object form a key-value + pair. For example, if the value of the ``key`` field is "special" and + the value of the ``value`` field is "gpu", the key value pair would + be ``special=gpu``. + } + ] } } # response body for status code(s): 404 @@ -187851,8 +195616,9 @@ def update_cluster( else: _json = body - _request = build_kubernetes_update_cluster_request( + _request = build_kubernetes_update_node_pool_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, content_type=content_type, json=_json, content=_content, @@ -187915,18 +195681,23 @@ def update_cluster( return cast(JSON, deserialized) # type: ignore @distributed_trace - def delete_cluster(self, cluster_id: str, **kwargs: Any) -> Optional[JSON]: + def delete_node_pool( + self, cluster_id: str, node_pool_id: str, **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Delete a Kubernetes Cluster. + """Delete a Node Pool in a Kubernetes Cluster. - To delete a Kubernetes cluster and all services deployed to it, send a DELETE - request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID``. + To delete a node pool, send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID``. A 204 status code with no body will be returned in response to a successful - request. + request. Nodes in the pool will subsequently be drained and deleted. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :return: JSON object or None :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: @@ -187964,8 +195735,9 @@ def delete_cluster(self, cluster_id: str, **kwargs: Any) -> Optional[JSON]: cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_delete_cluster_request( + _request = build_kubernetes_delete_node_pool_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, headers=_headers, params=_params, ) @@ -188021,50 +195793,53 @@ def delete_cluster(self, cluster_id: str, **kwargs: Any) -> Optional[JSON]: return deserialized # type: ignore @distributed_trace - def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSON: + def delete_node( + self, + cluster_id: str, + node_pool_id: str, + node_id: str, + *, + skip_drain: int = 0, + replace: int = 0, + **kwargs: Any, + ) -> Optional[JSON]: # pylint: disable=line-too-long - """List Associated Resources for Cluster Deletion. + """Delete a Node in a Kubernetes Cluster. - To list the associated billable resources that can be destroyed along with a cluster, send a - GET request to the - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources`` endpoint. + To delete a single node in a pool, send a DELETE request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID``. + + Appending the ``skip_drain=1`` query parameter to the request causes node + draining to be skipped. Omitting the query parameter or setting its value to + ``0`` carries out draining prior to deletion. + + Appending the ``replace=1`` query parameter to the request causes the node to + be replaced by a new one after deletion. Omitting the query parameter or + setting its value to ``0`` deletes without replacement. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str - :return: JSON object - :rtype: JSON + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str + :param node_id: A unique ID that can be used to reference a node in a Kubernetes node pool. + Required. + :type node_id: str + :keyword skip_drain: Specifies whether or not to drain workloads from a node before it is + deleted. Setting it to ``1`` causes node draining to be skipped. Omitting the query parameter + or setting its value to ``0`` carries out draining prior to deletion. Default value is 0. + :paramtype skip_drain: int + :keyword replace: Specifies whether or not to replace a node after it has been deleted. Setting + it to ``1`` causes the node to be replaced by a new one after deletion. Omitting the query + parameter or setting its value to ``0`` deletes without replacement. Default value is 0. + :paramtype replace: int + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 - response == { - "load_balancers": [ - { - "id": "str", # Optional. The ID of a resource associated - with a Kubernetes cluster. - "name": "str" # Optional. The name of a resource associated - with a Kubernetes cluster. - } - ], - "volume_snapshots": [ - { - "id": "str", # Optional. The ID of a resource associated - with a Kubernetes cluster. - "name": "str" # Optional. The name of a resource associated - with a Kubernetes cluster. - } - ], - "volumes": [ - { - "id": "str", # Optional. The ID of a resource associated - with a Kubernetes cluster. - "name": "str" # Optional. The name of a resource associated - with a Kubernetes cluster. - } - ] - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -188093,10 +195868,14 @@ def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSON: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_list_associated_resources_request( + _request = build_kubernetes_delete_node_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, + node_id=node_id, + skip_drain=skip_drain, + replace=replace, headers=_headers, params=_params, ) @@ -188111,14 +195890,15 @@ def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [202, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - if response.status_code == 200: + if response.status_code == 202: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -188129,11 +195909,6 @@ def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSON: "int", response.headers.get("ratelimit-reset") ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -188151,36 +195926,32 @@ def list_associated_resources(self, cluster_id: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return deserialized # type: ignore @overload - def destroy_associated_resources_selective( + def recycle_node_pool( self, cluster_id: str, + node_pool_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any, ) -> Optional[JSON]: # pylint: disable=line-too-long - """Selectively Delete a Cluster and its Associated Resources. - - To delete a Kubernetes cluster along with a subset of its associated resources, - send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. - - The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or - ``volume_snapshots`` keys each set to an array of IDs for the associated - resources to be destroyed. + """Recycle a Kubernetes Node Pool. - The IDs can be found by querying the cluster's associated resources endpoint. - Any associated resource not included in the request will remain and continue - to accrue changes on your account. + The endpoint has been deprecated. Please use the DELETE + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` + method instead. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -188195,17 +195966,8 @@ def destroy_associated_resources_selective( # JSON input template you can fill out and use as your body input. body = { - "load_balancers": [ - "str" # Optional. A list of IDs for associated load balancers to - destroy along with the cluster. - ], - "volume_snapshots": [ - "str" # Optional. A list of IDs for associated volume snapshots to - destroy along with the cluster. - ], - "volumes": [ - "str" # Optional. A list of IDs for associated volumes to destroy - along with the cluster. + "nodes": [ + "str" # Optional. ] } @@ -188223,31 +195985,27 @@ def destroy_associated_resources_selective( """ @overload - def destroy_associated_resources_selective( + def recycle_node_pool( self, cluster_id: str, + node_pool_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, ) -> Optional[JSON]: # pylint: disable=line-too-long - """Selectively Delete a Cluster and its Associated Resources. - - To delete a Kubernetes cluster along with a subset of its associated resources, - send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. - - The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or - ``volume_snapshots`` keys each set to an array of IDs for the associated - resources to be destroyed. + """Recycle a Kubernetes Node Pool. - The IDs can be found by querying the cluster's associated resources endpoint. - Any associated resource not included in the request will remain and continue - to accrue changes on your account. + The endpoint has been deprecated. Please use the DELETE + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` + method instead. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -188274,48 +196032,38 @@ def destroy_associated_resources_selective( """ @distributed_trace - def destroy_associated_resources_selective( - self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + def recycle_node_pool( + self, + cluster_id: str, + node_pool_id: str, + body: Union[JSON, IO[bytes]], + **kwargs: Any, ) -> Optional[JSON]: # pylint: disable=line-too-long - """Selectively Delete a Cluster and its Associated Resources. - - To delete a Kubernetes cluster along with a subset of its associated resources, - send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective``. - - The JSON body of the request should include ``load_balancers``\\ , ``volumes``\\ , or - ``volume_snapshots`` keys each set to an array of IDs for the associated - resources to be destroyed. + """Recycle a Kubernetes Node Pool. - The IDs can be found by querying the cluster's associated resources endpoint. - Any associated resource not included in the request will remain and continue - to accrue changes on your account. + The endpoint has been deprecated. Please use the DELETE + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` + method instead. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. + Required. + :type node_pool_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] :return: JSON object or None :rtype: JSON or None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "load_balancers": [ - "str" # Optional. A list of IDs for associated load balancers to - destroy along with the cluster. - ], - "volume_snapshots": [ - "str" # Optional. A list of IDs for associated volume snapshots to - destroy along with the cluster. - ], - "volumes": [ - "str" # Optional. A list of IDs for associated volumes to destroy - along with the cluster. + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "nodes": [ + "str" # Optional. ] } @@ -188360,8 +196108,9 @@ def destroy_associated_resources_selective( else: _json = body - _request = build_kubernetes_destroy_associated_resources_selective_request( + _request = build_kubernetes_recycle_node_pool_request( cluster_id=cluster_id, + node_pool_id=node_pool_id, content_type=content_type, json=_json, content=_content, @@ -188379,7 +196128,7 @@ def destroy_associated_resources_selective( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [202, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore @@ -188387,7 +196136,7 @@ def destroy_associated_resources_selective( deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 202: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -188420,26 +196169,33 @@ def destroy_associated_resources_selective( return deserialized # type: ignore @distributed_trace - def destroy_associated_resources_dangerous( - self, cluster_id: str, **kwargs: Any - ) -> Optional[JSON]: + def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Delete a Cluster and All of its Associated Resources (Dangerous). + """Retrieve User Information for a Kubernetes Cluster. - To delete a Kubernetes cluster with all of its associated resources, send a - DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/dangerous``. - A 204 status code with no body will be returned in response to a successful request. + To show information the user associated with a Kubernetes cluster, send a GET + request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/user``. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "kubernetes_cluster_user": { + "groups": [ + "str" # Optional. A list of in-cluster groups that the user + belongs to. + ], + "username": "str" # Optional. The username for the cluster admin + user. + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -188468,9 +196224,9 @@ def destroy_associated_resources_dangerous( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_destroy_associated_resources_dangerous_request( + _request = build_kubernetes_get_cluster_user_request( cluster_id=cluster_id, headers=_headers, params=_params, @@ -188486,15 +196242,14 @@ def destroy_associated_resources_dangerous( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [200, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -188505,6 +196260,11 @@ def destroy_associated_resources_dangerous( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -188522,68 +196282,61 @@ def destroy_associated_resources_dangerous( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_kubeconfig( - self, - cluster_id: str, - *, - expiry_seconds: int = 0, - type: Optional[str] = None, - **kwargs: Any, - ) -> Optional[JSON]: + def list_options(self, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Retrieve the kubeconfig for a Kubernetes Cluster. - - This endpoint returns a kubeconfig file in YAML format. It can be used to - connect to and administer the cluster using the Kubernetes command line tool, - ``kubectl``\\ , or other programs supporting kubeconfig files (e.g., client libraries). - - The resulting kubeconfig file uses token-based authentication for clusters - supporting it, and certificate-based authentication otherwise. For a list of - supported versions and more information, see "\\ `How to Connect to a DigitalOcean - Kubernetes Cluster - `_\\ ". - - To retrieve a kubeconfig file for use with a Kubernetes cluster, send a GET - request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig``. - - Clusters supporting token-based authentication may define an expiration by - passing a duration in seconds as a query parameter to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/kubeconfig?expiry_seconds=$DURATION_IN_SECONDS``. - If not set or 0, then the token will have a 7 day expiry. The query parameter - has no impact for other kubeconfig types. - - Using an ``sso`` kubeconfig type requires ``doctl`` to be installed to handle the client side - of the OAuth2 flow. + """List Available Regions, Node Sizes, and Versions of Kubernetes. - Kubernetes Roles granted to a user are derived from that user's - DigitalOcean role. Predefined roles (Owner, Member, Modifier etc.) have an automatic mapping - to Kubernetes roles. Custom roles are not automatically mapped to any Kubernetes roles, - and require `additional configuration - `_ - by a cluster administrator. + To list the versions of Kubernetes available for use, the regions that support Kubernetes, and + the available node sizes, send a GET request to ``/v2/kubernetes/options``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :keyword expiry_seconds: The duration in seconds that the returned Kubernetes credentials will - be valid. If not set or 0, the credentials will have a 7 day expiry. Default value is 0. - :paramtype expiry_seconds: int - :keyword type: The type of credentials to return in the kubeconfig. When omitted, the - default credential type for the cluster is used: ``sso`` for clusters with SSO enabled, - ``token`` for clusters without SSO enabled. Known values are: "token" and "sso". Default value - is None. - :paramtype type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "options": { + "regions": [ + { + "name": "str", # Optional. A DigitalOcean region + where Kubernetes is available. + "slug": "str" # Optional. The identifier for a + region for use when creating a new cluster. + } + ], + "sizes": [ + { + "name": "str", # Optional. A Droplet size available + for use in a Kubernetes node pool. + "slug": "str" # Optional. The identifier for a size + for use when creating a new cluster. + } + ], + "versions": [ + { + "kubernetes_version": "str", # Optional. The + upstream version string for the version of Kubernetes provided by a + given slug. + "slug": "str", # Optional. The slug identifier for + an available version of Kubernetes for use when creating or updating + a cluster. The string contains both the upstream version of + Kubernetes as well as the DigitalOcean revision. + "supported_features": [ + "str" # Optional. The features available + with the version of Kubernetes provided by a given slug. + ] + } + ] + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -188612,12 +196365,9 @@ def get_kubeconfig( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_kubeconfig_request( - cluster_id=cluster_id, - expiry_seconds=expiry_seconds, - type=type, + _request = build_kubernetes_list_options_request( headers=_headers, params=_params, ) @@ -188638,7 +196388,6 @@ def get_kubeconfig( map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( @@ -188651,6 +196400,11 @@ def get_kubeconfig( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -188668,40 +196422,119 @@ def get_kubeconfig( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore - @distributed_trace - def get_credentials( - self, cluster_id: str, *, expiry_seconds: int = 0, **kwargs: Any + @overload + def run_cluster_lint( + self, + cluster_id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """Retrieve Credentials for a Kubernetes Cluster. + """Run Clusterlint Checks on a Kubernetes Cluster. - This endpoint returns a JSON object . It can be used to programmatically - construct Kubernetes clients which cannot parse kubeconfig files. + Clusterlint helps operators conform to Kubernetes best practices around + resources, security and reliability to avoid common problems while operating + or upgrading the clusters. - The resulting JSON object contains token-based authentication for clusters - supporting it, and certificate-based authentication otherwise. For a list of - supported versions and more information, see "\\ `How to Connect to a DigitalOcean - Kubernetes Cluster - `_\\ ". + To request a clusterlint run on your cluster, send a POST request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all + checks present in the ``doks`` group by default, if a request body is not + specified. Optionally specify the below attributes. - To retrieve credentials for accessing a Kubernetes cluster, send a GET - request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials``. + For information about the available checks, please refer to + `the clusterlint check documentation + `_. - Clusters supporting token-based authentication may define an expiration by - passing a duration in seconds as a query parameter to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/credentials?expiry_seconds=$DURATION_IN_SECONDS``. - If not set or 0, then the token will have a 7 day expiry. The query parameter - has no impact in certificate-based authentication. + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "exclude_checks": [ + "str" # Optional. An array of checks that will be run when + clusterlint executes checks. + ], + "exclude_groups": [ + "str" # Optional. An array of check groups that will be omitted when + clusterlint executes checks. + ], + "include_checks": [ + "str" # Optional. An array of checks that will be run when + clusterlint executes checks. + ], + "include_groups": [ + "str" # Optional. An array of check groups that will be run when + clusterlint executes checks. + ] + } + + # response body for status code(s): 202 + response == { + "run_id": "str" # Optional. ID of the clusterlint run that can be used later + to fetch the diagnostics. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def run_cluster_lint( + self, + cluster_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Run Clusterlint Checks on a Kubernetes Cluster. + + Clusterlint helps operators conform to Kubernetes best practices around + resources, security and reliability to avoid common problems while operating + or upgrading the clusters. + + To request a clusterlint run on your cluster, send a POST request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all + checks present in the ``doks`` group by default, if a request body is not + specified. Optionally specify the below attributes. + + For information about the available checks, please refer to + `the clusterlint check documentation + `_. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str - :keyword expiry_seconds: The duration in seconds that the returned Kubernetes credentials will - be valid. If not set or 0, the credentials will have a 7 day expiry. Default value is 0. - :paramtype expiry_seconds: int + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -188709,30 +196542,82 @@ def get_credentials( Example: .. code-block:: python - # response body for status code(s): 200 + # response body for status code(s): 202 response == { - "certificate_authority_data": bytes("bytes", encoding="utf-8"), # Optional. - A base64 encoding of bytes representing the certificate authority data for - accessing the cluster. - "client_certificate_data": bytes("bytes", encoding="utf-8"), # Optional. A - base64 encoding of bytes representing the x509 client certificate data for access - the cluster. This is only returned for clusters without support for token-based - authentication. Newly created Kubernetes clusters do not return credentials - using certificate-based authentication. For additional information, `see here - `_. - "client_key_data": bytes("bytes", encoding="utf-8"), # Optional. A base64 - encoding of bytes representing the x509 client key data for access the cluster. - This is only returned for clusters without support for token-based - authentication. Newly created Kubernetes clusters do not return credentials - using certificate-based authentication. For additional information, `see here - `_. - "expires_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the access token - expires. - "server": "str", # Optional. The URL used to access the cluster API server. - "token": "str" # Optional. An access token used to authenticate with the - cluster. This is only returned for clusters with support for token-based - authentication. + "run_id": "str" # Optional. ID of the clusterlint run that can be used later + to fetch the diagnostics. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def run_cluster_lint( + self, + cluster_id: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Run Clusterlint Checks on a Kubernetes Cluster. + + Clusterlint helps operators conform to Kubernetes best practices around + resources, security and reliability to avoid common problems while operating + or upgrading the clusters. + + To request a clusterlint run on your cluster, send a POST request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all + checks present in the ``doks`` group by default, if a request body is not + specified. Optionally specify the below attributes. + + For information about the available checks, please refer to + `the clusterlint check documentation + `_. + + :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. + :type cluster_id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "exclude_checks": [ + "str" # Optional. An array of checks that will be run when + clusterlint executes checks. + ], + "exclude_groups": [ + "str" # Optional. An array of check groups that will be omitted when + clusterlint executes checks. + ], + "include_checks": [ + "str" # Optional. An array of checks that will be run when + clusterlint executes checks. + ], + "include_groups": [ + "str" # Optional. An array of check groups that will be run when + clusterlint executes checks. + ] + } + + # response body for status code(s): 202 + response == { + "run_id": "str" # Optional. ID of the clusterlint run that can be used later + to fetch the diagnostics. } # response body for status code(s): 404 response == { @@ -188759,14 +196644,30 @@ def get_credentials( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_credentials_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_kubernetes_run_cluster_lint_request( cluster_id=cluster_id, - expiry_seconds=expiry_seconds, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -188781,14 +196682,14 @@ def get_credentials( response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [202, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: + if response.status_code == 202: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -188826,16 +196727,26 @@ def get_credentials( return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: + def get_cluster_lint_results( + self, cluster_id: str, *, run_id: Optional[str] = None, **kwargs: Any + ) -> JSON: # pylint: disable=line-too-long - """Retrieve Available Upgrades for an Existing Kubernetes Cluster. + """Fetch Clusterlint Diagnostics for a Kubernetes Cluster. - To determine whether a cluster can be upgraded, and the versions to which it - can be upgraded, send a GET request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + To request clusterlint diagnostics for your cluster, send a GET request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. If the ``run_id`` query + parameter is provided, then the diagnostics for the specific run is fetched. + By default, the latest results are shown. + + To find out how to address clusterlint feedback, please refer to + `the clusterlint check documentation + `_. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str + :keyword run_id: Specifies the clusterlint run whose results will be retrieved. Default value + is None. + :paramtype run_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -188845,20 +196756,31 @@ def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: # response body for status code(s): 200 response == { - "available_upgrade_versions": [ + "completed_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the schedule + clusterlint run request was completed. + "diagnostics": [ { - "kubernetes_version": "str", # Optional. The upstream - version string for the version of Kubernetes provided by a given slug. - "slug": "str", # Optional. The slug identifier for an - available version of Kubernetes for use when creating or updating a - cluster. The string contains both the upstream version of Kubernetes as - well as the DigitalOcean revision. - "supported_features": [ - "str" # Optional. The features available with the - version of Kubernetes provided by a given slug. - ] + "check_name": "str", # Optional. The clusterlint check that + resulted in the diagnostic. + "message": "str", # Optional. Feedback about the object for + users to fix. + "object": { + "kind": "str", # Optional. The kind of Kubernetes + API object. + "name": "str", # Optional. Name of the object. + "namespace": "str" # Optional. The namespace the + object resides in the cluster. + }, + "severity": "str" # Optional. Can be one of error, warning + or suggestion. } - ] + ], + "requested_at": "2020-02-20 00:00:00", # Optional. A time value given in + ISO8601 combined date and time format that represents when the schedule + clusterlint run request was made. + "run_id": "str" # Optional. Id of the clusterlint run that can be used later + to fetch the diagnostics. } # response body for status code(s): 404 response == { @@ -188890,8 +196812,9 @@ def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_available_upgrades_request( + _request = build_kubernetes_get_cluster_lint_results_request( cluster_id=cluster_id, + run_id=run_id, headers=_headers, params=_params, ) @@ -188951,33 +196874,25 @@ def get_available_upgrades(self, cluster_id: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore @overload - def upgrade_cluster( + def add_registry( # pylint: disable=inconsistent-return-statements self, - cluster_id: str, - body: JSON, + body: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any, - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Upgrade a Kubernetes Cluster. - - To immediately upgrade a Kubernetes cluster to a newer patch release of - Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. - The body of the request must specify a version attribute. + ) -> None: + """Add Container Registry to Kubernetes Clusters. - Available upgrade versions for a cluster can be fetched from - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + To integrate the container registry with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registry``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Required. + :param body: Default value is None. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -188985,89 +196900,152 @@ def upgrade_cluster( # JSON input template you can fill out and use as your body input. body = { - "version": "str" # Optional. The slug identifier for the version of - Kubernetes that the cluster will be upgraded to. - } - - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ] } """ @overload - def upgrade_cluster( + def add_registry( # pylint: disable=inconsistent-return-statements self, - cluster_id: str, - body: IO[bytes], + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any, - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Upgrade a Kubernetes Cluster. - - To immediately upgrade a Kubernetes cluster to a newer patch release of - Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. - The body of the request must specify a version attribute. + ) -> None: + """Add Container Registry to Kubernetes Clusters. - Available upgrade versions for a cluster can be fetched from - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + To integrate the container registry with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registry``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Required. + :param body: Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def add_registry( # pylint: disable=inconsistent-return-statements + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> None: + """Add Container Registry to Kubernetes Clusters. + + To integrate the container registry with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registry``. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + # JSON input template you can fill out and use as your body input. + body = { + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ] } """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @distributed_trace - def upgrade_cluster( - self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Upgrade a Kubernetes Cluster. + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - To immediately upgrade a Kubernetes cluster to a newer patch release of - Kubernetes, send a POST request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrade``. - The body of the request must specify a version attribute. + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - Available upgrade versions for a cluster can be fetched from - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades``. + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :return: JSON object or None - :rtype: JSON or None + _request = build_kubernetes_add_registry_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + def remove_registry( # pylint: disable=inconsistent-return-statements + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Remove Container Registry from Kubernetes Clusters. + + To remove the container registry from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registry``. + + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -189075,20 +197053,60 @@ def upgrade_cluster( # JSON input template you can fill out and use as your body input. body = { - "version": "str" # Optional. The slug identifier for the version of - Kubernetes that the cluster will be upgraded to. + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ] } + """ - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + @overload + def remove_registry( # pylint: disable=inconsistent-return-statements + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Remove Container Registry from Kubernetes Clusters. + + To remove the container registry from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registry``. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def remove_registry( # pylint: disable=inconsistent-return-statements + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> None: + """Remove Container Registry from Kubernetes Clusters. + + To remove the container registry from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registry``. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ] } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -189110,7 +197128,7 @@ def upgrade_cluster( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -189118,10 +197136,12 @@ def upgrade_cluster( if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + if body is not None: + _json = body + else: + _json = None - _request = build_kubernetes_upgrade_cluster_request( - cluster_id=cluster_id, + _request = build_kubernetes_remove_registry_request( content_type=content_type, json=_json, content=_content, @@ -189139,153 +197159,114 @@ def upgrade_cluster( response = pipeline_response.http_response - if response.status_code not in [202, 404]: + if response.status_code not in [204]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 202: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore - if response.content: - deserialized = response.json() - else: - deserialized = None + @overload + def add_registries( # pylint: disable=inconsistent-return-statements + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Add Container Registries to Kubernetes Clusters. - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + To integrate the container registries with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registries``. - return deserialized # type: ignore + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ], + "registries": [ + "str" # Optional. An array containing the registry names. + ] + } + """ + + @overload + def add_registries( # pylint: disable=inconsistent-return-statements + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> None: + """Add Container Registries to Kubernetes Clusters. + + To integrate the container registries with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registries``. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list_node_pools(self, cluster_id: str, **kwargs: Any) -> JSON: - # pylint: disable=line-too-long - """List All Node Pools in a Kubernetes Clusters. + def add_registries( # pylint: disable=inconsistent-return-statements + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> None: + """Add Container Registries to Kubernetes Clusters. - To list all of the node pools in a Kubernetes clusters, send a GET request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools``. + To integrate the container registries with Kubernetes clusters, send a POST request to + ``/v2/kubernetes/registries``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :return: JSON object - :rtype: JSON + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 - response == { - "node_pools": [ - { - "auto_scale": bool, # Optional. A boolean value indicating - whether auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in - the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU - partition mode for this node pool. Only applicable to AMD GPU sizes that - support partitioning. Immutable after the node pool is created. When - omitted, the GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to - identify and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings - specifying labels to apply to all nodes in a pool. Labels will - automatically be applied to all existing nodes and any subsequent nodes - added to the pool. Note that when a label is removed, it is not deleted - from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that - this node pool can be auto-scaled to. The value will be ``0`` if - ``auto_scale`` is set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that - this node pool can be auto-scaled to. The value will be ``0`` if - ``auto_scale`` is set to ``false``. - "name": "str", # Optional. A human-readable name for the - node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # - Optional. A time value given in ISO8601 combined date and time - format that represents when the node was created. - "droplet_id": "str", # Optional. The ID of - the Droplet used for the worker node. - "id": "str", # Optional. A unique ID that - can be used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # - Optional. A time value given in ISO8601 combined date and time - format that represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type - of Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags - applied to the node pool. All node pools are automatically tagged - ``k8s``"" , ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node - reacts to pods that it won't tolerate. Available effect values - are ``NoSchedule``"" , ``PreferNoSchedule``"" , and - ``NoExecute``. Known values are: "NoSchedule", - "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary - string. The ``key`` and ``value`` fields of the ``taint`` object - form a key-value pair. For example, if the value of the ``key`` - field is "special" and the value of the ``value`` field is "gpu", - the key value pair would be ``special=gpu``. - "value": "str" # Optional. An arbitrary - string. The ``key`` and ``value`` fields of the ``taint`` object - form a key-value pair. For example, if the value of the ``key`` - field is "special" and the value of the ``value`` field is "gpu", - the key value pair would be ``special=gpu``. - } - ] - } + # JSON input template you can fill out and use as your body input. + body = { + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. + ], + "registries": [ + "str" # Optional. An array containing the registry names. ] } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -189300,13 +197281,29 @@ def list_node_pools(self, cluster_id: str, **kwargs: Any) -> JSON: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_kubernetes_list_node_pools_request( - cluster_id=cluster_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_kubernetes_add_registries_request( + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -189321,75 +197318,46 @@ def list_node_pools(self, cluster_id: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [204]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore + return cls(pipeline_response, None, response_headers) # type: ignore @overload - def add_node_pool( + def remove_registries( # pylint: disable=inconsistent-return-statements self, - cluster_id: str, - body: JSON, + body: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any, - ) -> JSON: - # pylint: disable=line-too-long - """Add a Node Pool to a Kubernetes Cluster. + ) -> None: + """Remove Container Registries from Kubernetes Clusters. - To add an additional node pool to a Kubernetes clusters, send a POST request - to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following - attributes. + To remove the container registries from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registries``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Required. + :param body: Default value is None. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -189397,297 +197365,52 @@ def add_node_pool( # JSON input template you can fill out and use as your body input. body = { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode for this - node pool. Only applicable to AMD GPU sizes that support partitioning. Immutable - after the node pool is created. When omitted, the GPUs in the pool are left - unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify and - reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying labels - to apply to all nodes in a pool. Labels will automatically be applied to all - existing nodes and any subsequent nodes added to the pool. Note that when a label - is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the node was created. - "droplet_id": "str", # Optional. The ID of the Droplet used - for the worker node. - "id": "str", # Optional. A unique ID that can be used to - identify and reference the node. - "name": "str", # Optional. An automatically generated, - human-readable name for the node. - "status": { - "state": "str" # Optional. A string indicating the - current status of the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A time value - given in ISO8601 combined date and time format that represents when the - node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of Droplet used - as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to the node - pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , - and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to pods - that it won't tolerate. Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: - "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } + "registries": [ + "str" # Optional. An array containing the registry names. ] } - - # response body for status code(s): 201 - response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - } - ] - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ @overload - def add_node_pool( + def remove_registries( # pylint: disable=inconsistent-return-statements self, - cluster_id: str, - body: IO[bytes], + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any, - ) -> JSON: - # pylint: disable=line-too-long - """Add a Node Pool to a Kubernetes Cluster. + ) -> None: + """Remove Container Registries from Kubernetes Clusters. - To add an additional node pool to a Kubernetes clusters, send a POST request - to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following - attributes. + To remove the container registries from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registries``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Required. + :param body: Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 201 - response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - } - ] - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ @distributed_trace - def add_node_pool( - self, cluster_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Add a Node Pool to a Kubernetes Cluster. + def remove_registries( # pylint: disable=inconsistent-return-statements + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> None: + """Remove Container Registries from Kubernetes Clusters. - To add an additional node pool to a Kubernetes clusters, send a POST request - to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools`` with the following - attributes. + To remove the container registries from Kubernetes clusters, send a DELETE request to + ``/v2/kubernetes/registries``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -189695,161 +197418,14 @@ def add_node_pool( # JSON input template you can fill out and use as your body input. body = { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode for this - node pool. Only applicable to AMD GPU sizes that support partitioning. Immutable - after the node pool is created. When omitted, the GPUs in the pool are left - unpartitioned. Known values are: "AMD_PARTITION_MODE_SPX_NPS1" and - "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify and - reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying labels - to apply to all nodes in a pool. Labels will automatically be applied to all - existing nodes and any subsequent nodes added to the pool. Note that when a label - is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the node was created. - "droplet_id": "str", # Optional. The ID of the Droplet used - for the worker node. - "id": "str", # Optional. A unique ID that can be used to - identify and reference the node. - "name": "str", # Optional. An automatically generated, - human-readable name for the node. - "status": { - "state": "str" # Optional. A string indicating the - current status of the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A time value - given in ISO8601 combined date and time format that represents when the - node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of Droplet used - as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to the node - pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , - and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. + "cluster_uuids": [ + "str" # Optional. An array containing the UUIDs of Kubernetes + clusters. ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to pods - that it won't tolerate. Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: - "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } + "registries": [ + "str" # Optional. An array containing the registry names. ] } - - # response body for status code(s): 201 - response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - } - ] - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -189870,7 +197446,7 @@ def add_node_pool( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -189878,10 +197454,12 @@ def add_node_pool( if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + if body is not None: + _json = body + else: + _json = None - _request = build_kubernetes_add_node_pool_request( - cluster_id=cluster_id, + _request = build_kubernetes_remove_registries_request( content_type=content_type, json=_json, content=_content, @@ -189899,63 +197477,46 @@ def add_node_pool( response = pipeline_response.http_response - if response.status_code not in [201, 404]: + if response.status_code not in [204]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 201: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace - def get_node_pool(self, cluster_id: str, node_pool_id: str, **kwargs: Any) -> JSON: + def get_status_messages( + self, + cluster_id: str, + *, + since: Optional[datetime.datetime] = None, + **kwargs: Any, + ) -> JSON: # pylint: disable=line-too-long - """Retrieve a Node Pool for a Kubernetes Cluster. + """Fetch Status Messages for a Kubernetes Cluster. - To show information about a specific node pool in a Kubernetes cluster, send - a GET request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID``. + To retrieve status messages for a Kubernetes cluster, send a GET request to + ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/status_messages``. Status messages inform users of + any issues that come up during the cluster lifecycle. :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str + :keyword since: A timestamp used to return status messages emitted since the specified time. + The timestamp should be in ISO8601 format. Default value is None. + :paramtype since: ~datetime.datetime :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -189965,77 +197526,14 @@ def get_node_pool(self, cluster_id: str, node_pool_id: str, **kwargs: Any) -> JS # response body for status code(s): 200 response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. - } - ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - } - ] - } + "messages": [ + { + "message": "str", # Optional. Status information about the + cluster which impacts it's lifecycle. + "timestamp": "2020-02-20 00:00:00" # Optional. A timestamp + in ISO8601 format that represents when the status message was emitted. + } + ] } # response body for status code(s): 404 response == { @@ -190067,9 +197565,9 @@ def get_node_pool(self, cluster_id: str, node_pool_id: str, **kwargs: Any) -> JS cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_get_node_pool_request( + _request = build_kubernetes_get_status_messages_request( cluster_id=cluster_id, - node_pool_id=node_pool_id, + since=since, headers=_headers, params=_params, ) @@ -190128,29 +197626,47 @@ def get_node_pool(self, cluster_id: str, node_pool_id: str, **kwargs: Any) -> JS return cast(JSON, deserialized) # type: ignore + +class LoadBalancersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`load_balancers` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + @overload - def update_node_pool( - self, - cluster_id: str, - node_pool_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any, + def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update a Node Pool in a Kubernetes Cluster. + """Create a New Load Balancer. - To update the name of a node pool, edit the tags applied to it, or adjust its - number of nodes, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the - following attributes. + To create a new load balancer instance, send a POST request to + ``/v2/load_balancers``. + + You can specify the Droplets that will sit behind the load balancer using one + of two methods: + + + * Set ``droplet_ids`` to a list of specific Droplet IDs. + * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be + assigned to the load balancer. Additional Droplets will be automatically + assigned as they are tagged. + + These methods are mutually exclusive. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -190164,180 +197680,247 @@ def update_node_pool( .. code-block:: python # JSON input template you can fill out and use as your body input. - body = { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node pool. - "id": "str", # Optional. A unique ID that can be used to identify and - reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying labels - to apply to all nodes in a pool. Labels will automatically be applied to all - existing nodes and any subsequent nodes added to the pool. Note that when a label - is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the node was created. - "droplet_id": "str", # Optional. The ID of the Droplet used - for the worker node. - "id": "str", # Optional. A unique ID that can be used to - identify and reference the node. - "name": "str", # Optional. An automatically generated, - human-readable name for the node. - "status": { - "state": "str" # Optional. A string indicating the - current status of the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A time value - given in ISO8601 combined date and time format that represents when the - node was last updated. - } - ], - "tags": [ - "str" # Optional. An array containing the tags applied to the node - pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , - and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to pods - that it won't tolerate. Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: - "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] - } + body = {} # response body for status code(s): 202 response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ + "load_balancer": { + "forwarding_rules": [ { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. } ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. } - ] + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. } } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ @overload - def update_node_pool( - self, - cluster_id: str, - node_pool_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, + def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Update a Node Pool in a Kubernetes Cluster. + """Create a New Load Balancer. - To update the name of a node pool, edit the tags applied to it, or adjust its - number of nodes, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the - following attributes. + To create a new load balancer instance, send a POST request to + ``/v2/load_balancers``. + + You can specify the Droplets that will sit behind the load balancer using one + of two methods: + + + * Set ``droplet_ids`` to a list of specific Droplet IDs. + * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be + assigned to the load balancer. Additional Droplets will be automatically + assigned as they are tagged. + + These methods are mutually exclusive. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -190352,112 +197935,241 @@ def update_node_pool( # response body for status code(s): 202 response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ + "load_balancer": { + "forwarding_rules": [ { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. } ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. } - ] + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. } } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ @distributed_trace - def update_node_pool( - self, - cluster_id: str, - node_pool_id: str, - body: Union[JSON, IO[bytes]], - **kwargs: Any, - ) -> JSON: + def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Update a Node Pool in a Kubernetes Cluster. + """Create a New Load Balancer. - To update the name of a node pool, edit the tags applied to it, or adjust its - number of nodes, send a PUT request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`` with the - following attributes. + To create a new load balancer instance, send a POST request to + ``/v2/load_balancers``. + + You can specify the Droplets that will sit behind the load balancer using one + of two methods: + + + * Set ``droplet_ids`` to a list of specific Droplet IDs. + * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be + assigned to the load balancer. Additional Droplets will be automatically + assigned as they are tagged. + + These methods are mutually exclusive. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] :return: JSON object @@ -190468,155 +198180,224 @@ def update_node_pool( .. code-block:: python # JSON input template you can fill out and use as your body input. - body = { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node pool. - "id": "str", # Optional. A unique ID that can be used to identify and - reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying labels - to apply to all nodes in a pool. Labels will automatically be applied to all - existing nodes and any subsequent nodes added to the pool. Note that when a label - is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this node pool - can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is set to - ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ - { - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the node was created. - "droplet_id": "str", # Optional. The ID of the Droplet used - for the worker node. - "id": "str", # Optional. A unique ID that can be used to - identify and reference the node. - "name": "str", # Optional. An automatically generated, - human-readable name for the node. - "status": { - "state": "str" # Optional. A string indicating the - current status of the node. Known values are: "provisioning", - "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A time value - given in ISO8601 combined date and time format that represents when the - node was last updated. - } - ], - "tags": [ - "str" # Optional. An array containing the tags applied to the node - pool. All node pools are automatically tagged ``k8s``"" , ``k8s-worker``"" , - and ``k8s:$K8S_CLUSTER_ID``. :code:`
`:code:`
`Requires ``tag:read`` - scope. - ], - "taints": [ - { - "effect": "str", # Optional. How the node reacts to pods - that it won't tolerate. Available effect values are ``NoSchedule``"" , - ``PreferNoSchedule``"" , and ``NoExecute``. Known values are: - "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The ``key`` - and ``value`` fields of the ``taint`` object form a key-value pair. For - example, if the value of the ``key`` field is "special" and the value of - the ``value`` field is "gpu", the key value pair would be - ``special=gpu``. - } - ] - } + body = {} # response body for status code(s): 202 response == { - "node_pool": { - "auto_scale": bool, # Optional. A boolean value indicating whether - auto-scaling is enabled for this node pool. - "count": 0, # Optional. The number of Droplet instances in the node - pool. - "gpu_partition_mode": "str", # Optional. The AMD GPU partition mode - for this node pool. Only applicable to AMD GPU sizes that support - partitioning. Immutable after the node pool is created. When omitted, the - GPUs in the pool are left unpartitioned. Known values are: - "AMD_PARTITION_MODE_SPX_NPS1" and "AMD_PARTITION_MODE_DPX_NPS2". - "id": "str", # Optional. A unique ID that can be used to identify - and reference a specific node pool. - "labels": {}, # Optional. An object of key/value mappings specifying - labels to apply to all nodes in a pool. Labels will automatically be applied - to all existing nodes and any subsequent nodes added to the pool. Note that - when a label is removed, it is not deleted from the nodes in the pool. - "max_nodes": 0, # Optional. The maximum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "min_nodes": 0, # Optional. The minimum number of nodes that this - node pool can be auto-scaled to. The value will be ``0`` if ``auto_scale`` is - set to ``false``. - "name": "str", # Optional. A human-readable name for the node pool. - "nodes": [ + "load_balancer": { + "forwarding_rules": [ { - "created_at": "2020-02-20 00:00:00", # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was created. - "droplet_id": "str", # Optional. The ID of the - Droplet used for the worker node. - "id": "str", # Optional. A unique ID that can be - used to identify and reference the node. - "name": "str", # Optional. An automatically - generated, human-readable name for the node. - "status": { - "state": "str" # Optional. A string - indicating the current status of the node. Known values are: - "provisioning", "running", "draining", and "deleting". - }, - "updated_at": "2020-02-20 00:00:00" # Optional. A - time value given in ISO8601 combined date and time format that - represents when the node was last updated. + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. } ], - "size": "str", # Optional. The slug identifier for the type of - Droplet used as workers in the node pool. - "tags": [ - "str" # Optional. An array containing the tags applied to - the node pool. All node pools are automatically tagged ``k8s``"" , - ``k8s-worker``"" , and ``k8s:$K8S_CLUSTER_ID``. - :code:`
`:code:`
`Requires ``tag:read`` scope. - ], - "taints": [ + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ { - "effect": "str", # Optional. How the node reacts to - pods that it won't tolerate. Available effect values are - ``NoSchedule``"" , ``PreferNoSchedule``"" , and ``NoExecute``. Known - values are: "NoSchedule", "PreferNoSchedule", and "NoExecute". - "key": "str", # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. - "value": "str" # Optional. An arbitrary string. The - ``key`` and ``value`` fields of the ``taint`` object form a key-value - pair. For example, if the value of the ``key`` field is "special" and - the value of the ``value`` field is "gpu", the key value pair would - be ``special=gpu``. + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. } - ] + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. } } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -190647,9 +198428,7 @@ def update_node_pool( else: _json = body - _request = build_kubernetes_update_node_pool_request( - cluster_id=cluster_id, - node_pool_id=node_pool_id, + _request = build_load_balancers_create_request( content_type=content_type, json=_json, content=_content, @@ -190667,44 +198446,27 @@ def update_node_pool( response = pipeline_response.http_response - if response.status_code not in [202, 404]: + if response.status_code not in [202]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 202: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore @@ -190712,40 +198474,259 @@ def update_node_pool( return cast(JSON, deserialized) # type: ignore @distributed_trace - def delete_node_pool( - self, cluster_id: str, node_pool_id: str, **kwargs: Any - ) -> Optional[JSON]: + def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Delete a Node Pool in a Kubernetes Cluster. - - To delete a node pool, send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID``. + """List All Load Balancers. - A 204 status code with no body will be returned in response to a successful - request. Nodes in the pool will subsequently be drained and deleted. + To list all of the load balancer instances on your account, send a GET request + to ``/v2/load_balancers``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str - :return: JSON object or None - :rtype: JSON or None + :keyword per_page: Number of items returned per page. Default value is 20. + :paramtype per_page: int + :keyword page: Which 'page' of paginated results to return. Default value is 1. + :paramtype page: int + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "meta": { + "total": 0 # Optional. Number of objects returned by the request. + }, + "links": { + "pages": {} + }, + "load_balancers": [ + { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing + the port on which the load balancer instance will listen. + Required. + "entry_protocol": "str", # The protocol used + for traffic to the load balancer. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" + , or ``udp``. If you set the ``entry_protocol`` to ``udp``"" , + the ``target_protocol`` must be set to ``udp``. When using UDP, + the load balancer requires that you set up a health check with a + port that uses TCP, HTTP, or HTTPS to work properly. Required. + Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing + the port on the backend Droplets to which the load balancer will + send traffic. Required. + "target_protocol": "str", # The protocol + used for traffic from the load balancer to the backend Droplets. + The possible values are: ``http``"" , ``https``"" , ``http2``"" , + ``tcp``"" , or ``udp``. If you set the ``target_protocol`` to + ``udp``"" , the ``entry_protocol`` must be set to ``udp``. When + using UDP, the load balancer requires that you set up a health + check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "tcp", and + "udp". + "certificate_id": "str", # Optional. The ID + of the TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A + boolean value indicating whether SSL encrypted traffic will be + passed through to the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify + an algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time + value given in ISO8601 combined date and time format that represents when + the load balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. + Default value is False. A boolean value indicating whether to disable + automatic DNS record creation for Let's Encrypt certificates that are + added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID + of the TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean + value indicating if the domain is already managed by + DigitalOcean. If true, all A and AAAA records required to enable + Global load balancers will be automatically added. + "name": "str" # Optional. FQDN to associate + with a Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the + Droplets assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value + is False. A boolean value indicating whether HTTP keepalive connections + are maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is + False. A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing + traffic to the load balancer (in the form 'ip:1.2.3.4' or + 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying + traffic to the load balancer (in the form 'ip:1.2.3.4' or + 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean + flag to enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer + value as a percentage to indicate failure threshold to decide how the + regional priorities will take effect. A value of ``50`` would + indicate that the Global load balancer will choose a lower priority + region to forward traffic to once this failure threshold has been + reached for the higher priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string + to an integer priority value indicating preference for which + regional target a Global load balancer will forward traffic to. A + lower value indicates a higher priority. + }, + "target_port": 0, # Optional. An integer + representing the port on the target backends which the load balancer + will forward traffic to. + "target_protocol": "str" # Optional. The protocol + used for forwarding traffic from the load balancer to the target + backends. The possible values are ``http``"" , ``https`` and + ``http2``. Known values are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default + value is 10. The number of seconds between between two consecutive + health checks. + "healthy_threshold": 3, # Optional. Default value is + 3. The number of times a health check must pass for a backend Droplet + to be marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The + path on the backend Droplets to which the load balancer instance will + send a request. + "port": 80, # Optional. Default value is 80. An + integer representing the port on the backend Droplets on which the + health check will attempt a connection. + "protocol": "http", # Optional. Default value is + "http". The protocol used for health checks sent to the backend + Droplets. The possible values are ``http``"" , ``https``"" , or + ``tcp``. Known values are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default + value is 5. The number of seconds the load balancer instance will + wait for a response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value + is 5. The number of times a health check must fail for a backend + Droplet to be marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value + is 60. An integer value which configures the idle timeout for HTTP + requests to the target droplets. + "id": "str", # Optional. A unique ID that can be used to + identify and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the + public-facing IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load + balancer instance. + "network": "EXTERNAL", # Optional. Default value is + "EXTERNAL". A string indicating whether the load balancer should be + external or internal. Internal load balancers have no public IPs and are + only accessible to resources on the same VPC network. This property + cannot be updated after creating the load balancer. Known values are: + "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is + "IPV4". A string indicating whether the load balancer will support IPv4 + or both IPv4 and IPv6 networking. This property cannot be updated after + creating the load balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that + the load balancer is associated with. If no ID is provided at creation, + the load balancer associates with the user's default project. If an + invalid project ID is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value + is False. A boolean value indicating whether HTTP requests to the load + balancer on port 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that + represents whether new Droplets can be created in this region. + Required. + "features": [ + "str" # This attribute is set to an array + which contains features available in this region. Required. + ], + "name": "str", # The display name of the region. + This will be a full name that is used in the control panel and other + interfaces. Required. + "sizes": [ + "str" # This attribute is set to an array + which contains the identifying slugs for the sizes available in + this region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used + as a unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". + This field has been replaced by the ``size_unit`` field for all regions + except in AMS2, NYC2, and SFO1. Each available load balancer size now + equates to the load balancer having a set number of nodes. * + ``lb-small`` = 1 node * ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes + You can resize load balancers after creation up to once per hour. You + cannot resize a load balancer within the first hour of its creation. + Known values are: "lb-small", "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many + nodes the load balancer contains. Each additional node increases the load + balancer's ability to manage more connections. Load balancers can be + scaled up or down, and you can change the number of nodes after creation + up to once per hour. This field is currently not available in the AMS2, + NYC2, or SFO1 regions. Use the ``size`` field to scale load balancers + that reside in these regions. + "status": "str", # Optional. A status string indicating the + current state of the load balancer. This can be ``new``"" , ``active``"" + , or ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the + cookie sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of + seconds until the cookie set by the load balancer expires. This + attribute is only returned when using ``cookies`` for the sticky + sessions type. + "type": "none" # Optional. Default value is "none". + An attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values + are ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the + UUID of the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag + corresponding to Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of + the Regional load balancers to be used as target backends for a + Global load balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used + by the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. + The default value is ``DEFAULT``. Known values are: "DEFAULT" and + "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". + A string indicating whether the load balancer should be a standard + regional HTTP load balancer, a regional network load balancer that routes + traffic at the TCP/UDP transport layer, or a global load balancer. Known + values are: "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID + of the VPC to which the load balancer is assigned. + } + ] } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -190764,11 +198745,11 @@ def delete_node_pool( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_delete_node_pool_request( - cluster_id=cluster_id, - node_pool_id=node_pool_id, + _request = build_load_balancers_list_request( + per_page=per_page, + page=page, headers=_headers, params=_params, ) @@ -190783,94 +198764,266 @@ def delete_node_pool( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [200]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @distributed_trace - def delete_node( - self, - cluster_id: str, - node_pool_id: str, - node_id: str, - *, - skip_drain: int = 0, - replace: int = 0, - **kwargs: Any, - ) -> Optional[JSON]: + def get(self, lb_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Delete a Node in a Kubernetes Cluster. - - To delete a single node in a pool, send a DELETE request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID``. - - Appending the ``skip_drain=1`` query parameter to the request causes node - draining to be skipped. Omitting the query parameter or setting its value to - ``0`` carries out draining prior to deletion. + """Retrieve an Existing Load Balancer. - Appending the ``replace=1`` query parameter to the request causes the node to - be replaced by a new one after deletion. Omitting the query parameter or - setting its value to ``0`` deletes without replacement. + To show information about a load balancer instance, send a GET request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str - :param node_id: A unique ID that can be used to reference a node in a Kubernetes node pool. - Required. - :type node_id: str - :keyword skip_drain: Specifies whether or not to drain workloads from a node before it is - deleted. Setting it to ``1`` causes node draining to be skipped. Omitting the query parameter - or setting its value to ``0`` carries out draining prior to deletion. Default value is 0. - :paramtype skip_drain: int - :keyword replace: Specifies whether or not to replace a node after it has been deleted. Setting - it to ``1`` causes the node to be replaced by a new one after deletion. Omitting the query - parameter or setting its value to ``0`` deletes without replacement. Default value is 0. - :paramtype replace: int - :return: JSON object or None - :rtype: JSON or None + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "load_balancer": { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -190899,14 +199052,10 @@ def delete_node( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_kubernetes_delete_node_request( - cluster_id=cluster_id, - node_pool_id=node_pool_id, - node_id=node_id, - skip_drain=skip_drain, - replace=replace, + _request = build_load_balancers_get_request( + lb_id=lb_id, headers=_headers, params=_params, ) @@ -190921,15 +199070,14 @@ def delete_node( response = pipeline_response.http_response - if response.status_code not in [202, 404]: + if response.status_code not in [200, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 202: + if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -190940,6 +199088,11 @@ def delete_node( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -190957,51 +199110,262 @@ def delete_node( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @overload - def recycle_node_pool( + def update( self, - cluster_id: str, - node_pool_id: str, + lb_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any, - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Recycle a Kubernetes Node Pool. + """Update a Load Balancer. - The endpoint has been deprecated. Please use the DELETE - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` - method instead. + To update a load balancer's settings, send a PUT request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full + representation of the load balancer including existing attributes. It may + contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually + exclusive. **Note that any attribute that is not provided will be reset to its + default value.**. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python # JSON input template you can fill out and use as your body input. - body = { - "nodes": [ - "str" # Optional. - ] - } + body = {} + # response body for status code(s): 200 + response == { + "load_balancer": { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -191016,39 +199380,254 @@ def recycle_node_pool( """ @overload - def recycle_node_pool( + def update( self, - cluster_id: str, - node_pool_id: str, + lb_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Recycle a Kubernetes Node Pool. + """Update a Load Balancer. - The endpoint has been deprecated. Please use the DELETE - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` - method instead. + To update a load balancer's settings, send a PUT request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full + representation of the load balancer including existing attributes. It may + contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually + exclusive. **Note that any attribute that is not provided will be reset to its + default value.**. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "load_balancer": { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. + } + } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -191063,41 +199642,247 @@ def recycle_node_pool( """ @distributed_trace - def recycle_node_pool( - self, - cluster_id: str, - node_pool_id: str, - body: Union[JSON, IO[bytes]], - **kwargs: Any, - ) -> Optional[JSON]: + def update(self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Recycle a Kubernetes Node Pool. + """Update a Load Balancer. - The endpoint has been deprecated. Please use the DELETE - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID/nodes/$NODE_ID`` - method instead. + To update a load balancer's settings, send a PUT request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full + representation of the load balancer including existing attributes. It may + contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually + exclusive. **Note that any attribute that is not provided will be reset to its + default value.**. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param node_pool_id: A unique ID that can be used to reference a Kubernetes node pool. - Required. - :type node_pool_id: str + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python # JSON input template you can fill out and use as your body input. - body = { - "nodes": [ - "str" # Optional. - ] + body = {} + + # response body for status code(s): 200 + response == { + "load_balancer": { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port + on which the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for + traffic to the load balancer. The possible values are: ``http``"" , + ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If + you set the ``entry_protocol`` to ``udp``"" , the + ``target_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "http3", "tcp", and "udp". + "target_port": 0, # An integer representing the port + on the backend Droplets to which the load balancer will send traffic. + Required. + "target_protocol": "str", # The protocol used for + traffic from the load balancer to the backend Droplets. The possible + values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or + ``udp``. If you set the ``target_protocol`` to ``udp``"" , the + ``entry_protocol`` must be set to ``udp``. When using UDP, the load + balancer requires that you set up a health check with a port that + uses TCP, HTTP, or HTTPS to work properly. Required. Known values + are: "http", "https", "http2", "tcp", and "udp". + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to + the backend Droplets. + } + ], + "algorithm": "round_robin", # Optional. Default value is + "round_robin". This field has been deprecated. You can no longer specify an + algorithm for load balancers. Known values are: "round_robin" and + "least_connections". + "created_at": "2020-02-20 00:00:00", # Optional. A time value given + in ISO8601 combined date and time format that represents when the load + balancer was created. + "disable_lets_encrypt_dns_records": False, # Optional. Default value + is False. A boolean value indicating whether to disable automatic DNS record + creation for Let's Encrypt certificates that are added to the load balancer. + "domains": [ + { + "certificate_id": "str", # Optional. The ID of the + TLS certificate used for SSL termination. + "is_managed": bool, # Optional. A boolean value + indicating if the domain is already managed by DigitalOcean. If true, + all A and AAAA records required to enable Global load balancers will + be automatically added. + "name": "str" # Optional. FQDN to associate with a + Global load balancer. + } + ], + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets + assigned to the load balancer. + ], + "enable_backend_keepalive": False, # Optional. Default value is + False. A boolean value indicating whether HTTP keepalive connections are + maintained to target Droplets. + "enable_proxy_protocol": False, # Optional. Default value is False. + A boolean value indicating whether PROXY Protocol is in use. + "firewall": { + "allow": [ + "str" # Optional. the rules for allowing traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ], + "deny": [ + "str" # Optional. the rules for denying traffic to + the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). + ] + }, + "glb_settings": { + "cdn": { + "is_enabled": bool # Optional. A boolean flag to + enable CDN caching. + }, + "failover_threshold": 0, # Optional. An integer value as a + percentage to indicate failure threshold to decide how the regional + priorities will take effect. A value of ``50`` would indicate that the + Global load balancer will choose a lower priority region to forward + traffic to once this failure threshold has been reached for the higher + priority region. + "region_priorities": { + "str": 0 # Optional. A map of region string to an + integer priority value indicating preference for which regional + target a Global load balancer will forward traffic to. A lower value + indicates a higher priority. + }, + "target_port": 0, # Optional. An integer representing the + port on the target backends which the load balancer will forward traffic + to. + "target_protocol": "str" # Optional. The protocol used for + forwarding traffic from the load balancer to the target backends. The + possible values are ``http``"" , ``https`` and ``http2``. Known values + are: "http", "https", and "http2". + }, + "health_check": { + "check_interval_seconds": 10, # Optional. Default value is + 10. The number of seconds between between two consecutive health checks. + "healthy_threshold": 3, # Optional. Default value is 3. The + number of times a health check must pass for a backend Droplet to be + marked "healthy" and be re-added to the pool. + "path": "/", # Optional. Default value is "/". The path on + the backend Droplets to which the load balancer instance will send a + request. + "port": 80, # Optional. Default value is 80. An integer + representing the port on the backend Droplets on which the health check + will attempt a connection. + "protocol": "http", # Optional. Default value is "http". The + protocol used for health checks sent to the backend Droplets. The + possible values are ``http``"" , ``https``"" , or ``tcp``. Known values + are: "http", "https", and "tcp". + "response_timeout_seconds": 5, # Optional. Default value is + 5. The number of seconds the load balancer instance will wait for a + response until marking a health check as failed. + "unhealthy_threshold": 5 # Optional. Default value is 5. The + number of times a health check must fail for a backend Droplet to be + marked "unhealthy" and be removed from the pool. + }, + "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An + integer value which configures the idle timeout for HTTP requests to the + target droplets. + "id": "str", # Optional. A unique ID that can be used to identify + and reference a load balancer. + "ipv6": "str", # Optional. An attribute containing the public-facing + IPv6 address of the load balancer. + "name": "str", # Optional. A human-readable name for a load balancer + instance. + "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A + string indicating whether the load balancer should be external or internal. + Internal load balancers have no public IPs and are only accessible to + resources on the same VPC network. This property cannot be updated after + creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". + "network_stack": "IPV4", # Optional. Default value is "IPV4". A + string indicating whether the load balancer will support IPv4 or both IPv4 + and IPv6 networking. This property cannot be updated after creating the load + balancer. Known values are: "IPV4" and "DUALSTACK". + "project_id": "str", # Optional. The ID of the project that the load + balancer is associated with. If no ID is provided at creation, the load + balancer associates with the user's default project. If an invalid project ID + is provided, the load balancer will not be created. + "redirect_http_to_https": False, # Optional. Default value is False. + A boolean value indicating whether HTTP requests to the load balancer on port + 80 will be redirected to HTTPS on port 443. + "region": { + "available": bool, # This is a boolean value that represents + whether new Droplets can be created in this region. Required. + "features": [ + "str" # This attribute is set to an array which + contains features available in this region. Required. + ], + "name": "str", # The display name of the region. This will + be a full name that is used in the control panel and other interfaces. + Required. + "sizes": [ + "str" # This attribute is set to an array which + contains the identifying slugs for the sizes available in this + region. sizes:read is required to view. Required. + ], + "slug": "str" # A human-readable string that is used as a + unique identifier for each region. Required. + }, + "size": "lb-small", # Optional. Default value is "lb-small". This + field has been replaced by the ``size_unit`` field for all regions except in + AMS2, NYC2, and SFO1. Each available load balancer size now equates to the + load balancer having a set number of nodes. * ``lb-small`` = 1 node * + ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load + balancers after creation up to once per hour. You cannot resize a load + balancer within the first hour of its creation. Known values are: "lb-small", + "lb-medium", and "lb-large". + "size_unit": 1, # Optional. Default value is 1. How many nodes the + load balancer contains. Each additional node increases the load balancer's + ability to manage more connections. Load balancers can be scaled up or down, + and you can change the number of nodes after creation up to once per hour. + This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use + the ``size`` field to scale load balancers that reside in these regions. + "status": "str", # Optional. A status string indicating the current + state of the load balancer. This can be ``new``"" , ``active``"" , or + ``errored``. Known values are: "new", "active", and "errored". + "sticky_sessions": { + "cookie_name": "str", # Optional. The name of the cookie + sent to the client. This attribute is only returned when using + ``cookies`` for the sticky sessions type. + "cookie_ttl_seconds": 0, # Optional. The number of seconds + until the cookie set by the load balancer expires. This attribute is only + returned when using ``cookies`` for the sticky sessions type. + "type": "none" # Optional. Default value is "none". An + attribute indicating how and if requests from a client will be + persistently served by the same backend Droplet. The possible values are + ``cookies`` or ``none``. Known values are: "cookies" and "none". + }, + "subnet_uuid": "str", # Optional. A string specifying the UUID of + the VPC subnet to which the load balancer is assigned. + "tag": "str", # Optional. The name of a Droplet tag corresponding to + Droplets assigned to the load balancer. + "target_load_balancer_ids": [ + "str" # Optional. An array containing the UUIDs of the + Regional load balancers to be used as target backends for a Global load + balancer. + ], + "tls_cipher_policy": "DEFAULT", # Optional. Default value is + "DEFAULT". A string indicating the policy for the TLS cipher suites used by + the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The + default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". + "type": "REGIONAL", # Optional. Default value is "REGIONAL". A + string indicating whether the load balancer should be a standard regional + HTTP load balancer, a regional network load balancer that routes traffic at + the TCP/UDP transport layer, or a global load balancer. Known values are: + "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". + "vpc_uuid": "str" # Optional. A string specifying the UUID of the + VPC to which the load balancer is assigned. + } } - # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -191129,7 +199914,7 @@ def recycle_node_pool( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -191139,9 +199924,8 @@ def recycle_node_pool( else: _json = body - _request = build_kubernetes_recycle_node_pool_request( - cluster_id=cluster_id, - node_pool_id=node_pool_id, + _request = build_load_balancers_update_request( + lb_id=lb_id, content_type=content_type, json=_json, content=_content, @@ -191159,15 +199943,14 @@ def recycle_node_pool( response = pipeline_response.http_response - if response.status_code not in [202, 404]: + if response.status_code not in [200, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 202: + if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -191178,6 +199961,11 @@ def recycle_node_pool( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -191195,38 +199983,31 @@ def recycle_node_pool( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: + def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: # pylint: disable=line-too-long - """Retrieve User Information for a Kubernetes Cluster. + """Delete a Load Balancer. - To show information the user associated with a Kubernetes cluster, send a GET - request to ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/user``. + To delete a load balancer instance, disassociating any Droplets assigned to it + and removing it from your account, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID``. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :return: JSON object - :rtype: JSON + A successful request will receive a 204 status code with no body in response. + This indicates that the request was processed successfully. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 - response == { - "kubernetes_cluster_user": { - "groups": [ - "str" # Optional. A list of in-cluster groups that the user - belongs to. - ], - "username": "str" # Optional. The username for the cluster admin - user. - } - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -191255,10 +200036,10 @@ def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_get_cluster_user_request( - cluster_id=cluster_id, + _request = build_load_balancers_delete_request( + lb_id=lb_id, headers=_headers, params=_params, ) @@ -191273,14 +200054,15 @@ def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [204, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - if response.status_code == 200: + if response.status_code == 204: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -191291,11 +200073,6 @@ def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: "int", response.headers.get("ratelimit-reset") ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -191313,61 +200090,30 @@ def get_cluster_user(self, cluster_id: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return deserialized # type: ignore @distributed_trace - def list_options(self, **kwargs: Any) -> JSON: + def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: # pylint: disable=line-too-long - """List Available Regions, Node Sizes, and Versions of Kubernetes. + """Delete a Global Load Balancer CDN Cache. - To list the versions of Kubernetes available for use, the regions that support Kubernetes, and - the available node sizes, send a GET request to ``/v2/kubernetes/options``. + To delete a Global load balancer CDN cache, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/cache``. - :return: JSON object - :rtype: JSON + A successful request will receive a 204 status code with no body in response. + This indicates that the request was processed successfully. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 - response == { - "options": { - "regions": [ - { - "name": "str", # Optional. A DigitalOcean region - where Kubernetes is available. - "slug": "str" # Optional. The identifier for a - region for use when creating a new cluster. - } - ], - "sizes": [ - { - "name": "str", # Optional. A Droplet size available - for use in a Kubernetes node pool. - "slug": "str" # Optional. The identifier for a size - for use when creating a new cluster. - } - ], - "versions": [ - { - "kubernetes_version": "str", # Optional. The - upstream version string for the version of Kubernetes provided by a - given slug. - "slug": "str", # Optional. The slug identifier for - an available version of Kubernetes for use when creating or updating - a cluster. The string contains both the upstream version of - Kubernetes as well as the DigitalOcean revision. - "supported_features": [ - "str" # Optional. The features available - with the version of Kubernetes provided by a given slug. - ] - } - ] - } - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -191396,9 +200142,10 @@ def list_options(self, **kwargs: Any) -> JSON: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_list_options_request( + _request = build_load_balancers_delete_cache_request( + lb_id=lb_id, headers=_headers, params=_params, ) @@ -191413,14 +200160,15 @@ def list_options(self, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [204, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - if response.status_code == 200: + if response.status_code == 204: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -191431,11 +200179,6 @@ def list_options(self, **kwargs: Any) -> JSON: "int", response.headers.get("ratelimit-reset") ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -191453,44 +200196,42 @@ def list_options(self, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return deserialized # type: ignore @overload - def run_cluster_lint( + def add_droplets( self, - cluster_id: str, - body: Optional[JSON] = None, + lb_id: str, + body: JSON, *, content_type: str = "application/json", **kwargs: Any, - ) -> JSON: + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Run Clusterlint Checks on a Kubernetes Cluster. - - Clusterlint helps operators conform to Kubernetes best practices around - resources, security and reliability to avoid common problems while operating - or upgrading the clusters. + """Add Droplets to a Load Balancer. - To request a clusterlint run on your cluster, send a POST request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all - checks present in the ``doks`` group by default, if a request body is not - specified. Optionally specify the below attributes. + To assign a Droplet to a load balancer instance, send a POST request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. + Individual Droplets can not be added to a load balancer configured with a + Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" + response from the API. - For information about the available checks, please refer to - `the clusterlint check documentation - `_. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Default value is None. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -191498,29 +200239,12 @@ def run_cluster_lint( # JSON input template you can fill out and use as your body input. body = { - "exclude_checks": [ - "str" # Optional. An array of checks that will be run when - clusterlint executes checks. - ], - "exclude_groups": [ - "str" # Optional. An array of check groups that will be omitted when - clusterlint executes checks. - ], - "include_checks": [ - "str" # Optional. An array of checks that will be run when - clusterlint executes checks. - ], - "include_groups": [ - "str" # Optional. An array of check groups that will be run when - clusterlint executes checks. + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets assigned + to the load balancer. ] } - # response body for status code(s): 202 - response == { - "run_id": "str" # Optional. ID of the clusterlint run that can be used later - to fetch the diagnostics. - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -191535,121 +200259,42 @@ def run_cluster_lint( """ @overload - def run_cluster_lint( + def add_droplets( self, - cluster_id: str, - body: Optional[IO[bytes]] = None, + lb_id: str, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> JSON: + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Run Clusterlint Checks on a Kubernetes Cluster. - - Clusterlint helps operators conform to Kubernetes best practices around - resources, security and reliability to avoid common problems while operating - or upgrading the clusters. + """Add Droplets to a Load Balancer. - To request a clusterlint run on your cluster, send a POST request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all - checks present in the ``doks`` group by default, if a request body is not - specified. Optionally specify the below attributes. + To assign a Droplet to a load balancer instance, send a POST request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. + Individual Droplets can not be added to a load balancer configured with a + Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" + response from the API. - For information about the available checks, please refer to - `the clusterlint check documentation - `_. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Default value is None. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "run_id": "str" # Optional. ID of the clusterlint run that can be used later - to fetch the diagnostics. - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ - - @distributed_trace - def run_cluster_lint( - self, - cluster_id: str, - body: Optional[Union[JSON, IO[bytes]]] = None, - **kwargs: Any, - ) -> JSON: - # pylint: disable=line-too-long - """Run Clusterlint Checks on a Kubernetes Cluster. - - Clusterlint helps operators conform to Kubernetes best practices around - resources, security and reliability to avoid common problems while operating - or upgrading the clusters. - - To request a clusterlint run on your cluster, send a POST request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. This will run all - checks present in the ``doks`` group by default, if a request body is not - specified. Optionally specify the below attributes. - - For information about the available checks, please refer to - `the clusterlint check documentation - `_. - - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "exclude_checks": [ - "str" # Optional. An array of checks that will be run when - clusterlint executes checks. - ], - "exclude_groups": [ - "str" # Optional. An array of check groups that will be omitted when - clusterlint executes checks. - ], - "include_checks": [ - "str" # Optional. An array of checks that will be run when - clusterlint executes checks. - ], - "include_groups": [ - "str" # Optional. An array of check groups that will be run when - clusterlint executes checks. - ] - } - - # response body for status code(s): 202 - response == { - "run_id": "str" # Optional. ID of the clusterlint run that can be used later - to fetch the diagnostics. - } # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -191662,627 +200307,31 @@ def run_cluster_lint( tickets to help identify the issue. } """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - 401: cast( - Type[HttpResponseError], - lambda response: ClientAuthenticationError(response=response), - ), - 429: HttpResponseError, - 500: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[JSON] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = body - else: - _json = None - - _request = build_kubernetes_run_cluster_lint_request( - cluster_id=cluster_id, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 404]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 202: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_cluster_lint_results( - self, cluster_id: str, *, run_id: Optional[str] = None, **kwargs: Any - ) -> JSON: + def add_droplets( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Fetch Clusterlint Diagnostics for a Kubernetes Cluster. - - To request clusterlint diagnostics for your cluster, send a GET request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint``. If the ``run_id`` query - parameter is provided, then the diagnostics for the specific run is fetched. - By default, the latest results are shown. - - To find out how to address clusterlint feedback, please refer to - `the clusterlint check documentation - `_. - - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :keyword run_id: Specifies the clusterlint run whose results will be retrieved. Default value - is None. - :paramtype run_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "completed_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the schedule - clusterlint run request was completed. - "diagnostics": [ - { - "check_name": "str", # Optional. The clusterlint check that - resulted in the diagnostic. - "message": "str", # Optional. Feedback about the object for - users to fix. - "object": { - "kind": "str", # Optional. The kind of Kubernetes - API object. - "name": "str", # Optional. Name of the object. - "namespace": "str" # Optional. The namespace the - object resides in the cluster. - }, - "severity": "str" # Optional. Can be one of error, warning - or suggestion. - } - ], - "requested_at": "2020-02-20 00:00:00", # Optional. A time value given in - ISO8601 combined date and time format that represents when the schedule - clusterlint run request was made. - "run_id": "str" # Optional. Id of the clusterlint run that can be used later - to fetch the diagnostics. - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - 401: cast( - Type[HttpResponseError], - lambda response: ClientAuthenticationError(response=response), - ), - 429: HttpResponseError, - 500: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - _request = build_kubernetes_get_cluster_lint_results_request( - cluster_id=cluster_id, - run_id=run_id, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 404]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - if response.status_code == 200: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 404: - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore - - @overload - def add_registry( # pylint: disable=inconsistent-return-statements - self, - body: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Add Container Registry to Kubernetes Clusters. - - To integrate the container registry with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registry``. - - :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ] - } - """ - - @overload - def add_registry( # pylint: disable=inconsistent-return-statements - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Add Container Registry to Kubernetes Clusters. - - To integrate the container registry with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registry``. - - :param body: Default value is None. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def add_registry( # pylint: disable=inconsistent-return-statements - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> None: - """Add Container Registry to Kubernetes Clusters. - - To integrate the container registry with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registry``. - - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ] - } - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - 401: cast( - Type[HttpResponseError], - lambda response: ClientAuthenticationError(response=response), - ), - 429: HttpResponseError, - 500: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = body - else: - _json = None - - _request = build_kubernetes_add_registry_request( - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - def remove_registry( # pylint: disable=inconsistent-return-statements - self, - body: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Remove Container Registry from Kubernetes Clusters. - - To remove the container registry from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registry``. - - :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ] - } - """ - - @overload - def remove_registry( # pylint: disable=inconsistent-return-statements - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Remove Container Registry from Kubernetes Clusters. - - To remove the container registry from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registry``. - - :param body: Default value is None. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def remove_registry( # pylint: disable=inconsistent-return-statements - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> None: - """Remove Container Registry from Kubernetes Clusters. - - To remove the container registry from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registry``. - - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ] - } - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - 401: cast( - Type[HttpResponseError], - lambda response: ClientAuthenticationError(response=response), - ), - 429: HttpResponseError, - 500: HttpResponseError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = body - else: - _json = None - - _request = build_kubernetes_remove_registry_request( - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = ( - self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket - map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - def add_registries( # pylint: disable=inconsistent-return-statements - self, - body: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Add Container Registries to Kubernetes Clusters. - - To integrate the container registries with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registries``. - - :param body: Default value is None. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ], - "registries": [ - "str" # Optional. An array containing the registry names. - ] - } - """ - - @overload - def add_registries( # pylint: disable=inconsistent-return-statements - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> None: - """Add Container Registries to Kubernetes Clusters. - - To integrate the container registries with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registries``. - - :param body: Default value is None. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + """Add Droplets to a Load Balancer. - @distributed_trace - def add_registries( # pylint: disable=inconsistent-return-statements - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> None: - """Add Container Registries to Kubernetes Clusters. + To assign a Droplet to a load balancer instance, send a POST request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. + Individual Droplets can not be added to a load balancer configured with a + Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" + response from the API. - To integrate the container registries with Kubernetes clusters, send a POST request to - ``/v2/kubernetes/registries``. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: None - :rtype: None + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -192290,14 +200339,23 @@ def add_registries( # pylint: disable=inconsistent-return-statements # JSON input template you can fill out and use as your body input. body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ], - "registries": [ - "str" # Optional. An array containing the registry names. + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets assigned + to the load balancer. ] } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -192318,7 +200376,7 @@ def add_registries( # pylint: disable=inconsistent-return-statements content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -192326,12 +200384,10 @@ def add_registries( # pylint: disable=inconsistent-return-statements if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = body - else: - _json = None + _json = body - _request = build_kubernetes_add_registries_request( + _request = build_load_balancers_add_droplets_request( + lb_id=lb_id, content_type=content_type, json=_json, content=_content, @@ -192349,46 +200405,75 @@ def add_registries( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [204, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload - def remove_registries( # pylint: disable=inconsistent-return-statements + def remove_droplets( self, - body: Optional[JSON] = None, + lb_id: str, + body: JSON, *, content_type: str = "application/json", **kwargs: Any, - ) -> None: - """Remove Container Registries from Kubernetes Clusters. + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Remove Droplets from a Load Balancer. - To remove the container registries from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registries``. + To remove a Droplet from a load balancer instance, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - :param body: Default value is None. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -192396,52 +200481,93 @@ def remove_registries( # pylint: disable=inconsistent-return-statements # JSON input template you can fill out and use as your body input. body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ], - "registries": [ - "str" # Optional. An array containing the registry names. + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets assigned + to the load balancer. ] } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ @overload - def remove_registries( # pylint: disable=inconsistent-return-statements + def remove_droplets( self, - body: Optional[IO[bytes]] = None, + lb_id: str, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> None: - """Remove Container Registries from Kubernetes Clusters. + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Remove Droplets from a Load Balancer. - To remove the container registries from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registries``. + To remove a Droplet from a load balancer instance, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - :param body: Default value is None. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None - :rtype: None + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ @distributed_trace - def remove_registries( # pylint: disable=inconsistent-return-statements - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> None: - """Remove Container Registries from Kubernetes Clusters. + def remove_droplets( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Remove Droplets from a Load Balancer. - To remove the container registries from Kubernetes clusters, send a DELETE request to - ``/v2/kubernetes/registries``. + To remove a Droplet from a load balancer instance, send a DELETE request to + ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, + there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: None - :rtype: None + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -192449,14 +200575,23 @@ def remove_registries( # pylint: disable=inconsistent-return-statements # JSON input template you can fill out and use as your body input. body = { - "cluster_uuids": [ - "str" # Optional. An array containing the UUIDs of Kubernetes - clusters. - ], - "registries": [ - "str" # Optional. An array containing the registry names. + "droplet_ids": [ + 0 # Optional. An array containing the IDs of the Droplets assigned + to the load balancer. ] } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 404: ResourceNotFoundError, @@ -192477,7 +200612,7 @@ def remove_registries( # pylint: disable=inconsistent-return-statements content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -192485,12 +200620,10 @@ def remove_registries( # pylint: disable=inconsistent-return-statements if isinstance(body, (IOBase, bytes)): _content = body else: - if body is not None: - _json = body - else: - _json = None + _json = body - _request = build_kubernetes_remove_registries_request( + _request = build_load_balancers_remove_droplets_request( + lb_id=lb_id, content_type=content_type, json=_json, content=_content, @@ -192508,64 +200641,235 @@ def remove_registries( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [204, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - @distributed_trace - def get_status_messages( + return deserialized # type: ignore + + @overload + def add_forwarding_rules( self, - cluster_id: str, + lb_id: str, + body: JSON, *, - since: Optional[datetime.datetime] = None, + content_type: str = "application/json", **kwargs: Any, - ) -> JSON: + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Fetch Status Messages for a Kubernetes Cluster. + """Add Forwarding Rules to a Load Balancer. - To retrieve status messages for a Kubernetes cluster, send a GET request to - ``/v2/kubernetes/clusters/$K8S_CLUSTER_ID/status_messages``. Status messages inform users of - any issues that come up during the cluster lifecycle. + To add an additional forwarding rule to a load balancer instance, send a POST + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body + of the request, there should be a ``forwarding_rules`` attribute containing an + array of rules to be added. - :param cluster_id: A unique ID that can be used to reference a Kubernetes cluster. Required. - :type cluster_id: str - :keyword since: A timestamp used to return status messages emitted since the specified time. - The timestamp should be in ISO8601 format. Default value is None. - :paramtype since: ~datetime.datetime - :return: JSON object - :rtype: JSON + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 + # JSON input template you can fill out and use as your body input. + body = { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port on which + the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for traffic to + the load balancer. The possible values are: ``http``"" , ``https``"" , + ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the + ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to + ``udp``. When using UDP, the load balancer requires that you set up a + health check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing the port on the + backend Droplets to which the load balancer will send traffic. Required. + "target_protocol": "str", # The protocol used for traffic + from the load balancer to the backend Droplets. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you + set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be + set to ``udp``. When using UDP, the load balancer requires that you set + up a health check with a port that uses TCP, HTTP, or HTTPS to work + properly. Required. Known values are: "http", "https", "http2", "tcp", + and "udp". + "certificate_id": "str", # Optional. The ID of the TLS + certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to the + backend Droplets. + } + ] + } + + # response body for status code(s): 404 response == { - "messages": [ + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def add_forwarding_rules( + self, + lb_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Add Forwarding Rules to a Load Balancer. + + To add an additional forwarding rule to a load balancer instance, send a POST + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body + of the request, there should be a ``forwarding_rules`` attribute containing an + array of rules to be added. + + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def add_forwarding_rules( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Add Forwarding Rules to a Load Balancer. + + To add an additional forwarding rule to a load balancer instance, send a POST + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body + of the request, there should be a ``forwarding_rules`` attribute containing an + array of rules to be added. + + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "forwarding_rules": [ { - "message": "str", # Optional. Status information about the - cluster which impacts it's lifecycle. - "timestamp": "2020-02-20 00:00:00" # Optional. A timestamp - in ISO8601 format that represents when the status message was emitted. + "entry_port": 0, # An integer representing the port on which + the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for traffic to + the load balancer. The possible values are: ``http``"" , ``https``"" , + ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the + ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to + ``udp``. When using UDP, the load balancer requires that you set up a + health check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing the port on the + backend Droplets to which the load balancer will send traffic. Required. + "target_protocol": "str", # The protocol used for traffic + from the load balancer to the backend Droplets. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you + set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be + set to ``udp``. When using UDP, the load balancer requires that you set + up a health check with a port that uses TCP, HTTP, or HTTPS to work + properly. Required. Known values are: "http", "https", "http2", "tcp", + and "udp". + "certificate_id": "str", # Optional. The ID of the TLS + certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to the + backend Droplets. } ] } + # response body for status code(s): 404 response == { "id": "str", # A short identifier corresponding to the HTTP status code @@ -192591,14 +200895,27 @@ def get_status_messages( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_kubernetes_get_status_messages_request( - cluster_id=cluster_id, - since=since, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_load_balancers_add_forwarding_rules_request( + lb_id=lb_id, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -192613,14 +200930,15 @@ def get_status_messages( response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [204, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - if response.status_code == 200: + if response.status_code == 204: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -192631,11 +200949,6 @@ def get_status_messages( "int", response.headers.get("ratelimit-reset") ) - if response.content: - deserialized = response.json() - else: - deserialized = None - if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -192653,781 +200966,209 @@ def get_status_messages( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - - return cast(JSON, deserialized) # type: ignore - - -class LoadBalancersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~pydo.GeneratedClient`'s - :attr:`load_balancers` attribute. - """ + return cls(pipeline_response, deserialized, response_headers) # type: ignore - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = ( - input_args.pop(0) if input_args else kwargs.pop("deserializer") - ) + return deserialized # type: ignore @overload - def create( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> JSON: + def remove_forwarding_rules( + self, + lb_id: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Create a New Load Balancer. - - To create a new load balancer instance, send a POST request to - ``/v2/load_balancers``. - - You can specify the Droplets that will sit behind the load balancer using one - of two methods: - + """Remove Forwarding Rules from a Load Balancer. - * Set ``droplet_ids`` to a list of specific Droplet IDs. - * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be - assigned to the load balancer. Additional Droplets will be automatically - assigned as they are tagged. + To remove forwarding rules from a load balancer instance, send a DELETE + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the + body of the request, there should be a ``forwarding_rules`` attribute containing + an array of rules to be removed. - These methods are mutually exclusive. + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python # JSON input template you can fill out and use as your body input. - body = {} - - # response body for status code(s): 202 - response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } - } - """ - - @overload - def create( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Create a New Load Balancer. - - To create a new load balancer instance, send a POST request to - ``/v2/load_balancers``. - - You can specify the Droplets that will sit behind the load balancer using one - of two methods: - - - * Set ``droplet_ids`` to a list of specific Droplet IDs. - * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be - assigned to the load balancer. Additional Droplets will be automatically - assigned as they are tagged. - - These methods are mutually exclusive. - - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } + body = { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port on which + the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for traffic to + the load balancer. The possible values are: ``http``"" , ``https``"" , + ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the + ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to + ``udp``. When using UDP, the load balancer requires that you set up a + health check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing the port on the + backend Droplets to which the load balancer will send traffic. Required. + "target_protocol": "str", # The protocol used for traffic + from the load balancer to the backend Droplets. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you + set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be + set to ``udp``. When using UDP, the load balancer requires that you set + up a health check with a port that uses TCP, HTTP, or HTTPS to work + properly. Required. Known values are: "http", "https", "http2", "tcp", + and "udp". + "certificate_id": "str", # Optional. The ID of the TLS + certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to the + backend Droplets. + } + ] + } + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. } """ - @distributed_trace - def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + @overload + def remove_forwarding_rules( + self, + lb_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> Optional[JSON]: # pylint: disable=line-too-long - """Create a New Load Balancer. + """Remove Forwarding Rules from a Load Balancer. - To create a new load balancer instance, send a POST request to - ``/v2/load_balancers``. + To remove forwarding rules from a load balancer instance, send a DELETE + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the + body of the request, there should be a ``forwarding_rules`` attribute containing + an array of rules to be removed. - You can specify the Droplets that will sit behind the load balancer using one - of two methods: + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: - * Set ``droplet_ids`` to a list of specific Droplet IDs. - * Set ``tag`` to the name of a tag. All Droplets with this tag applied will be - assigned to the load balancer. Additional Droplets will be automatically - assigned as they are tagged. + Example: + .. code-block:: python - These methods are mutually exclusive. + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def remove_forwarding_rules( + self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> Optional[JSON]: + # pylint: disable=line-too-long + """Remove Forwarding Rules from a Load Balancer. + + To remove forwarding rules from a load balancer instance, send a DELETE + request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the + body of the request, there should be a ``forwarding_rules`` attribute containing + an array of rules to be removed. + + No response body will be sent back, but the response code will indicate + success. Specifically, the response code will be a 204, which means that the + action was successful with no returned body data. + :param lb_id: A unique identifier for a load balancer. Required. + :type lb_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON + :return: JSON object or None + :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python # JSON input template you can fill out and use as your body input. - body = {} + body = { + "forwarding_rules": [ + { + "entry_port": 0, # An integer representing the port on which + the load balancer instance will listen. Required. + "entry_protocol": "str", # The protocol used for traffic to + the load balancer. The possible values are: ``http``"" , ``https``"" , + ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the + ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to + ``udp``. When using UDP, the load balancer requires that you set up a + health check with a port that uses TCP, HTTP, or HTTPS to work properly. + Required. Known values are: "http", "https", "http2", "http3", "tcp", and + "udp". + "target_port": 0, # An integer representing the port on the + backend Droplets to which the load balancer will send traffic. Required. + "target_protocol": "str", # The protocol used for traffic + from the load balancer to the backend Droplets. The possible values are: + ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you + set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be + set to ``udp``. When using UDP, the load balancer requires that you set + up a health check with a port that uses TCP, HTTP, or HTTPS to work + properly. Required. Known values are: "http", "https", "http2", "tcp", + and "udp". + "certificate_id": "str", # Optional. The ID of the TLS + certificate used for SSL termination if enabled. + "tls_passthrough": bool # Optional. A boolean value + indicating whether SSL encrypted traffic will be passed through to the + backend Droplets. + } + ] + } - # response body for status code(s): 202 + # response body for status code(s): 404 response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -193449,7 +201190,7 @@ def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -193459,7 +201200,8 @@ def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: else: _json = body - _request = build_load_balancers_create_request( + _request = build_load_balancers_remove_forwarding_rules_request( + lb_id=lb_id, content_type=content_type, json=_json, content=_content, @@ -193477,45 +201219,95 @@ def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [204, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) + deserialized = None response_headers = {} - response_headers["ratelimit-limit"] = self._deserialize( - "int", response.headers.get("ratelimit-limit") - ) - response_headers["ratelimit-remaining"] = self._deserialize( - "int", response.headers.get("ratelimit-remaining") - ) - response_headers["ratelimit-reset"] = self._deserialize( - "int", response.headers.get("ratelimit-reset") - ) + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) # type: ignore + return deserialized # type: ignore + + +class MicrovmsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`microvms` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) @distributed_trace - def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: + def list( + self, + *, + page: int = 1, + per_page: int = 25, + region: Optional[str] = None, + name: Optional[str] = None, + tag_name: Optional[str] = None, + **kwargs: Any, + ) -> JSON: # pylint: disable=line-too-long - """List All Load Balancers. + """List all MicroVMs. - To list all of the load balancer instances on your account, send a GET request - to ``/v2/load_balancers``. + To list all of the MicroVMs on your team, send a GET request to ``/v2/microvms``. + + The ``region``\\ , ``name``\\ , and ``tag_name`` filters combine with AND. - :keyword per_page: Number of items returned per page. Default value is 20. - :paramtype per_page: int :keyword page: Which 'page' of paginated results to return. Default value is 1. :paramtype page: int + :keyword per_page: Number of items returned per page. Default value is 25. + :paramtype per_page: int + :keyword region: Only return MicroVMs in this region. Default value is None. + :paramtype region: str + :keyword name: Only return the MicroVM with this exact name. Default value is None. + :paramtype name: str + :keyword tag_name: Only return MicroVMs with this tag. A tag that matches no MicroVMs returns + an empty list. Default value is None. + :paramtype tag_name: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -193531,231 +201323,83 @@ def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: "links": { "pages": {} }, - "load_balancers": [ + "microvms": [ { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing - the port on which the load balancer instance will listen. - Required. - "entry_protocol": "str", # The protocol used - for traffic to the load balancer. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" - , or ``udp``. If you set the ``entry_protocol`` to ``udp``"" , - the ``target_protocol`` must be set to ``udp``. When using UDP, - the load balancer requires that you set up a health check with a - port that uses TCP, HTTP, or HTTPS to work properly. Required. - Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing - the port on the backend Droplets to which the load balancer will - send traffic. Required. - "target_protocol": "str", # The protocol - used for traffic from the load balancer to the backend Droplets. - The possible values are: ``http``"" , ``https``"" , ``http2``"" , - ``tcp``"" , or ``udp``. If you set the ``target_protocol`` to - ``udp``"" , the ``entry_protocol`` must be set to ``udp``. When - using UDP, the load balancer requires that you set up a health - check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "tcp", and - "udp". - "certificate_id": "str", # Optional. The ID - of the TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A - boolean value indicating whether SSL encrypted traffic will be - passed through to the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify - an algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time - value given in ISO8601 combined date and time format that represents when - the load balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. - Default value is False. A boolean value indicating whether to disable - automatic DNS record creation for Let's Encrypt certificates that are - added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID - of the TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean - value indicating if the domain is already managed by - DigitalOcean. If true, all A and AAAA records required to enable - Global load balancers will be automatically added. - "name": "str" # Optional. FQDN to associate - with a Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the - Droplets assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value - is False. A boolean value indicating whether HTTP keepalive connections - are maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is - False. A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing - traffic to the load balancer (in the form 'ip:1.2.3.4' or - 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying - traffic to the load balancer (in the form 'ip:1.2.3.4' or - 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean - flag to enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer - value as a percentage to indicate failure threshold to decide how the - regional priorities will take effect. A value of ``50`` would - indicate that the Global load balancer will choose a lower priority - region to forward traffic to once this failure threshold has been - reached for the higher priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string - to an integer priority value indicating preference for which - regional target a Global load balancer will forward traffic to. A - lower value indicates a higher priority. - }, - "target_port": 0, # Optional. An integer - representing the port on the target backends which the load balancer - will forward traffic to. - "target_protocol": "str" # Optional. The protocol - used for forwarding traffic from the load balancer to the target - backends. The possible values are ``http``"" , ``https`` and - ``http2``. Known values are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default - value is 10. The number of seconds between between two consecutive - health checks. - "healthy_threshold": 3, # Optional. Default value is - 3. The number of times a health check must pass for a backend Droplet - to be marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The - path on the backend Droplets to which the load balancer instance will - send a request. - "port": 80, # Optional. Default value is 80. An - integer representing the port on the backend Droplets on which the - health check will attempt a connection. - "protocol": "http", # Optional. Default value is - "http". The protocol used for health checks sent to the backend - Droplets. The possible values are ``http``"" , ``https``"" , or - ``tcp``. Known values are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default - value is 5. The number of seconds the load balancer instance will - wait for a response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value - is 5. The number of times a health check must fail for a backend - Droplet to be marked "unhealthy" and be removed from the pool. + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is + on. Always ``true``. + "idle_timeout": "str" # Optional. How long the + MicroVM is idle before it pauses, as a duration such as ``30s``"" , + ``5m``"" , or ``1h``. Defaults to ``5m``. The maximum is ``4h``. + Responses show the duration in the form ``5m0s``. }, - "http_idle_timeout_seconds": 60, # Optional. Default value - is 60. An integer value which configures the idle timeout for HTTP - requests to the target droplets. - "id": "str", # Optional. A unique ID that can be used to - identify and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the - public-facing IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load - balancer instance. - "network": "EXTERNAL", # Optional. Default value is - "EXTERNAL". A string indicating whether the load balancer should be - external or internal. Internal load balancers have no public IPs and are - only accessible to resources on the same VPC network. This property - cannot be updated after creating the load balancer. Known values are: - "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is - "IPV4". A string indicating whether the load balancer will support IPv4 - or both IPv4 and IPv6 networking. This property cannot be updated after - creating the load balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that - the load balancer is associated with. If no ID is provided at creation, - the load balancer associates with the user's default project. If an - invalid project ID is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value - is False. A boolean value indicating whether HTTP requests to the load - balancer on port 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that - represents whether new Droplets can be created in this region. + "auto_resume": True, # Optional. Default value is True. + Whether an HTTP request, command, or console session resumes the MicroVM + when it is paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the + MicroVM was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. + Present only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the + MicroVM's HTTP port serves. ``null`` if the protocol was not set when the + MicroVM was created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be + unique in the region and contain 1 to 63 lowercase letters, digits, and + hyphens. + "networking": "public", # Optional. Default value is + "public". ``public`` sends outbound traffic through a shared NAT gateway. + ``vpc`` places the MicroVM in the VPC network set by ``vpc_uuid``. Known + values are: "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the + MicroVM, including the HTTP port. During the public preview, only the + HTTP port is reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the + MicroVM is in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. - "features": [ - "str" # This attribute is set to an array - which contains features available in this region. Required. - ], - "name": "str", # The display name of the region. - This will be a full name that is used in the control panel and other - interfaces. Required. - "sizes": [ - "str" # This attribute is set to an array - which contains the identifying slugs for the sizes available in - this region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used - as a unique identifier for each region. Required. + "disk": 0 # Optional. The size of the disk, in GB. + Set by the size. }, - "size": "lb-small", # Optional. Default value is "lb-small". - This field has been replaced by the ``size_unit`` field for all regions - except in AMS2, NYC2, and SFO1. Each available load balancer size now - equates to the load balancer having a set number of nodes. * - ``lb-small`` = 1 node * ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes - You can resize load balancers after creation up to once per hour. You - cannot resize a load balancer within the first hour of its creation. - Known values are: "lb-small", "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many - nodes the load balancer contains. Each additional node increases the load - balancer's ability to manage more connections. Load balancers can be - scaled up or down, and you can change the number of nodes after creation - up to once per hour. This field is currently not available in the AMS2, - NYC2, or SFO1 regions. Use the ``size`` field to scale load balancers - that reside in these regions. - "status": "str", # Optional. A status string indicating the - current state of the load balancer. This can be ``new``"" , ``active``"" - , or ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the - cookie sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of - seconds until the cookie set by the load balancer expires. This - attribute is only returned when using ``cookies`` for the sticky - sessions type. - "type": "none" # Optional. Default value is "none". - An attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values - are ``cookies`` or ``none``. Known values are: "cookies" and "none". + "source": { + "checkpoint_id": "str", # Optional. The ID of a + checkpoint to create the MicroVM from. The new MicroVM inherits the + checkpoint's region, size, container image, and environment + variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form + ``registry/repository:tag``. The image can be public, such as an + image on Docker Hub, or private in your team's DigitalOcean Container + Registry. }, - "subnet_uuid": "str", # Optional. A string specifying the - UUID of the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag - corresponding to Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of - the Regional load balancers to be used as target backends for a - Global load balancer. + "state": "str", # Optional. The MicroVM's current state. + Known values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used - by the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. - The default value is ``DEFAULT``. Known values are: "DEFAULT" and - "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". - A string indicating whether the load balancer should be a standard - regional HTTP load balancer, a regional network load balancer that routes - traffic at the TCP/UDP transport layer, or a global load balancer. Known - values are: "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID - of the VPC to which the load balancer is assigned. + "urls": [ + { + "default": bool, # Optional. Whether this is + the endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The + endpoint's hostname. Empty until provisioning finishes. Requests + to the endpoint must include a DigitalOcean API token with the + ``microvm:access`` scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the + endpoint serves. + "status": "str" # Optional. ``PENDING`` + until provisioning finishes, then ``ACTIVE``. Known values are: + "PENDING" and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the + same region that belongs to your team. Present only when ``networking`` + is ``vpc``. } ] } @@ -193778,9 +201422,12 @@ def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_load_balancers_list_request( - per_page=per_page, + _request = build_microvms_list_request( page=page, + per_page=per_page, + region=region, + name=name, + tag_name=tag_name, headers=_headers, params=_params, ) @@ -193822,16 +201469,30 @@ def list(self, *, per_page: int = 20, page: int = 1, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore - @distributed_trace - def get(self, lb_id: str, **kwargs: Any) -> JSON: + @overload + def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: # pylint: disable=line-too-long - """Retrieve an Existing Load Balancer. + """Create a MicroVM. - To show information about a load balancer instance, send a GET request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. + To create a MicroVM, send a POST request to ``/v2/microvms``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + ``name`` and ``source`` are required. Set ``source.oci_ref`` to create the MicroVM from a + ``linux/amd64`` container image, or ``source.checkpoint_id`` to create it from a checkpoint. + With ``oci_ref``\\ , ``region`` and ``size`` are also required. + + A MicroVM created from an image is returned with ``state`` set to ``creating``. Poll + ``GET /v2/microvms/{microvm_id}`` until ``state`` is ``running``. A MicroVM created from a + checkpoint is usually returned already ``running``. + + All settings are fixed at creation. There is no update endpoint. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -193839,232 +201500,421 @@ def get(self, lb_id: str, **kwargs: Any) -> JSON: Example: .. code-block:: python - # response body for status code(s): 200 + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # The name of the MicroVM. Must be unique in the region and + contain 1 to 63 lowercase letters, digits, and hyphens. Required. + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint to create + the MicroVM from. The new MicroVM inherits the checkpoint's region, size, + container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a ``linux/amd64`` + container image in the form ``registry/repository:tag``. The image can be + public, such as an image on Docker Hub, or private in your team's + DigitalOcean Container Registry. + }, + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. Always + ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is idle + before it pauses, as a duration such as ``30s``"" , ``5m``"" , or ``1h``. + Defaults to ``5m``. The maximum is ``4h``. Responses show the duration in the + form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an HTTP + request, command, or console session resumes the MicroVM when it is paused. Set + to ``false`` to require a manual resume. + "environment": { + "str": "str" # Optional. Environment variables passed into the + MicroVM at boot, as key and value pairs. Not returned in responses. + }, + "http_port": 8080, # Optional. Default value is 8080. The guest port the + workload serves HTTP on. Defaults to ``8080``. Not returned in responses. When + creating from a checkpoint without ``ports``"" , must be one of the checkpoint's + ports. + "http_protocol": "str", # Optional. The protocol the HTTP port serves. Known + values are: "http" and "http2". + "networking": "public", # Optional. Default value is "public". ``public`` + sends outbound traffic through a shared NAT gateway. ``vpc`` places the MicroVM + in the VPC network set by ``vpc_uuid``. Known values are: "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports to declare, up to five. Must include + ``http_port``. Defaults to only the HTTP port. During the public preview, + only the HTTP port is reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region to create the MicroVM + in. Required with ``source.oci_ref``. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by the size. + }, + "tags": [ + "str" # Optional. Tags to apply to the MicroVM. + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same region + that belongs to your team. Required when ``networking`` is ``vpc``. + } + + # response body for status code(s): 201 response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. + }, + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. + ], + "urls": [ { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". } ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. + } + } + # response body for status code(s): 400, 403 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. + } + """ + + @overload + def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a MicroVM. + + To create a MicroVM, send a POST request to ``/v2/microvms``. + + ``name`` and ``source`` are required. Set ``source.oci_ref`` to create the MicroVM from a + ``linux/amd64`` container image, or ``source.checkpoint_id`` to create it from a checkpoint. + With ``oci_ref``\\ , ``region`` and ``size`` are also required. + + A MicroVM created from an image is returned with ``state`` set to ``creating``. Poll + ``GET /v2/microvms/{microvm_id}`` until ``state`` is ``running``. A MicroVM created from a + checkpoint is usually returned already ``running``. + + All settings are fixed at creation. There is no update endpoint. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. + ], + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. + } + } + # response body for status code(s): 400, 403 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. + } + """ + + @distributed_trace + def create(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Create a MicroVM. + + To create a MicroVM, send a POST request to ``/v2/microvms``. + + ``name`` and ``source`` are required. Set ``source.oci_ref`` to create the MicroVM from a + ``linux/amd64`` container image, or ``source.checkpoint_id`` to create it from a checkpoint. + With ``oci_ref``\\ , ``region`` and ``size`` are also required. + + A MicroVM created from an image is returned with ``state`` set to ``creating``. Poll + ``GET /v2/microvms/{microvm_id}`` until ``state`` is ``running``. A MicroVM created from a + checkpoint is usually returned already ``running``. + + All settings are fixed at creation. There is no update endpoint. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # The name of the MicroVM. Must be unique in the region and + contain 1 to 63 lowercase letters, digits, and hyphens. Required. + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint to create + the MicroVM from. The new MicroVM inherits the checkpoint's region, size, + container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a ``linux/amd64`` + container image in the form ``registry/repository:tag``. The image can be + public, such as an image on Docker Hub, or private in your team's + DigitalOcean Container Registry. + }, + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. Always + ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is idle + before it pauses, as a duration such as ``30s``"" , ``5m``"" , or ``1h``. + Defaults to ``5m``. The maximum is ``4h``. Responses show the duration in the + form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an HTTP + request, command, or console session resumes the MicroVM when it is paused. Set + to ``false`` to require a manual resume. + "environment": { + "str": "str" # Optional. Environment variables passed into the + MicroVM at boot, as key and value pairs. Not returned in responses. + }, + "http_port": 8080, # Optional. Default value is 8080. The guest port the + workload serves HTTP on. Defaults to ``8080``. Not returned in responses. When + creating from a checkpoint without ``ports``"" , must be one of the checkpoint's + ports. + "http_protocol": "str", # Optional. The protocol the HTTP port serves. Known + values are: "http" and "http2". + "networking": "public", # Optional. Default value is "public". ``public`` + sends outbound traffic through a shared NAT gateway. ``vpc`` places the MicroVM + in the VPC network set by ``vpc_uuid``. Known values are: "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports to declare, up to five. Must include + ``http_port``. Defaults to only the HTTP port. During the public preview, + only the HTTP port is reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region to create the MicroVM + in. Required with ``source.oci_ref``. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by the size. + }, + "tags": [ + "str" # Optional. Tags to apply to the MicroVM. + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same region + that belongs to your team. Required when ``networking`` is ``vpc``. + } + + # response body for status code(s): 201 + response == { + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. } } - # response body for status code(s): 404 + # response body for status code(s): 400, 403 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -194080,13 +201930,26 @@ def get(self, lb_id: str, **kwargs: Any) -> JSON: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_load_balancers_get_request( - lb_id=lb_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_microvms_create_request( + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -194101,14 +201964,14 @@ def get(self, lb_id: str, **kwargs: Any) -> JSON: response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [201, 400, 403]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: + if response.status_code == 201: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -194124,7 +201987,23 @@ def get(self, lb_id: str, **kwargs: Any) -> JSON: else: deserialized = None - if response.status_code == 404: + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 403: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -194145,32 +202024,13 @@ def get(self, lb_id: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) # type: ignore - @overload - def update( - self, - lb_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> JSON: - # pylint: disable=line-too-long - """Update a Load Balancer. + @distributed_trace + def get_options(self, **kwargs: Any) -> JSON: + """List MicroVM options. - To update a load balancer's settings, send a PUT request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full - representation of the load balancer including existing attributes. It may - contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually - exclusive. **Note that any attribute that is not provided will be reset to its - default value.**. + To list the default region, sizes, prices, account limits, and features available to + your team, send a GET request to ``/v2/microvms/options``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -194178,516 +202038,130 @@ def update( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = {} - # response body for status code(s): 200 response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. + "account_limits": { + "max_disk_bytes": 0, # Optional. The maximum disk per MicroVM, in + bytes. + "max_idle_timeout_seconds": 0, # Optional. The maximum auto-pause + idle timeout, in seconds. + "max_memory_bytes": 0, # Optional. The maximum memory per MicroVM, + in bytes. + "max_total_count": 0 # Optional. The maximum number of MicroVMs, + counting both running and paused MicroVMs. + }, + "default_region": "str", # Optional. The slug of the region MicroVMs are + created in by default. + "features": [ + { + "enabled": bool, # Optional. Whether the feature is enabled. + "name": "str" # Optional. The name of the feature. + } + ], + "resource_pricing": { + "price_per_gib_bandwidth": 0.0, # Optional. The price per GiB of + outbound data transfer. + "price_per_gib_memory_hour": 0.0, # Optional. The price per GiB of + memory per hour of running time. + "price_per_gib_storage_month": 0.0, # Optional. The price per + GiB-month of disk and checkpoint storage. + "price_per_vcpu_hour": 0.0 # Optional. The price per vCPU per hour + of running time. + }, + "sizes": [ + { + "available": bool, # Optional. Whether the size is available + on your team's plan. + "cpu": 0, # Optional. The number of vCPUs. + "disk": 0, # Optional. The size of the disk, in GB. + "memory": 0, # Optional. The amount of memory, in MiB. + "pricing": { + "price_per_hour": 0.0, # Optional. The price per + hour of running time, in USD. + "price_per_month": 0.0 # Optional. The price for + running continuously for a month (730 hours), in USD. }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "regions": [ + "str" # Optional. The slugs of the regions the size + is available in. + ] + } + ] } """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def update( - self, - lb_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> JSON: - # pylint: disable=line-too-long - """Update a Load Balancer. + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - To update a load balancer's settings, send a PUT request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full - representation of the load balancer including existing attributes. It may - contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually - exclusive. **Note that any attribute that is not provided will be reset to its - default value.**. + cls: ClsType[JSON] = kwargs.pop("cls", None) - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: + _request = build_microvms_get_options_request( + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - Example: - .. code-block:: python + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) - # response body for status code(s): 200 - response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. - }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. - }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". - }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. - ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore @distributed_trace - def update(self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + def get(self, microvm_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Update a Load Balancer. + """Retrieve a MicroVM. - To update a load balancer's settings, send a PUT request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. The request should contain a full - representation of the load balancer including existing attributes. It may - contain *one of* the ``droplets_ids`` or ``tag`` attributes as they are mutually - exclusive. **Note that any attribute that is not provided will be reset to its - default value.**. + To show information about a MicroVM, send a GET request to ``/v2/microvms/{microvm_id}``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] + The endpoint is in the ``urls`` entry with ``default`` set to ``true``. Its ``hostname`` is + empty + and its ``status`` is ``PENDING`` until provisioning finishes. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -194695,235 +202169,86 @@ def update(self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSO Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = {} - # response body for status code(s): 200 response == { - "load_balancer": { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port - on which the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for - traffic to the load balancer. The possible values are: ``http``"" , - ``https``"" , ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If - you set the ``entry_protocol`` to ``udp``"" , the - ``target_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "http3", "tcp", and "udp". - "target_port": 0, # An integer representing the port - on the backend Droplets to which the load balancer will send traffic. - Required. - "target_protocol": "str", # The protocol used for - traffic from the load balancer to the backend Droplets. The possible - values are: ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or - ``udp``. If you set the ``target_protocol`` to ``udp``"" , the - ``entry_protocol`` must be set to ``udp``. When using UDP, the load - balancer requires that you set up a health check with a port that - uses TCP, HTTP, or HTTPS to work properly. Required. Known values - are: "http", "https", "http2", "tcp", and "udp". - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to - the backend Droplets. - } - ], - "algorithm": "round_robin", # Optional. Default value is - "round_robin". This field has been deprecated. You can no longer specify an - algorithm for load balancers. Known values are: "round_robin" and - "least_connections". - "created_at": "2020-02-20 00:00:00", # Optional. A time value given - in ISO8601 combined date and time format that represents when the load - balancer was created. - "disable_lets_encrypt_dns_records": False, # Optional. Default value - is False. A boolean value indicating whether to disable automatic DNS record - creation for Let's Encrypt certificates that are added to the load balancer. - "domains": [ - { - "certificate_id": "str", # Optional. The ID of the - TLS certificate used for SSL termination. - "is_managed": bool, # Optional. A boolean value - indicating if the domain is already managed by DigitalOcean. If true, - all A and AAAA records required to enable Global load balancers will - be automatically added. - "name": "str" # Optional. FQDN to associate with a - Global load balancer. - } - ], - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets - assigned to the load balancer. - ], - "enable_backend_keepalive": False, # Optional. Default value is - False. A boolean value indicating whether HTTP keepalive connections are - maintained to target Droplets. - "enable_proxy_protocol": False, # Optional. Default value is False. - A boolean value indicating whether PROXY Protocol is in use. - "firewall": { - "allow": [ - "str" # Optional. the rules for allowing traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ], - "deny": [ - "str" # Optional. the rules for denying traffic to - the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16'). - ] - }, - "glb_settings": { - "cdn": { - "is_enabled": bool # Optional. A boolean flag to - enable CDN caching. - }, - "failover_threshold": 0, # Optional. An integer value as a - percentage to indicate failure threshold to decide how the regional - priorities will take effect. A value of ``50`` would indicate that the - Global load balancer will choose a lower priority region to forward - traffic to once this failure threshold has been reached for the higher - priority region. - "region_priorities": { - "str": 0 # Optional. A map of region string to an - integer priority value indicating preference for which regional - target a Global load balancer will forward traffic to. A lower value - indicates a higher priority. - }, - "target_port": 0, # Optional. An integer representing the - port on the target backends which the load balancer will forward traffic - to. - "target_protocol": "str" # Optional. The protocol used for - forwarding traffic from the load balancer to the target backends. The - possible values are ``http``"" , ``https`` and ``http2``. Known values - are: "http", "https", and "http2". - }, - "health_check": { - "check_interval_seconds": 10, # Optional. Default value is - 10. The number of seconds between between two consecutive health checks. - "healthy_threshold": 3, # Optional. Default value is 3. The - number of times a health check must pass for a backend Droplet to be - marked "healthy" and be re-added to the pool. - "path": "/", # Optional. Default value is "/". The path on - the backend Droplets to which the load balancer instance will send a - request. - "port": 80, # Optional. Default value is 80. An integer - representing the port on the backend Droplets on which the health check - will attempt a connection. - "protocol": "http", # Optional. Default value is "http". The - protocol used for health checks sent to the backend Droplets. The - possible values are ``http``"" , ``https``"" , or ``tcp``. Known values - are: "http", "https", and "tcp". - "response_timeout_seconds": 5, # Optional. Default value is - 5. The number of seconds the load balancer instance will wait for a - response until marking a health check as failed. - "unhealthy_threshold": 5 # Optional. Default value is 5. The - number of times a health check must fail for a backend Droplet to be - marked "unhealthy" and be removed from the pool. + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. }, - "http_idle_timeout_seconds": 60, # Optional. Default value is 60. An - integer value which configures the idle timeout for HTTP requests to the - target droplets. - "id": "str", # Optional. A unique ID that can be used to identify - and reference a load balancer. - "ipv6": "str", # Optional. An attribute containing the public-facing - IPv6 address of the load balancer. - "name": "str", # Optional. A human-readable name for a load balancer - instance. - "network": "EXTERNAL", # Optional. Default value is "EXTERNAL". A - string indicating whether the load balancer should be external or internal. - Internal load balancers have no public IPs and are only accessible to - resources on the same VPC network. This property cannot be updated after - creating the load balancer. Known values are: "EXTERNAL" and "INTERNAL". - "network_stack": "IPV4", # Optional. Default value is "IPV4". A - string indicating whether the load balancer will support IPv4 or both IPv4 - and IPv6 networking. This property cannot be updated after creating the load - balancer. Known values are: "IPV4" and "DUALSTACK". - "project_id": "str", # Optional. The ID of the project that the load - balancer is associated with. If no ID is provided at creation, the load - balancer associates with the user's default project. If an invalid project ID - is provided, the load balancer will not be created. - "redirect_http_to_https": False, # Optional. Default value is False. - A boolean value indicating whether HTTP requests to the load balancer on port - 80 will be redirected to HTTPS on port 443. - "region": { - "available": bool, # This is a boolean value that represents - whether new Droplets can be created in this region. Required. - "features": [ - "str" # This attribute is set to an array which - contains features available in this region. Required. - ], - "name": "str", # The display name of the region. This will - be a full name that is used in the control panel and other interfaces. - Required. - "sizes": [ - "str" # This attribute is set to an array which - contains the identifying slugs for the sizes available in this - region. sizes:read is required to view. Required. - ], - "slug": "str" # A human-readable string that is used as a - unique identifier for each region. Required. + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. }, - "size": "lb-small", # Optional. Default value is "lb-small". This - field has been replaced by the ``size_unit`` field for all regions except in - AMS2, NYC2, and SFO1. Each available load balancer size now equates to the - load balancer having a set number of nodes. * ``lb-small`` = 1 node * - ``lb-medium`` = 3 nodes * ``lb-large`` = 6 nodes You can resize load - balancers after creation up to once per hour. You cannot resize a load - balancer within the first hour of its creation. Known values are: "lb-small", - "lb-medium", and "lb-large". - "size_unit": 1, # Optional. Default value is 1. How many nodes the - load balancer contains. Each additional node increases the load balancer's - ability to manage more connections. Load balancers can be scaled up or down, - and you can change the number of nodes after creation up to once per hour. - This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use - the ``size`` field to scale load balancers that reside in these regions. - "status": "str", # Optional. A status string indicating the current - state of the load balancer. This can be ``new``"" , ``active``"" , or - ``errored``. Known values are: "new", "active", and "errored". - "sticky_sessions": { - "cookie_name": "str", # Optional. The name of the cookie - sent to the client. This attribute is only returned when using - ``cookies`` for the sticky sessions type. - "cookie_ttl_seconds": 0, # Optional. The number of seconds - until the cookie set by the load balancer expires. This attribute is only - returned when using ``cookies`` for the sticky sessions type. - "type": "none" # Optional. Default value is "none". An - attribute indicating how and if requests from a client will be - persistently served by the same backend Droplet. The possible values are - ``cookies`` or ``none``. Known values are: "cookies" and "none". + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. }, - "subnet_uuid": "str", # Optional. A string specifying the UUID of - the VPC subnet to which the load balancer is assigned. - "tag": "str", # Optional. The name of a Droplet tag corresponding to - Droplets assigned to the load balancer. - "target_load_balancer_ids": [ - "str" # Optional. An array containing the UUIDs of the - Regional load balancers to be used as target backends for a Global load - balancer. + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. ], - "tls_cipher_policy": "DEFAULT", # Optional. Default value is - "DEFAULT". A string indicating the policy for the TLS cipher suites used by - the load balancer. The possible values are ``DEFAULT`` or ``STRONG``. The - default value is ``DEFAULT``. Known values are: "DEFAULT" and "STRONG". - "type": "REGIONAL", # Optional. Default value is "REGIONAL". A - string indicating whether the load balancer should be a standard regional - HTTP load balancer, a regional network load balancer that routes traffic at - the TCP/UDP transport layer, or a global load balancer. Known values are: - "REGIONAL", "REGIONAL_NETWORK", and "GLOBAL". - "vpc_uuid": "str" # Optional. A string specifying the UUID of the - VPC to which the load balancer is assigned. + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. } } # response body for status code(s): 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -194939,27 +202264,13 @@ def update(self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSO } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) cls: ClsType[JSON] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_load_balancers_update_request( - lb_id=lb_id, - content_type=content_type, - json=_json, - content=_content, + _request = build_microvms_get_request( + microvm_id=microvm_id, headers=_headers, params=_params, ) @@ -195019,19 +202330,16 @@ def update(self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSO return cast(JSON, deserialized) # type: ignore @distributed_trace - def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: - # pylint: disable=line-too-long - """Delete a Load Balancer. + def delete(self, microvm_id: str, **kwargs: Any) -> Optional[JSON]: + """Delete a MicroVM. - To delete a load balancer instance, disassociating any Droplets assigned to it - and removing it from your account, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID``. + To delete a MicroVM and the data on its disk, send a DELETE request to + ``/v2/microvms/{microvm_id}``. The MicroVM's checkpoints are not deleted. - A successful request will receive a 204 status code with no body in response. - This indicates that the request was processed successfully. + A successful request returns a ``204 No Content`` status code. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :return: JSON object or None :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: @@ -195041,14 +202349,8 @@ def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: # response body for status code(s): 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -195069,8 +202371,8 @@ def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_load_balancers_delete_request( - lb_id=lb_id, + _request = build_microvms_delete_request( + microvm_id=microvm_id, headers=_headers, params=_params, ) @@ -195126,35 +202428,303 @@ def delete(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: return deserialized # type: ignore @distributed_trace - def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: + def post_pause(self, microvm_id: str, **kwargs: Any) -> JSON: # pylint: disable=line-too-long - """Delete a Global Load Balancer CDN Cache. + """Pause a MicroVM. - To delete a Global load balancer CDN cache, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/cache``. + To pause a MicroVM, send a POST request to ``/v2/microvms/{microvm_id}/pause``. + + Pausing suspends the MicroVM's processes and preserves its memory, files, and processes. + A paused MicroVM incurs storage charges only. The request returns when the change + completes. Pausing a MicroVM that is already paused succeeds. The request returns HTTP 400 + when the MicroVM is ``creating``\\ , ``terminated``\\ , or ``failed``. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. + }, + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. + ], + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_microvms_post_pause_request( + microvm_id=microvm_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 400, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def post_resume(self, microvm_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Resume a MicroVM. + + To resume a paused MicroVM, send a POST request to ``/v2/microvms/{microvm_id}/resume``. - A successful request will receive a 204 status code with no body in response. - This indicates that the request was processed successfully. + The request returns when the change completes. Resuming a MicroVM that is already running + succeeds. The request returns HTTP 400 when the MicroVM is ``creating``\\ , ``terminated``\\ , + or + ``failed``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :return: JSON object or None - :rtype: JSON or None + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "microvm": { + "auto_pause": { + "enabled": bool, # Optional. Whether auto-pause is on. + Always ``true``. + "idle_timeout": "str" # Optional. How long the MicroVM is + idle before it pauses, as a duration such as ``30s``"" , ``5m``"" , or + ``1h``. Defaults to ``5m``. The maximum is ``4h``. Responses show the + duration in the form ``5m0s``. + }, + "auto_resume": True, # Optional. Default value is True. Whether an + HTTP request, command, or console session resumes the MicroVM when it is + paused. + "created_at": "2020-02-20 00:00:00", # Optional. When the MicroVM + was created, in ISO 8601 format. + "failure_reason": "str", # Optional. Why the MicroVM failed. Present + only when ``state`` is ``failed``. + "http_protocol": "str", # Optional. The protocol the MicroVM's HTTP + port serves. ``null`` if the protocol was not set when the MicroVM was + created. Known values are: "http" and "http2". + "id": "str", # Optional. The unique ID of the MicroVM. + "name": "str", # Optional. The name of the MicroVM. Must be unique + in the region and contain 1 to 63 lowercase letters, digits, and hyphens. + "networking": "public", # Optional. Default value is "public". + ``public`` sends outbound traffic through a shared NAT gateway. ``vpc`` + places the MicroVM in the VPC network set by ``vpc_uuid``. Known values are: + "public" and "vpc". + "ports": [ + 0 # Optional. The guest ports declared on the MicroVM, + including the HTTP port. During the public preview, only the HTTP port is + reachable through the MicroVM's endpoint. + ], + "region": "str", # Optional. The slug of the region the MicroVM is + in. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "source": { + "checkpoint_id": "str", # Optional. The ID of a checkpoint + to create the MicroVM from. The new MicroVM inherits the checkpoint's + region, size, container image, and environment variables. + "oci_ref": "str" # Optional. A reference to a + ``linux/amd64`` container image in the form ``registry/repository:tag``. + The image can be public, such as an image on Docker Hub, or private in + your team's DigitalOcean Container Registry. + }, + "state": "str", # Optional. The MicroVM's current state. Known + values are: "creating", "running", "pausing", "paused", "resuming", + "terminating", "terminated", "failed", and "unknown". + "tags": [ + "str" # Optional. The tags applied to the MicroVM. + ], + "urls": [ + { + "default": bool, # Optional. Whether this is the + endpoint for the MicroVM's HTTP port. + "hostname": "str", # Optional. The endpoint's + hostname. Empty until provisioning finishes. Requests to the endpoint + must include a DigitalOcean API token with the ``microvm:access`` + scope in the ``Authorization`` header. + "port": 0, # Optional. The guest port the endpoint + serves. + "status": "str" # Optional. ``PENDING`` until + provisioning finishes, then ``ACTIVE``. Known values are: "PENDING" + and "ACTIVE". + } + ], + "vpc_uuid": "str" # Optional. The ID of a VPC network in the same + region that belongs to your team. Present only when ``networking`` is + ``vpc``. + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -195173,10 +202743,10 @@ def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_load_balancers_delete_cache_request( - lb_id=lb_id, + _request = build_microvms_post_resume_request( + microvm_id=microvm_id, headers=_headers, params=_params, ) @@ -195191,15 +202761,30 @@ def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [200, 400, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -195210,6 +202795,11 @@ def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -195227,42 +202817,39 @@ def delete_cache(self, lb_id: str, **kwargs: Any) -> Optional[JSON]: deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore @overload - def add_droplets( + def run_command( self, - lb_id: str, + microvm_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any, - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Droplets to a Load Balancer. + ) -> JSON: + """Run a command in a MicroVM. - To assign a Droplet to a load balancer instance, send a POST request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - Individual Droplets can not be added to a load balancer configured with a - Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" - response from the API. + To run a command in a MicroVM's workload container, send a POST request to + ``/v2/microvms/{microvm_id}/exec``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + ``argv`` runs directly, not through a shell, with standard input closed. If the MicroVM is + paused and auto-resume is on, the request resumes it and waits until it is running. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + A command has 60 seconds to finish. Your team can run 32 commands at once and 60 commands + per minute. Rejected requests count toward the per-minute limit. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :param body: Required. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -195270,99 +202857,101 @@ def add_droplets( # JSON input template you can fill out and use as your body input. body = { - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets assigned - to the load balancer. - ] + "argv": [ + "str" # The command and its arguments. Required. + ], + "cwd": "str" # Optional. The working directory to run the command in. } - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "exit_code": 0, # Optional. The command's exit code. + "stderr": "str", # Optional. The command's standard error. Bytes that are + not valid UTF-8 are replaced. + "stdout": "str", # Optional. The command's standard output. Bytes that are + not valid UTF-8 are replaced. + "truncated": bool # Optional. Present and ``true`` when the output exceeded + 4 MiB and was cut off. + } + # response body for status code(s): 400, 403, 404, 502 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ @overload - def add_droplets( + def run_command( self, - lb_id: str, + microvm_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any, - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Droplets to a Load Balancer. + ) -> JSON: + """Run a command in a MicroVM. - To assign a Droplet to a load balancer instance, send a POST request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - Individual Droplets can not be added to a load balancer configured with a - Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" - response from the API. + To run a command in a MicroVM's workload container, send a POST request to + ``/v2/microvms/{microvm_id}/exec``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + ``argv`` runs directly, not through a shell, with standard input closed. If the MicroVM is + paused and auto-resume is on, the request resumes it and waits until it is running. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + A command has 60 seconds to finish. Your team can run 32 commands at once and 60 commands + per minute. Rejected requests count toward the per-minute limit. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :param body: Required. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "exit_code": 0, # Optional. The command's exit code. + "stderr": "str", # Optional. The command's standard error. Bytes that are + not valid UTF-8 are replaced. + "stdout": "str", # Optional. The command's standard output. Bytes that are + not valid UTF-8 are replaced. + "truncated": bool # Optional. Present and ``true`` when the output exceeded + 4 MiB and was cut off. + } + # response body for status code(s): 400, 403, 404, 502 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ @distributed_trace - def add_droplets( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Droplets to a Load Balancer. + def run_command( + self, microvm_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + ) -> JSON: + """Run a command in a MicroVM. - To assign a Droplet to a load balancer instance, send a POST request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - Individual Droplets can not be added to a load balancer configured with a - Droplet tag. Attempting to do so will result in a "422 Unprocessable Entity" - response from the API. + To run a command in a MicroVM's workload container, send a POST request to + ``/v2/microvms/{microvm_id}/exec``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + ``argv`` runs directly, not through a shell, with standard input closed. If the MicroVM is + paused and auto-resume is on, the request resumes it and waits until it is running. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str + A command has 60 seconds to finish. Your team can run 32 commands at once and 60 commands + per minute. Rejected requests count toward the per-minute limit. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -195370,22 +202959,26 @@ def add_droplets( # JSON input template you can fill out and use as your body input. body = { - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets assigned - to the load balancer. - ] + "argv": [ + "str" # The command and its arguments. Required. + ], + "cwd": "str" # Optional. The working directory to run the command in. } - # response body for status code(s): 404 + # response body for status code(s): 200 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "exit_code": 0, # Optional. The command's exit code. + "stderr": "str", # Optional. The command's standard error. Bytes that are + not valid UTF-8 are replaced. + "stdout": "str", # Optional. The command's standard output. Bytes that are + not valid UTF-8 are replaced. + "truncated": bool # Optional. Present and ``true`` when the output exceeded + 4 MiB and was cut off. + } + # response body for status code(s): 400, 403, 404, 502 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -195407,7 +203000,7 @@ def add_droplets( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -195417,8 +203010,8 @@ def add_droplets( else: _json = body - _request = build_load_balancers_add_droplets_request( - lb_id=lb_id, + _request = build_microvms_run_command_request( + microvm_id=microvm_id, content_type=content_type, json=_json, content=_content, @@ -195436,15 +203029,14 @@ def add_droplets( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [200, 400, 403, 404, 502]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 200: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -195455,7 +203047,12 @@ def add_droplets( "int", response.headers.get("ratelimit-reset") ) - if response.status_code == 404: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -195471,132 +203068,79 @@ def add_droplets( else: deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def remove_droplets( - self, - lb_id: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Remove Droplets from a Load Balancer. - - To remove a Droplet from a load balancer instance, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. - - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets assigned - to the load balancer. - ] - } + if response.status_code == 403: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ + if response.content: + deserialized = response.json() + else: + deserialized = None - @overload - def remove_droplets( - self, - lb_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Remove Droplets from a Load Balancer. + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - To remove a Droplet from a load balancer instance, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. + if response.content: + deserialized = response.json() + else: + deserialized = None - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + if response.status_code == 502: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None - :raises ~azure.core.exceptions.HttpResponseError: + if response.content: + deserialized = response.json() + else: + deserialized = None - Example: - .. code-block:: python + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ + return cast(JSON, deserialized) # type: ignore @distributed_trace - def remove_droplets( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any + def get_console( + self, microvm_id: str, *, rows: int = 24, cols: int = 80, **kwargs: Any ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Remove Droplets from a Load Balancer. - - To remove a Droplet from a load balancer instance, send a DELETE request to - ``/v2/load_balancers/$LOAD_BALANCER_ID/droplets``. In the body of the request, - there should be a ``droplet_ids`` attribute containing a list of Droplet IDs. - - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. - - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] + """Open a console in a MicroVM. + + To open an interactive ``/bin/sh`` console in a MicroVM's workload container, open a + WebSocket connection to ``wss://api.digitalocean.com/v2/microvms/{microvm_id}/console``. + + Send the API token in the ``Authorization`` header of the handshake. Browsers cannot set this + header, so you cannot open the console from browser JavaScript. The image must include + ``/bin/sh``. A MicroVM can have four consoles open at a time. If the MicroVM is paused and + auto-resume is on, opening a console resumes it. + + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :keyword rows: The initial number of terminal rows. Default value is 24. + :paramtype rows: int + :keyword cols: The initial number of terminal columns. Default value is 80. + :paramtype cols: int :return: JSON object or None :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: @@ -195604,24 +203148,10 @@ def remove_droplets( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "droplet_ids": [ - 0 # Optional. An array containing the IDs of the Droplets assigned - to the load balancer. - ] - } - - # response body for status code(s): 404 + # response body for status code(s): 403, 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -195637,27 +203167,15 @@ def remove_droplets( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_load_balancers_remove_droplets_request( - lb_id=lb_id, - content_type=content_type, - json=_json, - content=_content, + _request = build_microvms_get_console_request( + microvm_id=microvm_id, + rows=rows, + cols=cols, headers=_headers, params=_params, ) @@ -195672,7 +203190,7 @@ def remove_droplets( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [101, 403, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore @@ -195680,7 +203198,18 @@ def remove_droplets( deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 101: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 403: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -195691,6 +203220,11 @@ def remove_droplets( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -195712,155 +203246,301 @@ def remove_droplets( return deserialized # type: ignore - @overload - def add_forwarding_rules( + +class MicrovmCheckpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`microvm_checkpoints` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace + def list( self, - lb_id: str, - body: JSON, *, - content_type: str = "application/json", + page: int = 1, + per_page: int = 25, + microvm_id: Optional[str] = None, **kwargs: Any, - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Add Forwarding Rules to a Load Balancer. + """List checkpoints. - To add an additional forwarding rule to a load balancer instance, send a POST - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body - of the request, there should be a ``forwarding_rules`` attribute containing an - array of rules to be added. - - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + To list your team's checkpoints, newest first, send a GET request to + ``/v2/microvms/checkpoints``. To list one MicroVM's checkpoints, add the ``microvm_id`` query + parameter. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :keyword page: Which 'page' of paginated results to return. Default value is 1. + :paramtype page: int + :keyword per_page: Number of items returned per page. Default value is 25. + :paramtype per_page: int + :keyword microvm_id: Only return checkpoints taken from this MicroVM. Default value is None. + :paramtype microvm_id: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "forwarding_rules": [ + # response body for status code(s): 200 + response == { + "meta": { + "total": 0 # Optional. Number of objects returned by the request. + }, + "checkpoints": [ { - "entry_port": 0, # An integer representing the port on which - the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for traffic to - the load balancer. The possible values are: ``http``"" , ``https``"" , - ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the - ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to - ``udp``. When using UDP, the load balancer requires that you set up a - health check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing the port on the - backend Droplets to which the load balancer will send traffic. Required. - "target_protocol": "str", # The protocol used for traffic - from the load balancer to the backend Droplets. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you - set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be - set to ``udp``. When using UDP, the load balancer requires that you set - up a health check with a port that uses TCP, HTTP, or HTTPS to work - properly. Required. Known values are: "http", "https", "http2", "tcp", - and "udp". - "certificate_id": "str", # Optional. The ID of the TLS - certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to the - backend Droplets. + "created_at": "2020-02-20 00:00:00", # Optional. When the + checkpoint was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the + checkpoint's disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the + checkpoint's memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM + the checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If + you do not set one, a name such as ``checkpoint-20260929-143559`` is + generated. + "region": "str", # Optional. The slug of the checkpoint's + region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. + Required. + "disk": 0 # Optional. The size of the disk, in GB. + Set by the size. + }, + "status": "str" # Optional. The checkpoint's status. You can + create MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. + Known values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". } - ] - } - - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + ], + "links": { + "pages": {} + } } """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def add_forwarding_rules( - self, - lb_id: str, - body: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Forwarding Rules to a Load Balancer. + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - To add an additional forwarding rule to a load balancer instance, send a POST - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body - of the request, there should be a ``forwarding_rules`` attribute containing an - array of rules to be added. + cls: ClsType[JSON] = kwargs.pop("cls", None) - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + _request = build_microvm_checkpoints_list_request( + page=page, + per_page=per_page, + microvm_id=microvm_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get(self, checkpoint_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve a checkpoint. + + To show information about a checkpoint, send a GET request to + ``/v2/microvms/checkpoints/{checkpoint_id}``. + + :param checkpoint_id: The unique ID of the checkpoint. Required. + :type checkpoint_id: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # response body for status code(s): 200 + response == { + "checkpoint": { + "created_at": "2020-02-20 00:00:00", # Optional. When the checkpoint + was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the checkpoint's + disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the checkpoint's + memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM the + checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If you do not + set one, a name such as ``checkpoint-20260929-143559`` is generated. + "region": "str", # Optional. The slug of the checkpoint's region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "status": "str" # Optional. The checkpoint's status. You can create + MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. Known + values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". + } + } # response body for status code(s): 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_microvm_checkpoints_get_request( + checkpoint_id=checkpoint_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore @distributed_trace - def add_forwarding_rules( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> Optional[JSON]: - # pylint: disable=line-too-long - """Add Forwarding Rules to a Load Balancer. + def delete(self, checkpoint_id: str, **kwargs: Any) -> Optional[JSON]: + """Delete a checkpoint. - To add an additional forwarding rule to a load balancer instance, send a POST - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the body - of the request, there should be a ``forwarding_rules`` attribute containing an - array of rules to be added. + To delete a checkpoint, send a DELETE request to ``/v2/microvms/checkpoints/{checkpoint_id}``. + You can no longer create MicroVMs from a deleted checkpoint. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + The request returns HTTP 400 while the checkpoint is still being captured. A successful + request returns a ``204 No Content`` status code. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] + :param checkpoint_id: The unique ID of the checkpoint. Required. + :type checkpoint_id: str :return: JSON object or None :rtype: JSON or None :raises ~azure.core.exceptions.HttpResponseError: @@ -195868,49 +203548,10 @@ def add_forwarding_rules( Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port on which - the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for traffic to - the load balancer. The possible values are: ``http``"" , ``https``"" , - ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the - ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to - ``udp``. When using UDP, the load balancer requires that you set up a - health check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing the port on the - backend Droplets to which the load balancer will send traffic. Required. - "target_protocol": "str", # The protocol used for traffic - from the load balancer to the backend Droplets. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you - set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be - set to ``udp``. When using UDP, the load balancer requires that you set - up a health check with a port that uses TCP, HTTP, or HTTPS to work - properly. Required. Known values are: "http", "https", "http2", "tcp", - and "udp". - "certificate_id": "str", # Optional. The ID of the TLS - certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to the - backend Droplets. - } - ] - } - - # response body for status code(s): 404 + # response body for status code(s): 400, 404 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -195926,27 +203567,13 @@ def add_forwarding_rules( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop( - "content_type", _headers.pop("Content-Type", None) - ) cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - _request = build_load_balancers_add_forwarding_rules_request( - lb_id=lb_id, - content_type=content_type, - json=_json, - content=_content, + _request = build_microvm_checkpoints_delete_request( + checkpoint_id=checkpoint_id, headers=_headers, params=_params, ) @@ -195961,7 +203588,7 @@ def add_forwarding_rules( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [204, 400, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore @@ -195980,6 +203607,22 @@ def add_forwarding_rules( "int", response.headers.get("ratelimit-reset") ) + if response.status_code == 400: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -196002,35 +203645,32 @@ def add_forwarding_rules( return deserialized # type: ignore @overload - def remove_forwarding_rules( + def create( self, - lb_id: str, - body: JSON, + microvm_id: str, + body: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any, - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Remove Forwarding Rules from a Load Balancer. + """Create a checkpoint of a MicroVM. - To remove forwarding rules from a load balancer instance, send a DELETE - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the - body of the request, there should be a ``forwarding_rules`` attribute containing - an array of rules to be removed. + To create a checkpoint of a running or paused MicroVM, send a POST request to + ``/v2/microvms/{microvm_id}/checkpoints``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + The capture runs in the background and does not change the MicroVM's state. Poll + ``GET /v2/microvms/checkpoints/{checkpoint_id}`` until ``status`` is ``CHECKPOINT_AVAILABLE``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :param body: Default value is None. :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -196038,120 +203678,136 @@ def remove_forwarding_rules( # JSON input template you can fill out and use as your body input. body = { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port on which - the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for traffic to - the load balancer. The possible values are: ``http``"" , ``https``"" , - ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the - ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to - ``udp``. When using UDP, the load balancer requires that you set up a - health check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing the port on the - backend Droplets to which the load balancer will send traffic. Required. - "target_protocol": "str", # The protocol used for traffic - from the load balancer to the backend Droplets. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you - set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be - set to ``udp``. When using UDP, the load balancer requires that you set - up a health check with a port that uses TCP, HTTP, or HTTPS to work - properly. Required. Known values are: "http", "https", "http2", "tcp", - and "udp". - "certificate_id": "str", # Optional. The ID of the TLS - certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to the - backend Droplets. - } - ] + "name": "str" # Optional. A name for the checkpoint. If you omit it, a name + such as ``checkpoint-20260929-143559`` is generated. } - # response body for status code(s): 404 + # response body for status code(s): 201 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "checkpoint": { + "created_at": "2020-02-20 00:00:00", # Optional. When the checkpoint + was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the checkpoint's + disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the checkpoint's + memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM the + checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If you do not + set one, a name such as ``checkpoint-20260929-143559`` is generated. + "region": "str", # Optional. The slug of the checkpoint's region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "status": "str" # Optional. The checkpoint's status. You can create + MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. Known + values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ @overload - def remove_forwarding_rules( + def create( self, - lb_id: str, - body: IO[bytes], + microvm_id: str, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any, - ) -> Optional[JSON]: + ) -> JSON: # pylint: disable=line-too-long - """Remove Forwarding Rules from a Load Balancer. + """Create a checkpoint of a MicroVM. - To remove forwarding rules from a load balancer instance, send a DELETE - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the - body of the request, there should be a ``forwarding_rules`` attribute containing - an array of rules to be removed. + To create a checkpoint of a running or paused MicroVM, send a POST request to + ``/v2/microvms/{microvm_id}/checkpoints``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + The capture runs in the background and does not change the MicroVM's state. Poll + ``GET /v2/microvms/checkpoints/{checkpoint_id}`` until ``status`` is ``CHECKPOINT_AVAILABLE``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Required. + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :param body: Default value is None. :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 404 + # response body for status code(s): 201 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "checkpoint": { + "created_at": "2020-02-20 00:00:00", # Optional. When the checkpoint + was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the checkpoint's + disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the checkpoint's + memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM the + checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If you do not + set one, a name such as ``checkpoint-20260929-143559`` is generated. + "region": "str", # Optional. The slug of the checkpoint's region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "status": "str" # Optional. The checkpoint's status. You can create + MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. Known + values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ @distributed_trace - def remove_forwarding_rules( - self, lb_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any - ) -> Optional[JSON]: + def create( + self, + microvm_id: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any, + ) -> JSON: # pylint: disable=line-too-long - """Remove Forwarding Rules from a Load Balancer. + """Create a checkpoint of a MicroVM. - To remove forwarding rules from a load balancer instance, send a DELETE - request to ``/v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules``. In the - body of the request, there should be a ``forwarding_rules`` attribute containing - an array of rules to be removed. + To create a checkpoint of a running or paused MicroVM, send a POST request to + ``/v2/microvms/{microvm_id}/checkpoints``. - No response body will be sent back, but the response code will indicate - success. Specifically, the response code will be a 204, which means that the - action was successful with no returned body data. + The capture runs in the background and does not change the MicroVM's state. Poll + ``GET /v2/microvms/checkpoints/{checkpoint_id}`` until ``status`` is ``CHECKPOINT_AVAILABLE``. - :param lb_id: A unique identifier for a load balancer. Required. - :type lb_id: str - :param body: Is either a JSON type or a IO[bytes] type. Required. + :param microvm_id: The unique ID of the MicroVM. Required. + :type microvm_id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. :type body: JSON or IO[bytes] - :return: JSON object or None - :rtype: JSON or None + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -196159,47 +203815,43 @@ def remove_forwarding_rules( # JSON input template you can fill out and use as your body input. body = { - "forwarding_rules": [ - { - "entry_port": 0, # An integer representing the port on which - the load balancer instance will listen. Required. - "entry_protocol": "str", # The protocol used for traffic to - the load balancer. The possible values are: ``http``"" , ``https``"" , - ``http2``"" , ``http3``"" , ``tcp``"" , or ``udp``. If you set the - ``entry_protocol`` to ``udp``"" , the ``target_protocol`` must be set to - ``udp``. When using UDP, the load balancer requires that you set up a - health check with a port that uses TCP, HTTP, or HTTPS to work properly. - Required. Known values are: "http", "https", "http2", "http3", "tcp", and - "udp". - "target_port": 0, # An integer representing the port on the - backend Droplets to which the load balancer will send traffic. Required. - "target_protocol": "str", # The protocol used for traffic - from the load balancer to the backend Droplets. The possible values are: - ``http``"" , ``https``"" , ``http2``"" , ``tcp``"" , or ``udp``. If you - set the ``target_protocol`` to ``udp``"" , the ``entry_protocol`` must be - set to ``udp``. When using UDP, the load balancer requires that you set - up a health check with a port that uses TCP, HTTP, or HTTPS to work - properly. Required. Known values are: "http", "https", "http2", "tcp", - and "udp". - "certificate_id": "str", # Optional. The ID of the TLS - certificate used for SSL termination if enabled. - "tls_passthrough": bool # Optional. A boolean value - indicating whether SSL encrypted traffic will be passed through to the - backend Droplets. - } - ] + "name": "str" # Optional. A name for the checkpoint. If you omit it, a name + such as ``checkpoint-20260929-143559`` is generated. } - # response body for status code(s): 404 + # response body for status code(s): 201 response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. + "checkpoint": { + "created_at": "2020-02-20 00:00:00", # Optional. When the checkpoint + was created, in ISO 8601 format. + "disk_bytes": 0, # Optional. The stored size of the checkpoint's + disk, in bytes. + "id": "str", # Optional. The unique ID of the checkpoint. + "memory_bytes": 0, # Optional. The stored size of the checkpoint's + memory, in bytes. + "microvm_id": "str", # Optional. The ID of the MicroVM the + checkpoint was taken from. + "microvm_name": "str", # Optional. The name of the MicroVM the + checkpoint was taken from. + "name": "str", # Optional. The name of the checkpoint. If you do not + set one, a name such as ``checkpoint-20260929-143559`` is generated. + "region": "str", # Optional. The slug of the checkpoint's region. + "size": { + "cpu": 0, # The number of vCPUs. Required. + "memory": 0, # The amount of memory, in MiB. Required. + "disk": 0 # Optional. The size of the disk, in GB. Set by + the size. + }, + "status": "str" # Optional. The checkpoint's status. You can create + MicroVMs from the checkpoint when it is ``CHECKPOINT_AVAILABLE``. Known + values are: "CHECKPOINT_CREATING", "CHECKPOINT_AVAILABLE", + "CHECKPOINT_FAILED", "CHECKPOINT_DELETING", and "CHECKPOINT_DELETED". + } + } + # response body for status code(s): 400, 404 + response == { + "code": "str", # A service-defined error code. Required. + "message": "str" # A human-readable description of the error. Required. } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -196221,7 +203873,7 @@ def remove_forwarding_rules( content_type: Optional[str] = kwargs.pop( "content_type", _headers.pop("Content-Type", None) ) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[JSON] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -196229,10 +203881,13 @@ def remove_forwarding_rules( if isinstance(body, (IOBase, bytes)): _content = body else: - _json = body + if body is not None: + _json = body + else: + _json = None - _request = build_load_balancers_remove_forwarding_rules_request( - lb_id=lb_id, + _request = build_microvm_checkpoints_create_request( + microvm_id=microvm_id, content_type=content_type, json=_json, content=_content, @@ -196250,15 +203905,30 @@ def remove_forwarding_rules( response = pipeline_response.http_response - if response.status_code not in [204, 404]: + if response.status_code not in [201, 400, 404]: if _stream: response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore raise HttpResponseError(response=response) - deserialized = None response_headers = {} - if response.status_code == 204: + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 400: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") ) @@ -196269,6 +203939,11 @@ def remove_forwarding_rules( "int", response.headers.get("ratelimit-reset") ) + if response.content: + deserialized = response.json() + else: + deserialized = None + if response.status_code == 404: response_headers["ratelimit-limit"] = self._deserialize( "int", response.headers.get("ratelimit-limit") @@ -196286,9 +203961,9 @@ def remove_forwarding_rules( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return deserialized # type: ignore + return cast(JSON, deserialized) # type: ignore class MonitoringOperations: # pylint: disable=too-many-public-methods @@ -307471,7 +315146,7 @@ def list_scenario_library_scenarios( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -307880,7 +315555,7 @@ def create_scenario_set( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -308099,7 +315774,7 @@ def create_scenario_set( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -309173,7 +316848,7 @@ def update_scenario_set( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -309404,7 +317079,7 @@ def update_scenario_set( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -310295,7 +317970,7 @@ def list_scenarios( { "description": "str", # Optional. What the user tries to accomplish. Required. - "exploration_budget": 0, # Optional. Number of journeys to + "exploration_budget": 0, # Optional. Number of episodes to explore for this scenario. Defaults to 1 if unset. "max_turns": 0, # Optional. Turn budget for the scenario. Falls back to the run-level default if unset. @@ -311010,12 +318685,12 @@ def list_simulation_runs( * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not yet executing. - * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. - * SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. + * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. + * SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was cancelled. - * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an attached evaluation is running. + * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run @@ -311096,16 +318771,16 @@ def list_simulation_runs( actor who triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that + have finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that - have finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the @@ -311130,11 +318805,11 @@ def list_simulation_runs( wall-clock duration across the run, in seconds. "verdict_counts": { "failure_count": 0, # Optional. Number of - journeys with a FAILURE verdict. + episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number - of journeys with an INCONCLUSIVE verdict. + of episodes with an INCONCLUSIVE verdict. "success_count": 0 # Optional. Number of - journeys with a SUCCESS verdict. + episodes with a SUCCESS verdict. } }, "run_uuid": "str", # Optional. UUID of the run. @@ -311145,12 +318820,12 @@ def list_simulation_runs( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, - not yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are - executing. * SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished + not yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are + executing. * SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was cancelled. * - SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an attached + SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -311161,7 +318836,7 @@ def list_simulation_runs( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -311337,323 +319012,7 @@ def create_simulation_run( } }, "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's - exploration_budget. - "judge_model_uuid": "str", # Optional. Optional model override for the - judge. Platform default when unset. - "max_turns": 0, # Optional. Optional run-level turn budget. When set, - overrides each scenario's max_turns. - "name": "str", # Optional. Optional run name. - "scenario_set_uuid": "str", # Optional. UUID of the existing scenario set to - execute. The set must be ready. - "user_simulator_config": {}, # Optional. Optional user simulator model - settings such as temperature and max_tokens. - "user_simulator_model_uuid": "str" # Optional. Optional model override for - the user simulator. Platform default when unset. - } - - # response body for status code(s): 200 - response == { - "simulation_run": { - "agent_config": { - "agent_deployment_uuid": "str", # Optional. Optional agent - deployment to run. Defaults to the agent's current deployment when unset. - "agent_uuid": "str", # Optional. UUID of the agent to - exercise as the candidate. - "name": "str" # Optional. Display name of the candidate - agent. Persisted with the run. - }, - "created_at": "2020-02-20 00:00:00", # Optional. Time created at. - "created_by_user_email": "str", # Optional. Email of the user who - triggered this run. - "created_by_user_id": "str", # Optional. User id of the actor who - triggered this run. - "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. - Unset unless the run has been deleted. - "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run - reserved for this simulation, when the create request included - evaluation_config. Empty when no evaluation is attached. - "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's - exploration_budget. - "failure_reason": "str", # Optional. Human-readable explanation of a - terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). - "judge_model_name": "str", # Optional. Display name of the judge - model (from the model catalog). - "judge_model_uuid": "str", # Optional. Model used by the judge. - "max_turns": 0, # Optional. Optional run-level turn budget. When - set, overrides each scenario's max_turns. - "name": "str", # Optional. Optional run name. - "result_summary": { - "token_usage": { - "candidate_agent_tokens": "str", # Optional. Tokens - consumed by the candidate agent. - "generator_tokens": "str", # Optional. Tokens - consumed by the scenario generator. - "judge_tokens": "str", # Optional. Tokens consumed - by the judge. - "simulator_tokens": "str", # Optional. Tokens - consumed by the user simulator. - "total_tokens": "str" # Optional. Total tokens - across all actors. - }, - "total_duration_sec": "str", # Optional. Total wall-clock - duration across the run, in seconds. - "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys - with a FAILURE verdict. - "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys - with a SUCCESS verdict. - } - }, - "run_uuid": "str", # Optional. UUID of the run. - "scenario_count": 0, # Optional. Number of scenarios in the scenario - set for this run. - "scenario_set_uuid": "str", # Optional. UUID of the scenario set - being executed (must exist at run create). - "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default - value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a - simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * - SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a - timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an - attached evaluation is running. Only reachable when the create request - included evaluation_config. When the evaluation reaches a terminal status, - its outcome is reflected in the simulation run status. * - SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL: The simulation or its attached - evaluation completed with a mixture of successful and failed results. Known - values are: "SIMULATION_RUN_STATUS_UNSPECIFIED", - "SIMULATION_RUN_STATUS_PENDING", "SIMULATION_RUN_STATUS_RUNNING", - "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", - "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and - "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of - exploration budgets). - "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated - at. - "user_simulator_config": {}, # Optional. Optional user simulator - model settings such as temperature and max_tokens. - "user_simulator_model_name": "str", # Optional. Display name of the - user simulator model (from the model catalog). - "user_simulator_model_uuid": "str", # Optional. Model used by the - user simulator. - "workflow_uuid": "str" # Optional. Identifier of the workflow - executing this run. - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ - - @overload - def create_simulation_run( - self, - body: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> JSON: - # pylint: disable=line-too-long - """Create Simulation Run. - - To create a simulation run, send a POST request to ``/v2/gen-ai/simulation_runs``. The scenario - set must be ready. Judge and user simulator models are optional and use platform defaults when - omitted. The run is returned in the pending state. - - :param body: Default value is None. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "simulation_run": { - "agent_config": { - "agent_deployment_uuid": "str", # Optional. Optional agent - deployment to run. Defaults to the agent's current deployment when unset. - "agent_uuid": "str", # Optional. UUID of the agent to - exercise as the candidate. - "name": "str" # Optional. Display name of the candidate - agent. Persisted with the run. - }, - "created_at": "2020-02-20 00:00:00", # Optional. Time created at. - "created_by_user_email": "str", # Optional. Email of the user who - triggered this run. - "created_by_user_id": "str", # Optional. User id of the actor who - triggered this run. - "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. - Unset unless the run has been deleted. - "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run - reserved for this simulation, when the create request included - evaluation_config. Empty when no evaluation is attached. - "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's - exploration_budget. - "failure_reason": "str", # Optional. Human-readable explanation of a - terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). - "judge_model_name": "str", # Optional. Display name of the judge - model (from the model catalog). - "judge_model_uuid": "str", # Optional. Model used by the judge. - "max_turns": 0, # Optional. Optional run-level turn budget. When - set, overrides each scenario's max_turns. - "name": "str", # Optional. Optional run name. - "result_summary": { - "token_usage": { - "candidate_agent_tokens": "str", # Optional. Tokens - consumed by the candidate agent. - "generator_tokens": "str", # Optional. Tokens - consumed by the scenario generator. - "judge_tokens": "str", # Optional. Tokens consumed - by the judge. - "simulator_tokens": "str", # Optional. Tokens - consumed by the user simulator. - "total_tokens": "str" # Optional. Total tokens - across all actors. - }, - "total_duration_sec": "str", # Optional. Total wall-clock - duration across the run, in seconds. - "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys - with a FAILURE verdict. - "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys - with a SUCCESS verdict. - } - }, - "run_uuid": "str", # Optional. UUID of the run. - "scenario_count": 0, # Optional. Number of scenarios in the scenario - set for this run. - "scenario_set_uuid": "str", # Optional. UUID of the scenario set - being executed (must exist at run create). - "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default - value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a - simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * - SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a - timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an - attached evaluation is running. Only reachable when the create request - included evaluation_config. When the evaluation reaches a terminal status, - its outcome is reflected in the simulation run status. * - SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL: The simulation or its attached - evaluation completed with a mixture of successful and failed results. Known - values are: "SIMULATION_RUN_STATUS_UNSPECIFIED", - "SIMULATION_RUN_STATUS_PENDING", "SIMULATION_RUN_STATUS_RUNNING", - "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", - "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and - "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of - exploration budgets). - "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated - at. - "user_simulator_config": {}, # Optional. Optional user simulator - model settings such as temperature and max_tokens. - "user_simulator_model_name": "str", # Optional. Display name of the - user simulator model (from the model catalog). - "user_simulator_model_uuid": "str", # Optional. Model used by the - user simulator. - "workflow_uuid": "str" # Optional. Identifier of the workflow - executing this run. - } - } - # response body for status code(s): 404 - response == { - "id": "str", # A short identifier corresponding to the HTTP status code - returned. For example, the ID for a response returning a 404 status code would - be "not_found.". Required. - "message": "str", # A message providing additional information about the - error, including details to help resolve it when possible. Required. - "request_id": "str" # Optional. Optionally, some endpoints may include a - request ID that should be provided when reporting bugs or opening support - tickets to help identify the issue. - } - """ - - @distributed_trace - def create_simulation_run( - self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any - ) -> JSON: - # pylint: disable=line-too-long - """Create Simulation Run. - - To create a simulation run, send a POST request to ``/v2/gen-ai/simulation_runs``. The scenario - set must be ready. Judge and user simulator models are optional and use platform defaults when - omitted. The run is returned in the pending state. - - :param body: Is either a JSON type or a IO[bytes] type. Default value is None. - :type body: JSON or IO[bytes] - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "agent_config": { - "agent_deployment_uuid": "str", # Optional. Optional agent - deployment to run. Defaults to the agent's current deployment when unset. - "agent_uuid": "str", # Optional. UUID of the agent to exercise as - the candidate. - "name": "str" # Optional. Display name of the candidate agent. - Persisted with the run. - }, - "evaluation_config": { - "metric_uuids": [ - "str" # Optional. Evaluation metric UUIDs (from the - evaluation metrics catalog). Must be simulation-eligible (multi-turn) - metrics; the create request is rejected if any UUID is unknown or - ineligible. - ], - "star_metric": { - "metric_uuid": "str", # Optional. Optional configuration - that opts a simulation run into an evaluation. When included on the - create-run request, the platform reserves a model_evaluation_run linked - to this simulation run and dispatches the evaluation automatically after - the simulation finishes. The evaluation reuses the simulation run's - judge_model_uuid. - "name": "str", # Optional. Optional configuration that opts - a simulation run into an evaluation. When included on the create-run - request, the platform reserves a model_evaluation_run linked to this - simulation run and dispatches the evaluation automatically after the - simulation finishes. The evaluation reuses the simulation run's - judge_model_uuid. - "success_threshold": 0.0, # Optional. The success threshold - for the star metric. This is a value that the metric must reach to be - considered successful. - "success_threshold_pct": 0 # Optional. The success threshold - for the star metric. This is a percentage value between 0 and 100. - } - }, - "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "judge_model_uuid": "str", # Optional. Optional model override for the judge. Platform default when unset. @@ -311686,16 +319045,151 @@ def create_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have + "judge_model_name": "str", # Optional. Display name of the judge + model (from the model catalog). + "judge_model_uuid": "str", # Optional. Model used by the judge. + "max_turns": 0, # Optional. Optional run-level turn budget. When + set, overrides each scenario's max_turns. + "name": "str", # Optional. Optional run name. + "result_summary": { + "token_usage": { + "candidate_agent_tokens": "str", # Optional. Tokens + consumed by the candidate agent. + "generator_tokens": "str", # Optional. Tokens + consumed by the scenario generator. + "judge_tokens": "str", # Optional. Tokens consumed + by the judge. + "simulator_tokens": "str", # Optional. Tokens + consumed by the user simulator. + "total_tokens": "str" # Optional. Total tokens + across all actors. + }, + "total_duration_sec": "str", # Optional. Total wall-clock + duration across the run, in seconds. + "verdict_counts": { + "failure_count": 0, # Optional. Number of episodes + with a FAILURE verdict. + "inconclusive_count": 0, # Optional. Number of + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes + with a SUCCESS verdict. + } + }, + "run_uuid": "str", # Optional. UUID of the run. + "scenario_count": 0, # Optional. Number of scenarios in the scenario + set for this run. + "scenario_set_uuid": "str", # Optional. UUID of the scenario set + being executed (must exist at run create). + "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default + value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a + simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * + SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a + timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an + attached evaluation is running. Only reachable when the create request + included evaluation_config. When the evaluation reaches a terminal status, + its outcome is reflected in the simulation run status. * + SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL: The simulation or its attached + evaluation completed with a mixture of successful and failed results. Known + values are: "SIMULATION_RUN_STATUS_UNSPECIFIED", + "SIMULATION_RUN_STATUS_PENDING", "SIMULATION_RUN_STATUS_RUNNING", + "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", + "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and + "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". + "total_episodes": 0, # Optional. Total number of episodes (sum of + exploration budgets). + "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated + at. + "user_simulator_config": {}, # Optional. Optional user simulator + model settings such as temperature and max_tokens. + "user_simulator_model_name": "str", # Optional. Display name of the + user simulator model (from the model catalog). + "user_simulator_model_uuid": "str", # Optional. Model used by the + user simulator. + "workflow_uuid": "str" # Optional. Identifier of the workflow + executing this run. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def create_simulation_run( + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create Simulation Run. + + To create a simulation run, send a POST request to ``/v2/gen-ai/simulation_runs``. The scenario + set must be ready. Judge and user simulator models are optional and use platform defaults when + omitted. The run is returned in the pending state. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "simulation_run": { + "agent_config": { + "agent_deployment_uuid": "str", # Optional. Optional agent + deployment to run. Defaults to the agent's current deployment when unset. + "agent_uuid": "str", # Optional. UUID of the agent to + exercise as the candidate. + "name": "str" # Optional. Display name of the candidate + agent. Persisted with the run. + }, + "created_at": "2020-02-20 00:00:00", # Optional. Time created at. + "created_by_user_email": "str", # Optional. Email of the user who + triggered this run. + "created_by_user_id": "str", # Optional. User id of the actor who + triggered this run. + "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. + Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have finished (successfully or not). + "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run + reserved for this simulation, when the create request included + evaluation_config. Empty when no evaluation is attached. + "exploration_budget": 0, # Optional. Optional run-level + episodes-per-scenario override. When set, overrides each scenario's + exploration_budget. + "failure_reason": "str", # Optional. Human-readable explanation of a + terminal FAILED status. Empty otherwise. "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -311718,11 +319212,11 @@ def create_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -311734,11 +319228,11 @@ def create_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -311749,7 +319243,188 @@ def create_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of + exploration budgets). + "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated + at. + "user_simulator_config": {}, # Optional. Optional user simulator + model settings such as temperature and max_tokens. + "user_simulator_model_name": "str", # Optional. Display name of the + user simulator model (from the model catalog). + "user_simulator_model_uuid": "str", # Optional. Model used by the + user simulator. + "workflow_uuid": "str" # Optional. Identifier of the workflow + executing this run. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def create_simulation_run( + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create Simulation Run. + + To create a simulation run, send a POST request to ``/v2/gen-ai/simulation_runs``. The scenario + set must be ready. Judge and user simulator models are optional and use platform defaults when + omitted. The run is returned in the pending state. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "agent_config": { + "agent_deployment_uuid": "str", # Optional. Optional agent + deployment to run. Defaults to the agent's current deployment when unset. + "agent_uuid": "str", # Optional. UUID of the agent to exercise as + the candidate. + "name": "str" # Optional. Display name of the candidate agent. + Persisted with the run. + }, + "evaluation_config": { + "metric_uuids": [ + "str" # Optional. Evaluation metric UUIDs (from the + evaluation metrics catalog). Must be simulation-eligible (multi-turn) + metrics; the create request is rejected if any UUID is unknown or + ineligible. + ], + "star_metric": { + "metric_uuid": "str", # Optional. Optional configuration + that opts a simulation run into an evaluation. When included on the + create-run request, the platform reserves a model_evaluation_run linked + to this simulation run and dispatches the evaluation automatically after + the simulation finishes. The evaluation reuses the simulation run's + judge_model_uuid. + "name": "str", # Optional. Optional configuration that opts + a simulation run into an evaluation. When included on the create-run + request, the platform reserves a model_evaluation_run linked to this + simulation run and dispatches the evaluation automatically after the + simulation finishes. The evaluation reuses the simulation run's + judge_model_uuid. + "success_threshold": 0.0, # Optional. The success threshold + for the star metric. This is a value that the metric must reach to be + considered successful. + "success_threshold_pct": 0 # Optional. The success threshold + for the star metric. This is a percentage value between 0 and 100. + } + }, + "exploration_budget": 0, # Optional. Optional run-level + episodes-per-scenario override. When set, overrides each scenario's + exploration_budget. + "judge_model_uuid": "str", # Optional. Optional model override for the + judge. Platform default when unset. + "max_turns": 0, # Optional. Optional run-level turn budget. When set, + overrides each scenario's max_turns. + "name": "str", # Optional. Optional run name. + "scenario_set_uuid": "str", # Optional. UUID of the existing scenario set to + execute. The set must be ready. + "user_simulator_config": {}, # Optional. Optional user simulator model + settings such as temperature and max_tokens. + "user_simulator_model_uuid": "str" # Optional. Optional model override for + the user simulator. Platform default when unset. + } + + # response body for status code(s): 200 + response == { + "simulation_run": { + "agent_config": { + "agent_deployment_uuid": "str", # Optional. Optional agent + deployment to run. Defaults to the agent's current deployment when unset. + "agent_uuid": "str", # Optional. UUID of the agent to + exercise as the candidate. + "name": "str" # Optional. Display name of the candidate + agent. Persisted with the run. + }, + "created_at": "2020-02-20 00:00:00", # Optional. Time created at. + "created_by_user_email": "str", # Optional. Email of the user who + triggered this run. + "created_by_user_id": "str", # Optional. User id of the actor who + triggered this run. + "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. + Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). + "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run + reserved for this simulation, when the create request included + evaluation_config. Empty when no evaluation is attached. + "exploration_budget": 0, # Optional. Optional run-level + episodes-per-scenario override. When set, overrides each scenario's + exploration_budget. + "failure_reason": "str", # Optional. Human-readable explanation of a + terminal FAILED status. Empty otherwise. + "judge_model_name": "str", # Optional. Display name of the judge + model (from the model catalog). + "judge_model_uuid": "str", # Optional. Model used by the judge. + "max_turns": 0, # Optional. Optional run-level turn budget. When + set, overrides each scenario's max_turns. + "name": "str", # Optional. Optional run name. + "result_summary": { + "token_usage": { + "candidate_agent_tokens": "str", # Optional. Tokens + consumed by the candidate agent. + "generator_tokens": "str", # Optional. Tokens + consumed by the scenario generator. + "judge_tokens": "str", # Optional. Tokens consumed + by the judge. + "simulator_tokens": "str", # Optional. Tokens + consumed by the user simulator. + "total_tokens": "str" # Optional. Total tokens + across all actors. + }, + "total_duration_sec": "str", # Optional. Total wall-clock + duration across the run, in seconds. + "verdict_counts": { + "failure_count": 0, # Optional. Number of episodes + with a FAILURE verdict. + "inconclusive_count": 0, # Optional. Number of + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes + with a SUCCESS verdict. + } + }, + "run_uuid": "str", # Optional. UUID of the run. + "scenario_count": 0, # Optional. Number of scenarios in the scenario + set for this run. + "scenario_set_uuid": "str", # Optional. UUID of the scenario set + being executed (must exist at run create). + "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default + value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a + simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * + SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a + timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an + attached evaluation is running. Only reachable when the create request + included evaluation_config. When the evaluation reaches a terminal status, + its outcome is reflected in the simulation run status. * + SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL: The simulation or its attached + evaluation completed with a mixture of successful and failed results. Known + values are: "SIMULATION_RUN_STATUS_UNSPECIFIED", + "SIMULATION_RUN_STATUS_PENDING", "SIMULATION_RUN_STATUS_RUNNING", + "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", + "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and + "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -311889,17 +319564,17 @@ def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: response == { "scenario_results": [ { - "journeys_finished": 0, # Optional. Journeys that have + "episodes_finished": 0, # Optional. Episodes that have finished (successfully or not). "scenario_uuid": "str", # Optional. UUID of the scenario. - "total_journeys": 0, # Optional. Total journeys for this + "total_episodes": 0, # Optional. Total episodes for this scenario (its exploration budget). "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } } @@ -311920,16 +319595,16 @@ def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -311952,11 +319627,11 @@ def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -311968,11 +319643,11 @@ def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -311983,7 +319658,7 @@ def get_simulation_run(self, run_uuid: str, **kwargs: Any) -> JSON: "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -312142,16 +319817,16 @@ def update_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -312174,11 +319849,11 @@ def update_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -312190,11 +319865,11 @@ def update_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -312205,7 +319880,7 @@ def update_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -312281,16 +319956,16 @@ def update_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -312313,11 +319988,11 @@ def update_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -312329,11 +320004,11 @@ def update_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -312344,7 +320019,7 @@ def update_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -312421,16 +320096,16 @@ def update_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -312453,11 +320128,11 @@ def update_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -312469,11 +320144,11 @@ def update_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -312484,7 +320159,7 @@ def update_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -312775,16 +320450,16 @@ def patch_cancel_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -312807,11 +320482,11 @@ def patch_cancel_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -312823,11 +320498,11 @@ def patch_cancel_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -312838,7 +320513,7 @@ def patch_cancel_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -312914,16 +320589,16 @@ def patch_cancel_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -312946,11 +320621,11 @@ def patch_cancel_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -312962,11 +320637,11 @@ def patch_cancel_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -312977,7 +320652,7 @@ def patch_cancel_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -313053,16 +320728,16 @@ def patch_cancel_simulation_run( triggered this run. "deleted_at": "2020-02-20 00:00:00", # Optional. Time deleted at. Unset unless the run has been deleted. + "episodes_finished": 0, # Optional. Number of episodes that have + finished (successfully or not). "evaluation_run_uuid": "str", # Optional. UUID of the evaluation run reserved for this simulation, when the create request included evaluation_config. Empty when no evaluation is attached. "exploration_budget": 0, # Optional. Optional run-level - journeys-per-scenario override. When set, overrides each scenario's + episodes-per-scenario override. When set, overrides each scenario's exploration_budget. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journeys_finished": 0, # Optional. Number of journeys that have - finished (successfully or not). "judge_model_name": "str", # Optional. Display name of the judge model (from the model catalog). "judge_model_uuid": "str", # Optional. Model used by the judge. @@ -313085,11 +320760,11 @@ def patch_cancel_simulation_run( "total_duration_sec": "str", # Optional. Total wall-clock duration across the run, in seconds. "verdict_counts": { - "failure_count": 0, # Optional. Number of journeys + "failure_count": 0, # Optional. Number of episodes with a FAILURE verdict. "inconclusive_count": 0, # Optional. Number of - journeys with an INCONCLUSIVE verdict. - "success_count": 0 # Optional. Number of journeys + episodes with an INCONCLUSIVE verdict. + "success_count": 0 # Optional. Number of episodes with a SUCCESS verdict. } }, @@ -313101,11 +320776,11 @@ def patch_cancel_simulation_run( "status": "SIMULATION_RUN_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_RUN_STATUS_UNSPECIFIED". Lifecycle status of a simulation run. * SIMULATION_RUN_STATUS_PENDING: Accepted and queued, not - yet executing. * SIMULATION_RUN_STATUS_RUNNING: Journeys are executing. * - SIMULATION_RUN_STATUS_SUCCEEDED: All journeys finished successfully. * + yet executing. * SIMULATION_RUN_STATUS_RUNNING: Episodes are executing. * + SIMULATION_RUN_STATUS_SUCCEEDED: All episodes finished successfully. * SIMULATION_RUN_STATUS_FAILED: The run failed, for example because of a timeout or workflow error. * SIMULATION_RUN_STATUS_CANCELLED: The run was - cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Journeys finished and an + cancelled. * SIMULATION_RUN_STATUS_EVALUATING: Episodes finished and an attached evaluation is running. Only reachable when the create request included evaluation_config. When the evaluation reaches a terminal status, its outcome is reflected in the simulation run status. * @@ -313116,7 +320791,7 @@ def patch_cancel_simulation_run( "SIMULATION_RUN_STATUS_SUCCEEDED", "SIMULATION_RUN_STATUS_FAILED", "SIMULATION_RUN_STATUS_CANCELLED", "SIMULATION_RUN_STATUS_EVALUATING", and "SIMULATION_RUN_STATUS_PARTIALLY_SUCCESSFUL". - "total_journeys": 0, # Optional. Total number of journeys (sum of + "total_episodes": 0, # Optional. Total number of episodes (sum of exploration budgets). "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. @@ -313238,7 +320913,7 @@ def patch_cancel_simulation_run( return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_simulation_journeys( + def list_simulation_episodes( self, run_uuid: str, *, @@ -313248,17 +320923,17 @@ def list_simulation_journeys( statuses: Optional[List[str]] = None, verdicts: Optional[List[str]] = None, search: Optional[str] = None, - sort_by: str = "SIMULATION_JOURNEY_SORT_FIELD_UNSPECIFIED", + sort_by: str = "SIMULATION_EPISODE_SORT_FIELD_UNSPECIFIED", sort_direction: str = "SORT_DIRECTION_UNSPECIFIED", **kwargs: Any, ) -> JSON: # pylint: disable=line-too-long - """List Simulation Journeys. + """List Simulation Episodes. - To list the journeys within a simulation run, send a GET request to - ``/v2/gen-ai/simulation_runs/{run_uuid}/journeys``. + To list the episodes within a simulation run, send a GET request to + ``/v2/gen-ai/simulation_runs/{run_uuid}/episodes``. - :param run_uuid: UUID of the run whose journeys to list. Required. + :param run_uuid: UUID of the run whose episodes to list. Required. :type run_uuid: str :keyword scenario_uuid: Optional filter by scenario. Default value is None. :paramtype scenario_uuid: str @@ -313269,22 +320944,22 @@ def list_simulation_journeys( :keyword statuses: Filter by one or more statuses. Empty means no status filter. - * SIMULATION_JOURNEY_STATUS_RUNNING: The journey is executing and a trajectory is available to + * SIMULATION_EPISODE_STATUS_RUNNING: The episode is executing and a trajectory is available to retrieve. - * SIMULATION_JOURNEY_STATUS_FINISHED: The journey reached a stop condition and produced a + * SIMULATION_EPISODE_STATUS_FINISHED: The episode reached a stop condition and produced a verdict. - * SIMULATION_JOURNEY_STATUS_FAILED: The journey failed because of a cancel, timeout, or error. - * SIMULATION_JOURNEY_STATUS_PREPARING: The journey is allocated but its trajectory is not + * SIMULATION_EPISODE_STATUS_FAILED: The episode failed because of a cancel, timeout, or error. + * SIMULATION_EPISODE_STATUS_PREPARING: The episode is allocated but its trajectory is not available yet. Default value is None. :paramtype statuses: list[str] :keyword verdicts: Filter by one or more verdicts. Empty means no verdict filter. - * SIMULATION_JOURNEY_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping + * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. - * SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy the stopping + * SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy the stopping criteria. - * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached + * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). Default value is None. :paramtype verdicts: list[str] :keyword search: Free-text search across scenario_uuid and session_id @@ -313293,14 +320968,14 @@ def list_simulation_journeys( :keyword sort_by: Field to sort by. Defaults to scenario ordering when unspecified. - * SIMULATION_JOURNEY_SORT_FIELD_SCENARIO: Sort by scenario_uuid then journey_index. Default. - * SIMULATION_JOURNEY_SORT_FIELD_CREATED_AT: Sort by creation date. - * SIMULATION_JOURNEY_SORT_FIELD_STATUS: Sort by journey status using lifecycle order. - * SIMULATION_JOURNEY_SORT_FIELD_VERDICT: Sort by verdict (nulls last). Known values are: - "SIMULATION_JOURNEY_SORT_FIELD_UNSPECIFIED", "SIMULATION_JOURNEY_SORT_FIELD_SCENARIO", - "SIMULATION_JOURNEY_SORT_FIELD_CREATED_AT", "SIMULATION_JOURNEY_SORT_FIELD_STATUS", and - "SIMULATION_JOURNEY_SORT_FIELD_VERDICT". Default value is - "SIMULATION_JOURNEY_SORT_FIELD_UNSPECIFIED". + * SIMULATION_EPISODE_SORT_FIELD_SCENARIO: Sort by scenario_uuid then episode_index. Default. + * SIMULATION_EPISODE_SORT_FIELD_CREATED_AT: Sort by creation date. + * SIMULATION_EPISODE_SORT_FIELD_STATUS: Sort by episode status using lifecycle order. + * SIMULATION_EPISODE_SORT_FIELD_VERDICT: Sort by verdict (nulls last). Known values are: + "SIMULATION_EPISODE_SORT_FIELD_UNSPECIFIED", "SIMULATION_EPISODE_SORT_FIELD_SCENARIO", + "SIMULATION_EPISODE_SORT_FIELD_CREATED_AT", "SIMULATION_EPISODE_SORT_FIELD_STATUS", and + "SIMULATION_EPISODE_SORT_FIELD_VERDICT". Default value is + "SIMULATION_EPISODE_SORT_FIELD_UNSPECIFIED". :paramtype sort_by: str :keyword sort_direction: Sort direction. Defaults to ascending when unspecified. Known values are: "SORT_DIRECTION_UNSPECIFIED", "SORT_DIRECTION_ASC", and "SORT_DIRECTION_DESC". Default @@ -313330,39 +321005,39 @@ def list_simulation_journeys( "str" # Optional. Verdicts available for filtering this list request. ], - "journeys": [ + "episodes": [ { "created_at": "2020-02-20 00:00:00", # Optional. Time created at. "duration_sec": "str", # Optional. Wall-clock time taken for - the journey to complete, in seconds. + the episode to complete, in seconds. + "episode_index": 0, # Optional. Zero-based index of this + episode within its scenario's exploration budget. + "episode_uuid": "str", # Optional. UUID of the episode. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journey_index": 0, # Optional. Zero-based index of this - journey within its scenario's exploration budget. - "journey_uuid": "str", # Optional. UUID of the journey. "judge_reasoning": "str", # Optional. Optional judge reasoning for the verdict. - "run_uuid": "str", # Optional. UUID of the run this journey + "run_uuid": "str", # Optional. UUID of the run this episode belongs to. "scenario_uuid": "str", # Optional. UUID of the scenario - this journey executed. + this episode executed. "session_id": "str", # Optional. Session identifier for this - journey. - "status": "SIMULATION_JOURNEY_STATUS_UNSPECIFIED", # - Optional. Default value is "SIMULATION_JOURNEY_STATUS_UNSPECIFIED". - Lifecycle status of a single journey. * - SIMULATION_JOURNEY_STATUS_RUNNING: The journey is executing and a + episode. + "status": "SIMULATION_EPISODE_STATUS_UNSPECIFIED", # + Optional. Default value is "SIMULATION_EPISODE_STATUS_UNSPECIFIED". + Lifecycle status of a single episode. * + SIMULATION_EPISODE_STATUS_RUNNING: The episode is executing and a trajectory is available to retrieve. * - SIMULATION_JOURNEY_STATUS_FINISHED: The journey reached a stop condition - and produced a verdict. * SIMULATION_JOURNEY_STATUS_FAILED: The journey + SIMULATION_EPISODE_STATUS_FINISHED: The episode reached a stop condition + and produced a verdict. * SIMULATION_EPISODE_STATUS_FAILED: The episode failed because of a cancel, timeout, or error. * - SIMULATION_JOURNEY_STATUS_PREPARING: The journey is allocated but its + SIMULATION_EPISODE_STATUS_PREPARING: The episode is allocated but its trajectory is not available yet. Known values are: - "SIMULATION_JOURNEY_STATUS_UNSPECIFIED", - "SIMULATION_JOURNEY_STATUS_RUNNING", - "SIMULATION_JOURNEY_STATUS_FINISHED", "SIMULATION_JOURNEY_STATUS_FAILED", - and "SIMULATION_JOURNEY_STATUS_PREPARING". + "SIMULATION_EPISODE_STATUS_UNSPECIFIED", + "SIMULATION_EPISODE_STATUS_RUNNING", + "SIMULATION_EPISODE_STATUS_FINISHED", "SIMULATION_EPISODE_STATUS_FAILED", + and "SIMULATION_EPISODE_STATUS_PREPARING". "token_usage": { "candidate_agent_tokens": "str", # Optional. Tokens consumed by the candidate agent. @@ -313376,25 +321051,25 @@ def list_simulation_journeys( across all actors. }, "trajectory_bucket_name": "str", # Optional. Object storage - bucket holding the trajectory JSON. Set when the journey finishes. + bucket holding the trajectory JSON. Set when the episode finishes. "trajectory_bucket_region": "str", # Optional. Object - storage bucket region for the trajectory JSON. Set when the journey + storage bucket region for the trajectory JSON. Set when the episode finishes. "trajectory_spaces_key": "str", # Optional. Object storage - key for the trajectory JSON. Set when the journey finishes. + key for the trajectory JSON. Set when the episode finishes. "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. - "verdict": "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED" # - Optional. Default value is "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED". The - judge's verdict for a journey. * SIMULATION_JOURNEY_VERDICT_SUCCESS: + "verdict": "SIMULATION_EPISODE_VERDICT_UNSPECIFIED" # + Optional. Default value is "SIMULATION_EPISODE_VERDICT_UNSPECIFIED". The + judge's verdict for an episode. * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. * - SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy - the stopping criteria. * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No + SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy + the stopping criteria. * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). - Known values are: "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED", - "SIMULATION_JOURNEY_VERDICT_SUCCESS", - "SIMULATION_JOURNEY_VERDICT_FAILURE", and - "SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE". + Known values are: "SIMULATION_EPISODE_VERDICT_UNSPECIFIED", + "SIMULATION_EPISODE_VERDICT_SUCCESS", + "SIMULATION_EPISODE_VERDICT_FAILURE", and + "SIMULATION_EPISODE_VERDICT_INCONCLUSIVE". } ], "links": { @@ -313441,7 +321116,7 @@ def list_simulation_journeys( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_genai_list_simulation_journeys_request( + _request = build_genai_list_simulation_episodes_request( run_uuid=run_uuid, scenario_uuid=scenario_uuid, page=page, @@ -313510,19 +321185,19 @@ def list_simulation_journeys( return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_simulation_journey( - self, run_uuid: str, journey_uuid: str, **kwargs: Any + def get_simulation_episode( + self, run_uuid: str, episode_uuid: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Retrieve Simulation Journey. + """Retrieve Simulation Episode. - To retrieve a single journey, send a GET request to - ``/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}``. + To retrieve a single episode, send a GET request to + ``/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}``. - :param run_uuid: UUID of the run the journey belongs to. Required. + :param run_uuid: UUID of the run the episode belongs to. Required. :type run_uuid: str - :param journey_uuid: UUID of the journey. Required. - :type journey_uuid: str + :param episode_uuid: UUID of the episode. Required. + :type episode_uuid: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -313532,35 +321207,35 @@ def get_simulation_journey( # response body for status code(s): 200 response == { - "journey": { + "episode": { "created_at": "2020-02-20 00:00:00", # Optional. Time created at. "duration_sec": "str", # Optional. Wall-clock time taken for the - journey to complete, in seconds. + episode to complete, in seconds. + "episode_index": 0, # Optional. Zero-based index of this episode + within its scenario's exploration budget. + "episode_uuid": "str", # Optional. UUID of the episode. "failure_reason": "str", # Optional. Human-readable explanation of a terminal FAILED status. Empty otherwise. - "journey_index": 0, # Optional. Zero-based index of this journey - within its scenario's exploration budget. - "journey_uuid": "str", # Optional. UUID of the journey. "judge_reasoning": "str", # Optional. Optional judge reasoning for the verdict. - "run_uuid": "str", # Optional. UUID of the run this journey belongs + "run_uuid": "str", # Optional. UUID of the run this episode belongs to. "scenario_uuid": "str", # Optional. UUID of the scenario this - journey executed. + episode executed. "session_id": "str", # Optional. Session identifier for this - journey. - "status": "SIMULATION_JOURNEY_STATUS_UNSPECIFIED", # Optional. - Default value is "SIMULATION_JOURNEY_STATUS_UNSPECIFIED". Lifecycle status of - a single journey. * SIMULATION_JOURNEY_STATUS_RUNNING: The journey is + episode. + "status": "SIMULATION_EPISODE_STATUS_UNSPECIFIED", # Optional. + Default value is "SIMULATION_EPISODE_STATUS_UNSPECIFIED". Lifecycle status of + a single episode. * SIMULATION_EPISODE_STATUS_RUNNING: The episode is executing and a trajectory is available to retrieve. * - SIMULATION_JOURNEY_STATUS_FINISHED: The journey reached a stop condition and - produced a verdict. * SIMULATION_JOURNEY_STATUS_FAILED: The journey failed + SIMULATION_EPISODE_STATUS_FINISHED: The episode reached a stop condition and + produced a verdict. * SIMULATION_EPISODE_STATUS_FAILED: The episode failed because of a cancel, timeout, or error. * - SIMULATION_JOURNEY_STATUS_PREPARING: The journey is allocated but its + SIMULATION_EPISODE_STATUS_PREPARING: The episode is allocated but its trajectory is not available yet. Known values are: - "SIMULATION_JOURNEY_STATUS_UNSPECIFIED", "SIMULATION_JOURNEY_STATUS_RUNNING", - "SIMULATION_JOURNEY_STATUS_FINISHED", "SIMULATION_JOURNEY_STATUS_FAILED", and - "SIMULATION_JOURNEY_STATUS_PREPARING". + "SIMULATION_EPISODE_STATUS_UNSPECIFIED", "SIMULATION_EPISODE_STATUS_RUNNING", + "SIMULATION_EPISODE_STATUS_FINISHED", "SIMULATION_EPISODE_STATUS_FAILED", and + "SIMULATION_EPISODE_STATUS_PREPARING". "token_usage": { "candidate_agent_tokens": "str", # Optional. Tokens consumed by the candidate agent. @@ -313574,23 +321249,23 @@ def get_simulation_journey( actors. }, "trajectory_bucket_name": "str", # Optional. Object storage bucket - holding the trajectory JSON. Set when the journey finishes. + holding the trajectory JSON. Set when the episode finishes. "trajectory_bucket_region": "str", # Optional. Object storage bucket - region for the trajectory JSON. Set when the journey finishes. + region for the trajectory JSON. Set when the episode finishes. "trajectory_spaces_key": "str", # Optional. Object storage key for - the trajectory JSON. Set when the journey finishes. + the trajectory JSON. Set when the episode finishes. "updated_at": "2020-02-20 00:00:00", # Optional. Time last updated at. - "verdict": "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED" # Optional. - Default value is "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED". The judge's - verdict for a journey. * SIMULATION_JOURNEY_VERDICT_SUCCESS: The candidate + "verdict": "SIMULATION_EPISODE_VERDICT_UNSPECIFIED" # Optional. + Default value is "SIMULATION_EPISODE_VERDICT_UNSPECIFIED". The judge's + verdict for an episode. * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. * - SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy the - stopping criteria. * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No conclusive + SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy the + stopping criteria. * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). Known values - are: "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED", - "SIMULATION_JOURNEY_VERDICT_SUCCESS", "SIMULATION_JOURNEY_VERDICT_FAILURE", - and "SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE". + are: "SIMULATION_EPISODE_VERDICT_UNSPECIFIED", + "SIMULATION_EPISODE_VERDICT_SUCCESS", "SIMULATION_EPISODE_VERDICT_FAILURE", + and "SIMULATION_EPISODE_VERDICT_INCONCLUSIVE". } } # response body for status code(s): 404 @@ -313623,9 +321298,9 @@ def get_simulation_journey( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_genai_get_simulation_journey_request( + _request = build_genai_get_simulation_episode_request( run_uuid=run_uuid, - journey_uuid=journey_uuid, + episode_uuid=episode_uuid, headers=_headers, params=_params, ) @@ -313685,20 +321360,20 @@ def get_simulation_journey( return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_simulation_journey_trajectory( - self, run_uuid: str, journey_uuid: str, **kwargs: Any + def get_simulation_episode_trajectory( + self, run_uuid: str, episode_uuid: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Retrieve Journey Trajectory. + """Retrieve Episode Trajectory. - To retrieve a journey's live trajectory, send a GET request to - ``/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}/trajectory``. Poll while the - journey is running to watch turn-by-turn progress. + To retrieve an episode's live trajectory, send a GET request to + ``/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}/trajectory``. Poll while the + episode is running to watch turn-by-turn progress. - :param run_uuid: UUID of the run the journey belongs to. Required. + :param run_uuid: UUID of the run the episode belongs to. Required. :type run_uuid: str - :param journey_uuid: UUID of the journey. Required. - :type journey_uuid: str + :param episode_uuid: UUID of the episode. Required. + :type episode_uuid: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -313710,12 +321385,18 @@ def get_simulation_journey_trajectory( response == { "trajectory": { "agent_id": "str", # Optional. Identifier of the candidate agent - under test for this journey. + under test for this episode. "completed_at": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "duration_sec": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live + progress. + "episode_index": 0, # Optional. Turn-by-turn trajectory for one + episode. Poll this resource while the episode is running to watch live + progress. + "episode_uuid": "str", # Optional. Turn-by-turn trajectory for one + episode. Poll this resource while the episode is running to watch live progress. "evaluation_metrics": [ { @@ -313746,13 +321427,7 @@ def get_simulation_journey_trajectory( } ], "failure_reason": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live - progress. - "journey_index": 0, # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live - progress. - "journey_uuid": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "judge": { "criteria_pass_fail": [ @@ -313767,19 +321442,19 @@ def get_simulation_journey_trajectory( ], "reasoning": "str", # Optional. Judge output embedded in the trajectory JSON. - "verdict": "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED" # - Optional. Default value is "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED". The - judge's verdict for a journey. * SIMULATION_JOURNEY_VERDICT_SUCCESS: + "verdict": "SIMULATION_EPISODE_VERDICT_UNSPECIFIED" # + Optional. Default value is "SIMULATION_EPISODE_VERDICT_UNSPECIFIED". The + judge's verdict for an episode. * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. * - SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy - the stopping criteria. * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No + SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy + the stopping criteria. * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). - Known values are: "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED", - "SIMULATION_JOURNEY_VERDICT_SUCCESS", - "SIMULATION_JOURNEY_VERDICT_FAILURE", and - "SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE". + Known values are: "SIMULATION_EPISODE_VERDICT_UNSPECIFIED", + "SIMULATION_EPISODE_VERDICT_SUCCESS", + "SIMULATION_EPISODE_VERDICT_FAILURE", and + "SIMULATION_EPISODE_VERDICT_INCONCLUSIVE". }, - "max_turns": 0, # Optional. Turn budget configured for this journey + "max_turns": 0, # Optional. Turn budget configured for this episode (per-scenario max_turns, after any run-level override). Compare with turn_count to see how many of the budgeted turns actually ran. "messages": [ @@ -313818,26 +321493,26 @@ def get_simulation_journey_trajectory( } ], "run_uuid": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "scenario_uuid": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "session_id": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "started_at": "str", # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. "status": "SIMULATION_TRAJECTORY_STATUS_UNSPECIFIED", # Optional. Default value is "SIMULATION_TRAJECTORY_STATUS_UNSPECIFIED". Lifecycle status - of the trajectory. Distinct from journey status: the trajectory is updated on - every turn while the journey is executing. * - SIMULATION_TRAJECTORY_STATUS_RUNNING: The journey loop is in progress; + of the trajectory. Distinct from episode status: the trajectory is updated on + every turn while the episode is executing. * + SIMULATION_TRAJECTORY_STATUS_RUNNING: The episode loop is in progress; messages may grow on each poll. * SIMULATION_TRAJECTORY_STATUS_COMPLETED: The - journey reached a stop condition and the trajectory is complete. * - SIMULATION_TRAJECTORY_STATUS_FAILED: The journey failed before or during - execution. * SIMULATION_TRAJECTORY_STATUS_CANCELLED: The journey was + episode reached a stop condition and the trajectory is complete. * + SIMULATION_TRAJECTORY_STATUS_FAILED: The episode failed before or during + execution. * SIMULATION_TRAJECTORY_STATUS_CANCELLED: The episode was cancelled. Known values are: "SIMULATION_TRAJECTORY_STATUS_UNSPECIFIED", "SIMULATION_TRAJECTORY_STATUS_RUNNING", "SIMULATION_TRAJECTORY_STATUS_COMPLETED", @@ -313856,18 +321531,18 @@ def get_simulation_journey_trajectory( actors. }, "turn_count": 0, # Optional. Turn-by-turn trajectory for one - journey. Poll this resource while the journey is running to watch live + episode. Poll this resource while the episode is running to watch live progress. - "verdict": "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED" # Optional. - Default value is "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED". The judge's - verdict for a journey. * SIMULATION_JOURNEY_VERDICT_SUCCESS: The candidate + "verdict": "SIMULATION_EPISODE_VERDICT_UNSPECIFIED" # Optional. + Default value is "SIMULATION_EPISODE_VERDICT_UNSPECIFIED". The judge's + verdict for an episode. * SIMULATION_EPISODE_VERDICT_SUCCESS: The candidate agent satisfied the scenario's stopping criteria. * - SIMULATION_JOURNEY_VERDICT_FAILURE: The candidate agent did not satisfy the - stopping criteria. * SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE: No conclusive + SIMULATION_EPISODE_VERDICT_FAILURE: The candidate agent did not satisfy the + stopping criteria. * SIMULATION_EPISODE_VERDICT_INCONCLUSIVE: No conclusive verdict (e.g. max_turns reached without the judge finishing). Known values - are: "SIMULATION_JOURNEY_VERDICT_UNSPECIFIED", - "SIMULATION_JOURNEY_VERDICT_SUCCESS", "SIMULATION_JOURNEY_VERDICT_FAILURE", - and "SIMULATION_JOURNEY_VERDICT_INCONCLUSIVE". + are: "SIMULATION_EPISODE_VERDICT_UNSPECIFIED", + "SIMULATION_EPISODE_VERDICT_SUCCESS", "SIMULATION_EPISODE_VERDICT_FAILURE", + and "SIMULATION_EPISODE_VERDICT_INCONCLUSIVE". } } # response body for status code(s): 404 @@ -313900,9 +321575,9 @@ def get_simulation_journey_trajectory( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_genai_get_simulation_journey_trajectory_request( + _request = build_genai_get_simulation_episode_trajectory_request( run_uuid=run_uuid, - journey_uuid=journey_uuid, + episode_uuid=episode_uuid, headers=_headers, params=_params, ) @@ -313962,19 +321637,19 @@ def get_simulation_journey_trajectory( return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_simulation_journey_trajectory_url( - self, run_uuid: str, journey_uuid: str, **kwargs: Any + def get_simulation_episode_trajectory_url( + self, run_uuid: str, episode_uuid: str, **kwargs: Any ) -> JSON: # pylint: disable=line-too-long - """Retrieve Journey Trajectory Download URL. + """Retrieve Episode Trajectory Download URL. - To retrieve a presigned download URL for a journey's trajectory, send a GET request to - ``/v2/gen-ai/simulation_runs/{run_uuid}/journeys/{journey_uuid}/trajectory_url``. + To retrieve a presigned download URL for an episode's trajectory, send a GET request to + ``/v2/gen-ai/simulation_runs/{run_uuid}/episodes/{episode_uuid}/trajectory_url``. - :param run_uuid: UUID of the run the journey belongs to. Required. + :param run_uuid: UUID of the run the episode belongs to. Required. :type run_uuid: str - :param journey_uuid: UUID of the journey. Required. - :type journey_uuid: str + :param episode_uuid: UUID of the episode. Required. + :type episode_uuid: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -314018,9 +321693,9 @@ def get_simulation_journey_trajectory_url( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_genai_get_simulation_journey_trajectory_url_request( + _request = build_genai_get_simulation_episode_trajectory_url_request( run_uuid=run_uuid, - journey_uuid=journey_uuid, + episode_uuid=episode_uuid, headers=_headers, params=_params, )