|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing import Dict, List |
| 5 | +from typing import Dict, List, Optional |
6 | 6 | from typing_extensions import Literal |
7 | 7 |
|
8 | 8 | import httpx |
|
57 | 57 | cluster_create_params, |
58 | 58 | cluster_delete_params, |
59 | 59 | cluster_resize_params, |
| 60 | + cluster_update_params, |
60 | 61 | cluster_update_servers_settings_params, |
61 | 62 | ) |
| 63 | +from .....types.cloud.tag_update_map_param import TagUpdateMapParam |
62 | 64 | from .....types.cloud.gpu_baremetal.gpu_baremetal_cluster import GPUBaremetalCluster |
63 | 65 | from .....types.cloud.gpu_baremetal.clusters.gpu_baremetal_cluster_server_v1_list import GPUBaremetalClusterServerV1List |
64 | 66 |
|
@@ -176,6 +178,88 @@ def create( |
176 | 178 | cast_to=TaskIDList, |
177 | 179 | ) |
178 | 180 |
|
| 181 | + def update( |
| 182 | + self, |
| 183 | + cluster_id: str, |
| 184 | + *, |
| 185 | + project_id: int | None = None, |
| 186 | + region_id: int | None = None, |
| 187 | + name: str | Omit = omit, |
| 188 | + tags: Optional[TagUpdateMapParam] | Omit = omit, |
| 189 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 190 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 191 | + extra_headers: Headers | None = None, |
| 192 | + extra_query: Query | None = None, |
| 193 | + extra_body: Body | None = None, |
| 194 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 195 | + ) -> GPUBaremetalCluster: |
| 196 | + """ |
| 197 | + Update the name of an existing bare metal GPU cluster. |
| 198 | +
|
| 199 | + Update tags for a bare metal GPU cluster (and apply to all its nodes) using JSON |
| 200 | + Merge Patch semantics (RFC 7386). To add or update tags, provide key-value |
| 201 | + pairs. To remove a tag, set its value to null. |
| 202 | +
|
| 203 | + Args: |
| 204 | + project_id: Project ID |
| 205 | +
|
| 206 | + region_id: Region ID |
| 207 | +
|
| 208 | + cluster_id: Cluster unique identifier |
| 209 | +
|
| 210 | + name: Cluster name |
| 211 | +
|
| 212 | + tags: Update key-value tags using JSON Merge Patch semantics (RFC 7386). Provide |
| 213 | + key-value pairs to add or update tags. Set tag values to `null` to remove tags. |
| 214 | + Unspecified tags remain unchanged. Read-only tags are always preserved and |
| 215 | + cannot be modified. |
| 216 | +
|
| 217 | + **Examples:** |
| 218 | +
|
| 219 | + - **Add/update tags:** |
| 220 | + `{'tags': {'environment': 'production', 'team': 'backend'}}` adds new tags or |
| 221 | + updates existing ones. |
| 222 | + - **Delete tags:** `{'tags': {'old_tag': null}}` removes specific tags. |
| 223 | + - **Remove all tags:** `{'tags': null}` removes all user-managed tags (read-only |
| 224 | + tags are preserved). |
| 225 | + - **Partial update:** `{'tags': {'environment': 'staging'}}` only updates |
| 226 | + specified tags. |
| 227 | + - **Mixed operations:** |
| 228 | + `{'tags': {'environment': 'production', 'cost_center': 'engineering', 'deprecated_tag': null}}` |
| 229 | + adds/updates 'environment' and 'cost_center' while removing 'deprecated_tag', |
| 230 | + preserving other existing tags. |
| 231 | + - **Replace all:** first delete existing tags with null values, then add new |
| 232 | + ones in the same request. |
| 233 | +
|
| 234 | + extra_headers: Send extra headers |
| 235 | +
|
| 236 | + extra_query: Add additional query parameters to the request |
| 237 | +
|
| 238 | + extra_body: Add additional JSON properties to the request |
| 239 | +
|
| 240 | + timeout: Override the client-level default timeout for this request, in seconds |
| 241 | + """ |
| 242 | + if project_id is None: |
| 243 | + project_id = self._client._get_cloud_project_id_path_param() |
| 244 | + if region_id is None: |
| 245 | + region_id = self._client._get_cloud_region_id_path_param() |
| 246 | + if not cluster_id: |
| 247 | + raise ValueError(f"Expected a non-empty value for `cluster_id` but received {cluster_id!r}") |
| 248 | + return self._patch( |
| 249 | + f"/cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters/{cluster_id}", |
| 250 | + body=maybe_transform( |
| 251 | + { |
| 252 | + "name": name, |
| 253 | + "tags": tags, |
| 254 | + }, |
| 255 | + cluster_update_params.ClusterUpdateParams, |
| 256 | + ), |
| 257 | + options=make_request_options( |
| 258 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 259 | + ), |
| 260 | + cast_to=GPUBaremetalCluster, |
| 261 | + ) |
| 262 | + |
179 | 263 | def list( |
180 | 264 | self, |
181 | 265 | *, |
@@ -862,6 +946,88 @@ async def create( |
862 | 946 | cast_to=TaskIDList, |
863 | 947 | ) |
864 | 948 |
|
| 949 | + async def update( |
| 950 | + self, |
| 951 | + cluster_id: str, |
| 952 | + *, |
| 953 | + project_id: int | None = None, |
| 954 | + region_id: int | None = None, |
| 955 | + name: str | Omit = omit, |
| 956 | + tags: Optional[TagUpdateMapParam] | Omit = omit, |
| 957 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 958 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 959 | + extra_headers: Headers | None = None, |
| 960 | + extra_query: Query | None = None, |
| 961 | + extra_body: Body | None = None, |
| 962 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 963 | + ) -> GPUBaremetalCluster: |
| 964 | + """ |
| 965 | + Update the name of an existing bare metal GPU cluster. |
| 966 | +
|
| 967 | + Update tags for a bare metal GPU cluster (and apply to all its nodes) using JSON |
| 968 | + Merge Patch semantics (RFC 7386). To add or update tags, provide key-value |
| 969 | + pairs. To remove a tag, set its value to null. |
| 970 | +
|
| 971 | + Args: |
| 972 | + project_id: Project ID |
| 973 | +
|
| 974 | + region_id: Region ID |
| 975 | +
|
| 976 | + cluster_id: Cluster unique identifier |
| 977 | +
|
| 978 | + name: Cluster name |
| 979 | +
|
| 980 | + tags: Update key-value tags using JSON Merge Patch semantics (RFC 7386). Provide |
| 981 | + key-value pairs to add or update tags. Set tag values to `null` to remove tags. |
| 982 | + Unspecified tags remain unchanged. Read-only tags are always preserved and |
| 983 | + cannot be modified. |
| 984 | +
|
| 985 | + **Examples:** |
| 986 | +
|
| 987 | + - **Add/update tags:** |
| 988 | + `{'tags': {'environment': 'production', 'team': 'backend'}}` adds new tags or |
| 989 | + updates existing ones. |
| 990 | + - **Delete tags:** `{'tags': {'old_tag': null}}` removes specific tags. |
| 991 | + - **Remove all tags:** `{'tags': null}` removes all user-managed tags (read-only |
| 992 | + tags are preserved). |
| 993 | + - **Partial update:** `{'tags': {'environment': 'staging'}}` only updates |
| 994 | + specified tags. |
| 995 | + - **Mixed operations:** |
| 996 | + `{'tags': {'environment': 'production', 'cost_center': 'engineering', 'deprecated_tag': null}}` |
| 997 | + adds/updates 'environment' and 'cost_center' while removing 'deprecated_tag', |
| 998 | + preserving other existing tags. |
| 999 | + - **Replace all:** first delete existing tags with null values, then add new |
| 1000 | + ones in the same request. |
| 1001 | +
|
| 1002 | + extra_headers: Send extra headers |
| 1003 | +
|
| 1004 | + extra_query: Add additional query parameters to the request |
| 1005 | +
|
| 1006 | + extra_body: Add additional JSON properties to the request |
| 1007 | +
|
| 1008 | + timeout: Override the client-level default timeout for this request, in seconds |
| 1009 | + """ |
| 1010 | + if project_id is None: |
| 1011 | + project_id = self._client._get_cloud_project_id_path_param() |
| 1012 | + if region_id is None: |
| 1013 | + region_id = self._client._get_cloud_region_id_path_param() |
| 1014 | + if not cluster_id: |
| 1015 | + raise ValueError(f"Expected a non-empty value for `cluster_id` but received {cluster_id!r}") |
| 1016 | + return await self._patch( |
| 1017 | + f"/cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters/{cluster_id}", |
| 1018 | + body=await async_maybe_transform( |
| 1019 | + { |
| 1020 | + "name": name, |
| 1021 | + "tags": tags, |
| 1022 | + }, |
| 1023 | + cluster_update_params.ClusterUpdateParams, |
| 1024 | + ), |
| 1025 | + options=make_request_options( |
| 1026 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1027 | + ), |
| 1028 | + cast_to=GPUBaremetalCluster, |
| 1029 | + ) |
| 1030 | + |
865 | 1031 | def list( |
866 | 1032 | self, |
867 | 1033 | *, |
@@ -1446,6 +1612,9 @@ def __init__(self, clusters: ClustersResource) -> None: |
1446 | 1612 | self.create = to_raw_response_wrapper( |
1447 | 1613 | clusters.create, |
1448 | 1614 | ) |
| 1615 | + self.update = to_raw_response_wrapper( |
| 1616 | + clusters.update, |
| 1617 | + ) |
1449 | 1618 | self.list = to_raw_response_wrapper( |
1450 | 1619 | clusters.list, |
1451 | 1620 | ) |
@@ -1505,6 +1674,9 @@ def __init__(self, clusters: AsyncClustersResource) -> None: |
1505 | 1674 | self.create = async_to_raw_response_wrapper( |
1506 | 1675 | clusters.create, |
1507 | 1676 | ) |
| 1677 | + self.update = async_to_raw_response_wrapper( |
| 1678 | + clusters.update, |
| 1679 | + ) |
1508 | 1680 | self.list = async_to_raw_response_wrapper( |
1509 | 1681 | clusters.list, |
1510 | 1682 | ) |
@@ -1564,6 +1736,9 @@ def __init__(self, clusters: ClustersResource) -> None: |
1564 | 1736 | self.create = to_streamed_response_wrapper( |
1565 | 1737 | clusters.create, |
1566 | 1738 | ) |
| 1739 | + self.update = to_streamed_response_wrapper( |
| 1740 | + clusters.update, |
| 1741 | + ) |
1567 | 1742 | self.list = to_streamed_response_wrapper( |
1568 | 1743 | clusters.list, |
1569 | 1744 | ) |
@@ -1623,6 +1798,9 @@ def __init__(self, clusters: AsyncClustersResource) -> None: |
1623 | 1798 | self.create = async_to_streamed_response_wrapper( |
1624 | 1799 | clusters.create, |
1625 | 1800 | ) |
| 1801 | + self.update = async_to_streamed_response_wrapper( |
| 1802 | + clusters.update, |
| 1803 | + ) |
1626 | 1804 | self.list = async_to_streamed_response_wrapper( |
1627 | 1805 | clusters.list, |
1628 | 1806 | ) |
|
0 commit comments