Skip to content

Commit 3aaae61

Browse files
feat(cloud): add update method to GPU Baremetal clusters
1 parent 36fef30 commit 3aaae61

File tree

6 files changed

+343
-3
lines changed

6 files changed

+343
-3
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 646
1+
configured_endpoints: 647
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore%2Fgcore-2482396a183d8700e3679fec5090d194f9d67113e907e6504934c08cc52f2f91.yml
33
openapi_spec_hash: 587bdc6b89167a5a1305332ec9d4565c
4-
config_hash: 679c55ab9eac10ef2e9c4974f904978e
4+
config_hash: a4c3f3f2864f6fd064ca57b691e73958

src/gcore/resources/cloud/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@ from gcore.types.cloud.gpu_baremetal import GPUBaremetalCluster
786786
Methods:
787787

788788
- <code title="post /cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters">client.cloud.gpu_baremetal.clusters.<a href="./src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py">create</a>(\*, project_id, region_id, \*\*<a href="src/gcore/types/cloud/gpu_baremetal/cluster_create_params.py">params</a>) -> <a href="./src/gcore/types/cloud/task_id_list.py">TaskIDList</a></code>
789+
- <code title="patch /cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters/{cluster_id}">client.cloud.gpu_baremetal.clusters.<a href="./src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py">update</a>(cluster_id, \*, project_id, region_id, \*\*<a href="src/gcore/types/cloud/gpu_baremetal/cluster_update_params.py">params</a>) -> <a href="./src/gcore/types/cloud/gpu_baremetal/gpu_baremetal_cluster.py">GPUBaremetalCluster</a></code>
789790
- <code title="get /cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters">client.cloud.gpu_baremetal.clusters.<a href="./src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py">list</a>(\*, project_id, region_id, \*\*<a href="src/gcore/types/cloud/gpu_baremetal/cluster_list_params.py">params</a>) -> <a href="./src/gcore/types/cloud/gpu_baremetal/gpu_baremetal_cluster.py">SyncOffsetPage[GPUBaremetalCluster]</a></code>
790791
- <code title="delete /cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters/{cluster_id}">client.cloud.gpu_baremetal.clusters.<a href="./src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py">delete</a>(cluster_id, \*, project_id, region_id, \*\*<a href="src/gcore/types/cloud/gpu_baremetal/cluster_delete_params.py">params</a>) -> <a href="./src/gcore/types/cloud/task_id_list.py">TaskIDList</a></code>
791792
- <code title="get /cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters/{cluster_id}">client.cloud.gpu_baremetal.clusters.<a href="./src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py">get</a>(cluster_id, \*, project_id, region_id) -> <a href="./src/gcore/types/cloud/gpu_baremetal/gpu_baremetal_cluster.py">GPUBaremetalCluster</a></code>

src/gcore/resources/cloud/gpu_baremetal/clusters/clusters.py

Lines changed: 179 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List
5+
from typing import Dict, List, Optional
66
from typing_extensions import Literal
77

88
import httpx
@@ -57,8 +57,10 @@
5757
cluster_create_params,
5858
cluster_delete_params,
5959
cluster_resize_params,
60+
cluster_update_params,
6061
cluster_update_servers_settings_params,
6162
)
63+
from .....types.cloud.tag_update_map_param import TagUpdateMapParam
6264
from .....types.cloud.gpu_baremetal.gpu_baremetal_cluster import GPUBaremetalCluster
6365
from .....types.cloud.gpu_baremetal.clusters.gpu_baremetal_cluster_server_v1_list import GPUBaremetalClusterServerV1List
6466

@@ -176,6 +178,88 @@ def create(
176178
cast_to=TaskIDList,
177179
)
178180

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+
179263
def list(
180264
self,
181265
*,
@@ -862,6 +946,88 @@ async def create(
862946
cast_to=TaskIDList,
863947
)
864948

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+
8651031
def list(
8661032
self,
8671033
*,
@@ -1446,6 +1612,9 @@ def __init__(self, clusters: ClustersResource) -> None:
14461612
self.create = to_raw_response_wrapper(
14471613
clusters.create,
14481614
)
1615+
self.update = to_raw_response_wrapper(
1616+
clusters.update,
1617+
)
14491618
self.list = to_raw_response_wrapper(
14501619
clusters.list,
14511620
)
@@ -1505,6 +1674,9 @@ def __init__(self, clusters: AsyncClustersResource) -> None:
15051674
self.create = async_to_raw_response_wrapper(
15061675
clusters.create,
15071676
)
1677+
self.update = async_to_raw_response_wrapper(
1678+
clusters.update,
1679+
)
15081680
self.list = async_to_raw_response_wrapper(
15091681
clusters.list,
15101682
)
@@ -1564,6 +1736,9 @@ def __init__(self, clusters: ClustersResource) -> None:
15641736
self.create = to_streamed_response_wrapper(
15651737
clusters.create,
15661738
)
1739+
self.update = to_streamed_response_wrapper(
1740+
clusters.update,
1741+
)
15671742
self.list = to_streamed_response_wrapper(
15681743
clusters.list,
15691744
)
@@ -1623,6 +1798,9 @@ def __init__(self, clusters: AsyncClustersResource) -> None:
16231798
self.create = async_to_streamed_response_wrapper(
16241799
clusters.create,
16251800
)
1801+
self.update = async_to_streamed_response_wrapper(
1802+
clusters.update,
1803+
)
16261804
self.list = async_to_streamed_response_wrapper(
16271805
clusters.list,
16281806
)

src/gcore/types/cloud/gpu_baremetal/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .cluster_create_params import ClusterCreateParams as ClusterCreateParams
77
from .cluster_delete_params import ClusterDeleteParams as ClusterDeleteParams
88
from .cluster_resize_params import ClusterResizeParams as ClusterResizeParams
9+
from .cluster_update_params import ClusterUpdateParams as ClusterUpdateParams
910
from .gpu_baremetal_cluster import GPUBaremetalCluster as GPUBaremetalCluster
1011
from .cluster_update_servers_settings_params import (
1112
ClusterUpdateServersSettingsParams as ClusterUpdateServersSettingsParams,
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import TypedDict
7+
8+
from ..tag_update_map_param import TagUpdateMapParam
9+
10+
__all__ = ["ClusterUpdateParams"]
11+
12+
13+
class ClusterUpdateParams(TypedDict, total=False):
14+
project_id: int
15+
"""Project ID"""
16+
17+
region_id: int
18+
"""Region ID"""
19+
20+
name: str
21+
"""Cluster name"""
22+
23+
tags: Optional[TagUpdateMapParam]
24+
"""Update key-value tags using JSON Merge Patch semantics (RFC 7386).
25+
26+
Provide key-value pairs to add or update tags. Set tag values to `null` to
27+
remove tags. Unspecified tags remain unchanged. Read-only tags are always
28+
preserved and cannot be modified.
29+
30+
**Examples:**
31+
32+
- **Add/update tags:**
33+
`{'tags': {'environment': 'production', 'team': 'backend'}}` adds new tags or
34+
updates existing ones.
35+
- **Delete tags:** `{'tags': {'old_tag': null}}` removes specific tags.
36+
- **Remove all tags:** `{'tags': null}` removes all user-managed tags (read-only
37+
tags are preserved).
38+
- **Partial update:** `{'tags': {'environment': 'staging'}}` only updates
39+
specified tags.
40+
- **Mixed operations:**
41+
`{'tags': {'environment': 'production', 'cost_center': 'engineering', 'deprecated_tag': null}}`
42+
adds/updates 'environment' and 'cost_center' while removing 'deprecated_tag',
43+
preserving other existing tags.
44+
- **Replace all:** first delete existing tags with null values, then add new
45+
ones in the same request.
46+
"""

0 commit comments

Comments
 (0)