diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e45725824..b8e657cc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/gcore-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Install Rye run: | @@ -46,7 +46,7 @@ jobs: id-token: write runs-on: ${{ github.repository == 'stainless-sdks/gcore-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Install Rye run: | @@ -67,7 +67,7 @@ jobs: github.repository == 'stainless-sdks/gcore-python' && !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v8 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); @@ -87,7 +87,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/gcore-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Install Rye run: | diff --git a/.github/workflows/detect-breaking-changes.yml b/.github/workflows/detect-breaking-changes.yml index ffca94ccf..84c5c1f6f 100644 --- a/.github/workflows/detect-breaking-changes.yml +++ b/.github/workflows/detect-breaking-changes.yml @@ -15,7 +15,7 @@ jobs: run: | echo "FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_ENV - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: # Ensure we can check out the pull request base in the script below. fetch-depth: ${{ env.FETCH_DEPTH }} diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 3cebca635..6f70ab685 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Install Rye run: | diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 927bb62ab..4663d865c 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'G-Core/gcore-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 563004f25..141e7cde8 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.46.0" + ".": "0.47.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 6f7725913..1edf33e53 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 658 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore/gcore-b3b1edc1075e6806e861cbcbd8f5a21f5aa1d520d1762d3005ad1ed6d2b378ec.yml -openapi_spec_hash: c1afaa5644fd940d6fe865733ae90a22 -config_hash: 0ecd0c790249a8eaac3965931f0f239e +configured_endpoints: 659 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gcore/gcore-57ddb0cb059d0bfb72681af53e70b8d96d23df71025efbed5ff895949191e09a.yml +openapi_spec_hash: 56b7f9ac85a32a2db9de669906c2de81 +config_hash: dfd7c029cbc3fb95b9fd5a3df7df1535 diff --git a/CHANGELOG.md b/CHANGELOG.md index 585c61277..ed9125b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 0.47.0 (2026-05-19) + +Full Changelog: [v0.46.0...v0.47.0](https://github.com/G-Core/gcore-python/compare/v0.46.0...v0.47.0) + +### Features + +* **api:** aggregated API specs update ([8c92d60](https://github.com/G-Core/gcore-python/commit/8c92d60aaeeeab24ede694117c8520b65346b1e4)) +* **cloud:** add example for replacing a GPU baremetal cluster server ([0b15bb0](https://github.com/G-Core/gcore-python/commit/0b15bb0b27d85a0d77f49a39d654b85f13817ab3)) +* **cloud:** add replace method for GPU baremetal cluster server ([302f52d](https://github.com/G-Core/gcore-python/commit/302f52da91a594ac0f2864be2a26e60145b8d64e)) +* **cloud:** add replace_and_poll and rebuild_and_poll for GPU baremetal cluster server ([119f015](https://github.com/G-Core/gcore-python/commit/119f015621f6666fc32f7e852aba1c92519447bd)) +* **internal/types:** support eagerly validating pydantic iterators ([8aa6320](https://github.com/G-Core/gcore-python/commit/8aa6320c91817c960e240259b29def9df3aac25a)) +* **storage:** support storage access keys resource in Terraform ([0b20d58](https://github.com/G-Core/gcore-python/commit/0b20d58d57e60dd249adbe0445022b59fab4ff3a)) +* **storage:** support TF for buckets ([6c7c89f](https://github.com/G-Core/gcore-python/commit/6c7c89f361acf3ac573f9a141c6ac3289fc245fb)) +* **storage:** support TF for object storages ([2a09961](https://github.com/G-Core/gcore-python/commit/2a09961a087b8c8b5942d6944f5a6399bc60f2ad)) + ## 0.46.0 (2026-05-11) Full Changelog: [v0.45.0...v0.46.0](https://github.com/G-Core/gcore-python/compare/v0.45.0...v0.46.0) diff --git a/examples/cloud/gpu_baremetal_clusters.py b/examples/cloud/gpu_baremetal_clusters.py index ebb276cb3..3f9c4e1ff 100644 --- a/examples/cloud/gpu_baremetal_clusters.py +++ b/examples/cloud/gpu_baremetal_clusters.py @@ -9,6 +9,7 @@ ) from gcore.types.cloud.gpu_baremetal.gpu_baremetal_cluster import GPUBaremetalCluster from gcore.types.cloud.gpu_baremetal.clusters.gpu_baremetal_flavor import GPUBaremetalFlavor +from gcore.types.cloud.gpu_baremetal.clusters.gpu_baremetal_cluster_server import GPUBaremetalClusterServer def main() -> None: @@ -44,7 +45,10 @@ def main() -> None: list_interfaces(client=gcore, cluster_id=cluster.id) # Servers - list_servers(client=gcore, cluster_id=cluster.id) + servers = list_servers(client=gcore, cluster_id=cluster.id) + if servers: + rebuild_server(client=gcore, cluster_id=cluster.id, server_id=servers[0].id) + replace_server(client=gcore, cluster_id=cluster.id, server_id=servers[0].id) # Delete delete_cluster(client=gcore, cluster_id=cluster.id) @@ -113,12 +117,35 @@ def list_interfaces(*, client: Gcore, cluster_id: str) -> List[NetworkInterface] return interfaces.results -def list_servers(*, client: Gcore, cluster_id: str) -> None: +def list_servers(*, client: Gcore, cluster_id: str) -> List[GPUBaremetalClusterServer]: print("\n=== LIST GPU BAREMETAL CLUSTER SERVERS ===") servers = client.cloud.gpu_baremetal.clusters.servers.list(cluster_id=cluster_id) for count, server in enumerate(servers.results, 1): print(f" {count}. Server: ID={server.id}, name={server.name}, status={server.status}") print("========================") + return servers.results + + +def rebuild_server(*, client: Gcore, cluster_id: str, server_id: str) -> GPUBaremetalClusterServer: + print("\n=== REBUILD GPU BAREMETAL CLUSTER SERVER ===") + server = client.cloud.gpu_baremetal.clusters.servers.rebuild_and_poll( + server_id=server_id, + cluster_id=cluster_id, + ) + print(f"Rebuilt server: ID={server.id}, name={server.name}, status={server.status}") + print("========================") + return server + + +def replace_server(*, client: Gcore, cluster_id: str, server_id: str) -> GPUBaremetalClusterServer: + print("\n=== REPLACE GPU BAREMETAL CLUSTER SERVER ===") + server = client.cloud.gpu_baremetal.clusters.servers.replace_and_poll( + server_id=server_id, + cluster_id=cluster_id, + ) + print(f"Replaced server: ID={server.id}, name={server.name}, status={server.status}") + print("========================") + return server def list_flavors(*, client: Gcore) -> List[GPUBaremetalFlavor]: diff --git a/examples/cloud/gpu_baremetal_clusters_async.py b/examples/cloud/gpu_baremetal_clusters_async.py index 44b88c4c9..0eceb2867 100644 --- a/examples/cloud/gpu_baremetal_clusters_async.py +++ b/examples/cloud/gpu_baremetal_clusters_async.py @@ -10,6 +10,7 @@ ) from gcore.types.cloud.gpu_baremetal.gpu_baremetal_cluster import GPUBaremetalCluster from gcore.types.cloud.gpu_baremetal.clusters.gpu_baremetal_flavor import GPUBaremetalFlavor +from gcore.types.cloud.gpu_baremetal.clusters.gpu_baremetal_cluster_server import GPUBaremetalClusterServer async def main() -> None: @@ -45,7 +46,10 @@ async def main() -> None: await list_interfaces(client=gcore, cluster_id=cluster.id) # Servers - await list_servers(client=gcore, cluster_id=cluster.id) + servers = await list_servers(client=gcore, cluster_id=cluster.id) + if servers: + await rebuild_server(client=gcore, cluster_id=cluster.id, server_id=servers[0].id) + await replace_server(client=gcore, cluster_id=cluster.id, server_id=servers[0].id) # Delete await delete_cluster(client=gcore, cluster_id=cluster.id) @@ -116,12 +120,35 @@ async def list_interfaces(*, client: AsyncGcore, cluster_id: str) -> List[Networ return interfaces.results -async def list_servers(*, client: AsyncGcore, cluster_id: str) -> None: +async def list_servers(*, client: AsyncGcore, cluster_id: str) -> List[GPUBaremetalClusterServer]: print("\n=== LIST GPU BAREMETAL CLUSTER SERVERS ===") servers = await client.cloud.gpu_baremetal.clusters.servers.list(cluster_id=cluster_id) for count, server in enumerate(servers.results, 1): print(f" {count}. Server: ID={server.id}, name={server.name}, status={server.status}") print("========================") + return servers.results + + +async def rebuild_server(*, client: AsyncGcore, cluster_id: str, server_id: str) -> GPUBaremetalClusterServer: + print("\n=== REBUILD GPU BAREMETAL CLUSTER SERVER ===") + server = await client.cloud.gpu_baremetal.clusters.servers.rebuild_and_poll( + server_id=server_id, + cluster_id=cluster_id, + ) + print(f"Rebuilt server: ID={server.id}, name={server.name}, status={server.status}") + print("========================") + return server + + +async def replace_server(*, client: AsyncGcore, cluster_id: str, server_id: str) -> GPUBaremetalClusterServer: + print("\n=== REPLACE GPU BAREMETAL CLUSTER SERVER ===") + server = await client.cloud.gpu_baremetal.clusters.servers.replace_and_poll( + server_id=server_id, + cluster_id=cluster_id, + ) + print(f"Replaced server: ID={server.id}, name={server.name}, status={server.status}") + print("========================") + return server async def list_flavors(*, client: AsyncGcore) -> List[GPUBaremetalFlavor]: diff --git a/pyproject.toml b/pyproject.toml index 970a913f0..c6e9b0da7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "gcore" -version = "0.46.0" +version = "0.47.0" description = "The official Python library for the gcore API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/gcore/_models.py b/src/gcore/_models.py index 29070e055..8c5ab2602 100644 --- a/src/gcore/_models.py +++ b/src/gcore/_models.py @@ -25,7 +25,9 @@ ClassVar, Protocol, Required, + Annotated, ParamSpec, + TypeAlias, TypedDict, TypeGuard, final, @@ -79,7 +81,15 @@ from ._constants import RAW_RESPONSE_HEADER if TYPE_CHECKING: + from pydantic import GetCoreSchemaHandler, ValidatorFunctionWrapHandler + from pydantic_core import CoreSchema, core_schema from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema +else: + try: + from pydantic_core import CoreSchema, core_schema + except ImportError: + CoreSchema = None + core_schema = None __all__ = ["BaseModel", "GenericModel"] @@ -396,6 +406,76 @@ def model_dump_json( ) +class _EagerIterable(list[_T], Generic[_T]): + """ + Accepts any Iterable[T] input (including generators), consumes it + eagerly, and validates all items upfront. + + Validation preserves the original container type where possible + (e.g. a set[T] stays a set[T]). Serialization (model_dump / JSON) + always emits a list — round-tripping through model_dump() will not + restore the original container type. + """ + + @classmethod + def __get_pydantic_core_schema__( + cls, + source_type: Any, + handler: GetCoreSchemaHandler, + ) -> CoreSchema: + (item_type,) = get_args(source_type) or (Any,) + item_schema: CoreSchema = handler.generate_schema(item_type) + list_of_items_schema: CoreSchema = core_schema.list_schema(item_schema) + + return core_schema.no_info_wrap_validator_function( + cls._validate, + list_of_items_schema, + serialization=core_schema.plain_serializer_function_ser_schema( + cls._serialize, + info_arg=False, + ), + ) + + @staticmethod + def _validate(v: Iterable[_T], handler: "ValidatorFunctionWrapHandler") -> Any: + original_type: type[Any] = type(v) + + # Normalize to list so list_schema can validate each item + if isinstance(v, list): + items: list[_T] = v + else: + try: + items = list(v) + except TypeError as e: + raise TypeError("Value is not iterable") from e + + # Validate items against the inner schema + validated: list[_T] = handler(items) + + # Reconstruct original container type + if original_type is list: + return validated + # str(list) produces the list's repr, not a string built from items, + # so skip reconstruction for str and its subclasses. + if issubclass(original_type, str): + return validated + try: + return original_type(validated) + except (TypeError, ValueError): + # If the type cannot be reconstructed, just return the validated list + return validated + + @staticmethod + def _serialize(v: Iterable[_T]) -> list[_T]: + """Always serialize as a list so Pydantic's JSON encoder is happy.""" + if isinstance(v, list): + return v + return list(v) + + +EagerIterable: TypeAlias = Annotated[Iterable[_T], _EagerIterable] + + def _construct_field(value: object, field: FieldInfo, key: str) -> object: if value is None: return field_get_default(field) diff --git a/src/gcore/_version.py b/src/gcore/_version.py index 734f35742..03edd9b88 100644 --- a/src/gcore/_version.py +++ b/src/gcore/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "gcore" -__version__ = "0.46.0" # x-release-please-version +__version__ = "0.47.0" # x-release-please-version diff --git a/src/gcore/resources/cloud/api.md b/src/gcore/resources/cloud/api.md index 710249015..1f62e49e1 100644 --- a/src/gcore/resources/cloud/api.md +++ b/src/gcore/resources/cloud/api.md @@ -843,6 +843,7 @@ Methods: - client.cloud.gpu_baremetal.clusters.servers.powercycle(instance_id, \*, project_id, region_id) -> GPUBaremetalClusterServerV1 - client.cloud.gpu_baremetal.clusters.servers.reboot(instance_id, \*, project_id, region_id) -> GPUBaremetalClusterServerV1 - client.cloud.gpu_baremetal.clusters.servers.rebuild(server_id, \*, project_id, region_id, cluster_id) -> TaskIDList +- client.cloud.gpu_baremetal.clusters.servers.replace(server_id, \*, project_id, region_id, cluster_id) -> TaskIDList #### Flavors diff --git a/src/gcore/resources/cloud/gpu_baremetal/clusters/servers.py b/src/gcore/resources/cloud/gpu_baremetal/clusters/servers.py index 5375060a5..86dc367fd 100644 --- a/src/gcore/resources/cloud/gpu_baremetal/clusters/servers.py +++ b/src/gcore/resources/cloud/gpu_baremetal/clusters/servers.py @@ -462,6 +462,171 @@ def delete_and_poll( polling_timeout_seconds=polling_timeout_seconds, ) + def replace( + self, + server_id: str, + *, + project_id: int | None = None, + region_id: int | None = None, + cluster_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TaskIDList: + """ + Delete a server from the cluster and provision a new one in its place, + maintaining the cluster size. Uses the current cluster configuration (image, SSH + key, network settings) for the new server. + + Args: + project_id: Project ID + + region_id: Region ID + + cluster_id: Cluster unique identifier + + server_id: Server unique identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if project_id is None: + project_id = self._client._get_cloud_project_id_path_param() + if region_id is None: + region_id = self._client._get_cloud_region_id_path_param() + if not cluster_id: + raise ValueError(f"Expected a non-empty value for `cluster_id` but received {cluster_id!r}") + if not server_id: + raise ValueError(f"Expected a non-empty value for `server_id` but received {server_id!r}") + return self._post( + path_template( + "/cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters/{cluster_id}/servers/{server_id}/replace", + project_id=project_id, + region_id=region_id, + cluster_id=cluster_id, + server_id=server_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TaskIDList, + ) + + def replace_and_poll( + self, + server_id: str, + *, + project_id: int | None = None, + region_id: int | None = None, + cluster_id: str, + polling_interval_seconds: int | Omit = omit, + polling_timeout_seconds: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GPUBaremetalClusterServer: + """ + Replace a bare metal GPU cluster server and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method. + """ + response = self.replace( + server_id=server_id, + project_id=project_id, + region_id=region_id, + cluster_id=cluster_id, + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + ) + if not response.tasks or len(response.tasks) < 1: + raise ValueError("Expected at least one task to be created") + task = self._client.cloud.tasks.poll( + response.tasks[0], + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + polling_interval_seconds=polling_interval_seconds, + polling_timeout_seconds=polling_timeout_seconds, + ) + if not task.created_resources or not task.created_resources.instances: + raise ValueError("No server was created") + new_server_id = task.created_resources.instances[0] + servers = self.list( + cluster_id=cluster_id, + project_id=project_id, + region_id=region_id, + uuids=[new_server_id], + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + ) + if not servers.results or len(servers.results) != 1: + raise ValueError(f"Server {new_server_id} not found") + return servers.results[0] + + def rebuild_and_poll( + self, + server_id: str, + *, + project_id: int | None = None, + region_id: int | None = None, + cluster_id: str, + polling_interval_seconds: int | Omit = omit, + polling_timeout_seconds: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GPUBaremetalClusterServer: + """ + Rebuild a bare metal GPU cluster server and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method. + """ + response = self.rebuild( + server_id=server_id, + project_id=project_id, + region_id=region_id, + cluster_id=cluster_id, + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + ) + if not response.tasks or len(response.tasks) < 1: + raise ValueError("Expected at least one task to be created") + self._client.cloud.tasks.poll( + response.tasks[0], + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + polling_interval_seconds=polling_interval_seconds, + polling_timeout_seconds=polling_timeout_seconds, + ) + servers = self.list( + cluster_id=cluster_id, + project_id=project_id, + region_id=region_id, + uuids=[server_id], + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + ) + if not servers.results or len(servers.results) != 1: + raise ValueError(f"Server {server_id} not found") + return servers.results[0] + class AsyncServersResource(AsyncAPIResource): @cached_property @@ -898,6 +1063,171 @@ async def delete_and_poll( polling_timeout_seconds=polling_timeout_seconds, ) + async def replace( + self, + server_id: str, + *, + project_id: int | None = None, + region_id: int | None = None, + cluster_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TaskIDList: + """ + Delete a server from the cluster and provision a new one in its place, + maintaining the cluster size. Uses the current cluster configuration (image, SSH + key, network settings) for the new server. + + Args: + project_id: Project ID + + region_id: Region ID + + cluster_id: Cluster unique identifier + + server_id: Server unique identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if project_id is None: + project_id = self._client._get_cloud_project_id_path_param() + if region_id is None: + region_id = self._client._get_cloud_region_id_path_param() + if not cluster_id: + raise ValueError(f"Expected a non-empty value for `cluster_id` but received {cluster_id!r}") + if not server_id: + raise ValueError(f"Expected a non-empty value for `server_id` but received {server_id!r}") + return await self._post( + path_template( + "/cloud/v3/gpu/baremetal/{project_id}/{region_id}/clusters/{cluster_id}/servers/{server_id}/replace", + project_id=project_id, + region_id=region_id, + cluster_id=cluster_id, + server_id=server_id, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TaskIDList, + ) + + async def replace_and_poll( + self, + server_id: str, + *, + project_id: int | None = None, + region_id: int | None = None, + cluster_id: str, + polling_interval_seconds: int | Omit = omit, + polling_timeout_seconds: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GPUBaremetalClusterServer: + """ + Replace a bare metal GPU cluster server and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method. + """ + response = await self.replace( + server_id=server_id, + project_id=project_id, + region_id=region_id, + cluster_id=cluster_id, + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + ) + if not response.tasks or len(response.tasks) < 1: + raise ValueError("Expected at least one task to be created") + task = await self._client.cloud.tasks.poll( + response.tasks[0], + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + polling_interval_seconds=polling_interval_seconds, + polling_timeout_seconds=polling_timeout_seconds, + ) + if not task.created_resources or not task.created_resources.instances: + raise ValueError("No server was created") + new_server_id = task.created_resources.instances[0] + servers = await self.list( + cluster_id=cluster_id, + project_id=project_id, + region_id=region_id, + uuids=[new_server_id], + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + ) + if not servers.results or len(servers.results) != 1: + raise ValueError(f"Server {new_server_id} not found") + return servers.results[0] + + async def rebuild_and_poll( + self, + server_id: str, + *, + project_id: int | None = None, + region_id: int | None = None, + cluster_id: str, + polling_interval_seconds: int | Omit = omit, + polling_timeout_seconds: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> GPUBaremetalClusterServer: + """ + Rebuild a bare metal GPU cluster server and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method. + """ + response = await self.rebuild( + server_id=server_id, + project_id=project_id, + region_id=region_id, + cluster_id=cluster_id, + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + ) + if not response.tasks or len(response.tasks) < 1: + raise ValueError("Expected at least one task to be created") + await self._client.cloud.tasks.poll( + response.tasks[0], + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + polling_interval_seconds=polling_interval_seconds, + polling_timeout_seconds=polling_timeout_seconds, + ) + servers = await self.list( + cluster_id=cluster_id, + project_id=project_id, + region_id=region_id, + uuids=[server_id], + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + ) + if not servers.results or len(servers.results) != 1: + raise ValueError(f"Server {server_id} not found") + return servers.results[0] + class ServersResourceWithRawResponse: def __init__(self, servers: ServersResource) -> None: @@ -921,9 +1251,18 @@ def __init__(self, servers: ServersResource) -> None: self.rebuild = to_raw_response_wrapper( servers.rebuild, ) + self.replace = to_raw_response_wrapper( + servers.replace, + ) self.delete_and_poll = to_raw_response_wrapper( servers.delete_and_poll, ) + self.replace_and_poll = to_raw_response_wrapper( + servers.replace_and_poll, + ) + self.rebuild_and_poll = to_raw_response_wrapper( + servers.rebuild_and_poll, + ) class AsyncServersResourceWithRawResponse: @@ -948,9 +1287,18 @@ def __init__(self, servers: AsyncServersResource) -> None: self.rebuild = async_to_raw_response_wrapper( servers.rebuild, ) + self.replace = async_to_raw_response_wrapper( + servers.replace, + ) self.delete_and_poll = async_to_raw_response_wrapper( servers.delete_and_poll, ) + self.replace_and_poll = async_to_raw_response_wrapper( + servers.replace_and_poll, + ) + self.rebuild_and_poll = async_to_raw_response_wrapper( + servers.rebuild_and_poll, + ) class ServersResourceWithStreamingResponse: @@ -975,9 +1323,18 @@ def __init__(self, servers: ServersResource) -> None: self.rebuild = to_streamed_response_wrapper( servers.rebuild, ) + self.replace = to_streamed_response_wrapper( + servers.replace, + ) self.delete_and_poll = to_streamed_response_wrapper( servers.delete_and_poll, ) + self.replace_and_poll = to_streamed_response_wrapper( + servers.replace_and_poll, + ) + self.rebuild_and_poll = to_streamed_response_wrapper( + servers.rebuild_and_poll, + ) class AsyncServersResourceWithStreamingResponse: @@ -1002,6 +1359,15 @@ def __init__(self, servers: AsyncServersResource) -> None: self.rebuild = async_to_streamed_response_wrapper( servers.rebuild, ) + self.replace = async_to_streamed_response_wrapper( + servers.replace, + ) self.delete_and_poll = async_to_streamed_response_wrapper( servers.delete_and_poll, ) + self.replace_and_poll = async_to_streamed_response_wrapper( + servers.replace_and_poll, + ) + self.rebuild_and_poll = async_to_streamed_response_wrapper( + servers.rebuild_and_poll, + ) diff --git a/src/gcore/resources/storage/object_storages/access_keys.py b/src/gcore/resources/storage/object_storages/access_keys.py index c650bf433..83ed5cc8b 100644 --- a/src/gcore/resources/storage/object_storages/access_keys.py +++ b/src/gcore/resources/storage/object_storages/access_keys.py @@ -24,6 +24,10 @@ class AccessKeysResource(SyncAPIResource): + """ + Object storage access keys provide secure credentials for API access to object storage resources. + """ + @cached_property def with_raw_response(self) -> AccessKeysResourceWithRawResponse: """ @@ -205,6 +209,10 @@ def get( class AsyncAccessKeysResource(AsyncAPIResource): + """ + Object storage access keys provide secure credentials for API access to object storage resources. + """ + @cached_property def with_raw_response(self) -> AsyncAccessKeysResourceWithRawResponse: """ diff --git a/src/gcore/resources/storage/object_storages/buckets.py b/src/gcore/resources/storage/object_storages/buckets.py index 3bfa3b568..d22193617 100644 --- a/src/gcore/resources/storage/object_storages/buckets.py +++ b/src/gcore/resources/storage/object_storages/buckets.py @@ -23,6 +23,10 @@ class BucketsResource(SyncAPIResource): + """ + Buckets are containers within object storage that hold files (objects) and define their CORS, lifecycle, and access policy configuration. + """ + @cached_property def with_raw_response(self) -> BucketsResourceWithRawResponse: """ @@ -253,6 +257,10 @@ def get( class AsyncBucketsResource(AsyncAPIResource): + """ + Buckets are containers within object storage that hold files (objects) and define their CORS, lifecycle, and access policy configuration. + """ + @cached_property def with_raw_response(self) -> AsyncBucketsResourceWithRawResponse: """ diff --git a/src/gcore/resources/storage/object_storages/object_storages.py b/src/gcore/resources/storage/object_storages/object_storages.py index 8b092f53e..574efb46b 100644 --- a/src/gcore/resources/storage/object_storages/object_storages.py +++ b/src/gcore/resources/storage/object_storages/object_storages.py @@ -42,12 +42,22 @@ class ObjectStoragesResource(SyncAPIResource): + """ + S3-compatible object storages provide scalable cloud storage with S3 API compatibility. Each storage is provisioned in a specific location and exposes one or more access keys for authentication. + """ + @cached_property def access_keys(self) -> AccessKeysResource: + """ + Object storage access keys provide secure credentials for API access to object storage resources. + """ return AccessKeysResource(self._client) @cached_property def buckets(self) -> BucketsResource: + """ + Buckets are containers within object storage that hold files (objects) and define their CORS, lifecycle, and access policy configuration. + """ return BucketsResource(self._client) @cached_property @@ -282,12 +292,22 @@ def restore( class AsyncObjectStoragesResource(AsyncAPIResource): + """ + S3-compatible object storages provide scalable cloud storage with S3 API compatibility. Each storage is provisioned in a specific location and exposes one or more access keys for authentication. + """ + @cached_property def access_keys(self) -> AsyncAccessKeysResource: + """ + Object storage access keys provide secure credentials for API access to object storage resources. + """ return AsyncAccessKeysResource(self._client) @cached_property def buckets(self) -> AsyncBucketsResource: + """ + Buckets are containers within object storage that hold files (objects) and define their CORS, lifecycle, and access policy configuration. + """ return AsyncBucketsResource(self._client) @cached_property @@ -543,10 +563,16 @@ def __init__(self, object_storages: ObjectStoragesResource) -> None: @cached_property def access_keys(self) -> AccessKeysResourceWithRawResponse: + """ + Object storage access keys provide secure credentials for API access to object storage resources. + """ return AccessKeysResourceWithRawResponse(self._object_storages.access_keys) @cached_property def buckets(self) -> BucketsResourceWithRawResponse: + """ + Buckets are containers within object storage that hold files (objects) and define their CORS, lifecycle, and access policy configuration. + """ return BucketsResourceWithRawResponse(self._object_storages.buckets) @@ -572,10 +598,16 @@ def __init__(self, object_storages: AsyncObjectStoragesResource) -> None: @cached_property def access_keys(self) -> AsyncAccessKeysResourceWithRawResponse: + """ + Object storage access keys provide secure credentials for API access to object storage resources. + """ return AsyncAccessKeysResourceWithRawResponse(self._object_storages.access_keys) @cached_property def buckets(self) -> AsyncBucketsResourceWithRawResponse: + """ + Buckets are containers within object storage that hold files (objects) and define their CORS, lifecycle, and access policy configuration. + """ return AsyncBucketsResourceWithRawResponse(self._object_storages.buckets) @@ -601,10 +633,16 @@ def __init__(self, object_storages: ObjectStoragesResource) -> None: @cached_property def access_keys(self) -> AccessKeysResourceWithStreamingResponse: + """ + Object storage access keys provide secure credentials for API access to object storage resources. + """ return AccessKeysResourceWithStreamingResponse(self._object_storages.access_keys) @cached_property def buckets(self) -> BucketsResourceWithStreamingResponse: + """ + Buckets are containers within object storage that hold files (objects) and define their CORS, lifecycle, and access policy configuration. + """ return BucketsResourceWithStreamingResponse(self._object_storages.buckets) @@ -630,8 +668,14 @@ def __init__(self, object_storages: AsyncObjectStoragesResource) -> None: @cached_property def access_keys(self) -> AsyncAccessKeysResourceWithStreamingResponse: + """ + Object storage access keys provide secure credentials for API access to object storage resources. + """ return AsyncAccessKeysResourceWithStreamingResponse(self._object_storages.access_keys) @cached_property def buckets(self) -> AsyncBucketsResourceWithStreamingResponse: + """ + Buckets are containers within object storage that hold files (objects) and define their CORS, lifecycle, and access policy configuration. + """ return AsyncBucketsResourceWithStreamingResponse(self._object_storages.buckets) diff --git a/src/gcore/resources/storage/storage.py b/src/gcore/resources/storage/storage.py index dd2c6cf29..a26f00fb3 100644 --- a/src/gcore/resources/storage/storage.py +++ b/src/gcore/resources/storage/storage.py @@ -56,6 +56,9 @@ def locations(self) -> LocationsResource: @cached_property def object_storages(self) -> ObjectStoragesResource: + """ + S3-compatible object storages provide scalable cloud storage with S3 API compatibility. Each storage is provisioned in a specific location and exposes one or more access keys for authentication. + """ return ObjectStoragesResource(self._client) @cached_property @@ -101,6 +104,9 @@ def locations(self) -> AsyncLocationsResource: @cached_property def object_storages(self) -> AsyncObjectStoragesResource: + """ + S3-compatible object storages provide scalable cloud storage with S3 API compatibility. Each storage is provisioned in a specific location and exposes one or more access keys for authentication. + """ return AsyncObjectStoragesResource(self._client) @cached_property @@ -149,6 +155,9 @@ def locations(self) -> LocationsResourceWithRawResponse: @cached_property def object_storages(self) -> ObjectStoragesResourceWithRawResponse: + """ + S3-compatible object storages provide scalable cloud storage with S3 API compatibility. Each storage is provisioned in a specific location and exposes one or more access keys for authentication. + """ return ObjectStoragesResourceWithRawResponse(self._storage.object_storages) @cached_property @@ -178,6 +187,9 @@ def locations(self) -> AsyncLocationsResourceWithRawResponse: @cached_property def object_storages(self) -> AsyncObjectStoragesResourceWithRawResponse: + """ + S3-compatible object storages provide scalable cloud storage with S3 API compatibility. Each storage is provisioned in a specific location and exposes one or more access keys for authentication. + """ return AsyncObjectStoragesResourceWithRawResponse(self._storage.object_storages) @cached_property @@ -207,6 +219,9 @@ def locations(self) -> LocationsResourceWithStreamingResponse: @cached_property def object_storages(self) -> ObjectStoragesResourceWithStreamingResponse: + """ + S3-compatible object storages provide scalable cloud storage with S3 API compatibility. Each storage is provisioned in a specific location and exposes one or more access keys for authentication. + """ return ObjectStoragesResourceWithStreamingResponse(self._storage.object_storages) @cached_property @@ -236,6 +251,9 @@ def locations(self) -> AsyncLocationsResourceWithStreamingResponse: @cached_property def object_storages(self) -> AsyncObjectStoragesResourceWithStreamingResponse: + """ + S3-compatible object storages provide scalable cloud storage with S3 API compatibility. Each storage is provisioned in a specific location and exposes one or more access keys for authentication. + """ return AsyncObjectStoragesResourceWithStreamingResponse(self._storage.object_storages) @cached_property diff --git a/src/gcore/types/waap/waap_detailed_domain.py b/src/gcore/types/waap/waap_detailed_domain.py index e76b62b19..ada4383ce 100644 --- a/src/gcore/types/waap/waap_detailed_domain.py +++ b/src/gcore/types/waap/waap_detailed_domain.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, Optional +from typing import Dict, List, Optional from datetime import datetime from typing_extensions import Literal @@ -41,5 +41,8 @@ class WaapDetailedDomain(BaseModel): status: Literal["active", "bypass", "monitor", "locked"] """The different statuses a domain can have""" + aliases: Optional[List[str]] = None + """CNAME aliases pointing at this domain's CDN resource""" + quotas: Optional[Dict[str, Quotas]] = None """Domain level quotas""" diff --git a/src/gcore/types/waap/waap_summary_domain.py b/src/gcore/types/waap/waap_summary_domain.py index b5186b373..92f13d06e 100644 --- a/src/gcore/types/waap/waap_summary_domain.py +++ b/src/gcore/types/waap/waap_summary_domain.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import List, Optional from datetime import datetime from typing_extensions import Literal @@ -26,3 +26,6 @@ class WaapSummaryDomain(BaseModel): status: Literal["active", "bypass", "monitor", "locked"] """The different statuses a domain can have""" + + aliases: Optional[List[str]] = None + """CNAME aliases pointing at this domain's CDN resource""" diff --git a/tests/api_resources/cloud/gpu_baremetal/clusters/test_servers.py b/tests/api_resources/cloud/gpu_baremetal/clusters/test_servers.py index d51f53792..847f96887 100644 --- a/tests/api_resources/cloud/gpu_baremetal/clusters/test_servers.py +++ b/tests/api_resources/cloud/gpu_baremetal/clusters/test_servers.py @@ -352,6 +352,64 @@ def test_path_params_rebuild(self, client: Gcore) -> None: cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", ) + @parametrize + def test_method_replace(self, client: Gcore) -> None: + server = client.cloud.gpu_baremetal.clusters.servers.replace( + server_id="f1c1eeb6-1834-48c9-a7b0-daafce64872b", + project_id=1, + region_id=7, + cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", + ) + assert_matches_type(TaskIDList, server, path=["response"]) + + @parametrize + def test_raw_response_replace(self, client: Gcore) -> None: + response = client.cloud.gpu_baremetal.clusters.servers.with_raw_response.replace( + server_id="f1c1eeb6-1834-48c9-a7b0-daafce64872b", + project_id=1, + region_id=7, + cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + server = response.parse() + assert_matches_type(TaskIDList, server, path=["response"]) + + @parametrize + def test_streaming_response_replace(self, client: Gcore) -> None: + with client.cloud.gpu_baremetal.clusters.servers.with_streaming_response.replace( + server_id="f1c1eeb6-1834-48c9-a7b0-daafce64872b", + project_id=1, + region_id=7, + cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + server = response.parse() + assert_matches_type(TaskIDList, server, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_replace(self, client: Gcore) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `cluster_id` but received ''"): + client.cloud.gpu_baremetal.clusters.servers.with_raw_response.replace( + server_id="f1c1eeb6-1834-48c9-a7b0-daafce64872b", + project_id=1, + region_id=7, + cluster_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `server_id` but received ''"): + client.cloud.gpu_baremetal.clusters.servers.with_raw_response.replace( + server_id="", + project_id=1, + region_id=7, + cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", + ) + class TestAsyncServers: parametrize = pytest.mark.parametrize( @@ -686,3 +744,61 @@ async def test_path_params_rebuild(self, async_client: AsyncGcore) -> None: region_id=7, cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", ) + + @parametrize + async def test_method_replace(self, async_client: AsyncGcore) -> None: + server = await async_client.cloud.gpu_baremetal.clusters.servers.replace( + server_id="f1c1eeb6-1834-48c9-a7b0-daafce64872b", + project_id=1, + region_id=7, + cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", + ) + assert_matches_type(TaskIDList, server, path=["response"]) + + @parametrize + async def test_raw_response_replace(self, async_client: AsyncGcore) -> None: + response = await async_client.cloud.gpu_baremetal.clusters.servers.with_raw_response.replace( + server_id="f1c1eeb6-1834-48c9-a7b0-daafce64872b", + project_id=1, + region_id=7, + cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + server = await response.parse() + assert_matches_type(TaskIDList, server, path=["response"]) + + @parametrize + async def test_streaming_response_replace(self, async_client: AsyncGcore) -> None: + async with async_client.cloud.gpu_baremetal.clusters.servers.with_streaming_response.replace( + server_id="f1c1eeb6-1834-48c9-a7b0-daafce64872b", + project_id=1, + region_id=7, + cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + server = await response.parse() + assert_matches_type(TaskIDList, server, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_replace(self, async_client: AsyncGcore) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `cluster_id` but received ''"): + await async_client.cloud.gpu_baremetal.clusters.servers.with_raw_response.replace( + server_id="f1c1eeb6-1834-48c9-a7b0-daafce64872b", + project_id=1, + region_id=7, + cluster_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `server_id` but received ''"): + await async_client.cloud.gpu_baremetal.clusters.servers.with_raw_response.replace( + server_id="", + project_id=1, + region_id=7, + cluster_id="1aaaab48-10d0-46d9-80cc-85209284ceb4", + ) diff --git a/tests/test_models.py b/tests/test_models.py index d899cd02c..e079ac0eb 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,7 +1,8 @@ import json -from typing import TYPE_CHECKING, Any, Dict, List, Union, Optional, cast +from typing import TYPE_CHECKING, Any, Dict, List, Union, Iterable, Optional, cast from datetime import datetime, timezone -from typing_extensions import Literal, Annotated, TypeAliasType +from collections import deque +from typing_extensions import Literal, Annotated, TypedDict, TypeAliasType import pytest import pydantic @@ -9,7 +10,7 @@ from gcore._utils import PropertyInfo from gcore._compat import PYDANTIC_V1, parse_obj, model_dump, model_json -from gcore._models import DISCRIMINATOR_CACHE, BaseModel, construct_type +from gcore._models import DISCRIMINATOR_CACHE, BaseModel, EagerIterable, construct_type class BasicModel(BaseModel): @@ -961,3 +962,56 @@ def __getattr__(self, attr: str) -> Item: ... assert model.a.prop == 1 assert isinstance(model.a, Item) assert model.other == "foo" + + +# NOTE: Workaround for Pydantic Iterable behavior. +# Iterable fields are replaced with a ValidatorIterator and may be consumed +# during serialization, which can cause subsequent dumps to return empty data. +# See: https://github.com/pydantic/pydantic/issues/9541 +@pytest.mark.parametrize( + "data, expected_validated", + [ + ([1, 2, 3], [1, 2, 3]), + ((1, 2, 3), (1, 2, 3)), + (set([1, 2, 3]), set([1, 2, 3])), + (iter([1, 2, 3]), [1, 2, 3]), + ([], []), + ((x for x in [1, 2, 3]), [1, 2, 3]), + (map(lambda x: x, [1, 2, 3]), [1, 2, 3]), + (frozenset([1, 2, 3]), frozenset([1, 2, 3])), + (deque([1, 2, 3]), deque([1, 2, 3])), + ], + ids=["list", "tuple", "set", "iterator", "empty", "generator", "map", "frozenset", "deque"], +) +@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2") +def test_iterable_construction(data: Iterable[int], expected_validated: Iterable[int]) -> None: + class TypeWithIterable(TypedDict): + items: EagerIterable[int] + + class Model(BaseModel): + data: TypeWithIterable + + m = Model.model_validate({"data": {"items": data}}) + assert m.data["items"] == expected_validated + + # Verify repeated dumps don't lose data (the original bug) + assert m.model_dump()["data"]["items"] == list(expected_validated) + assert m.model_dump()["data"]["items"] == list(expected_validated) + + +@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2") +def test_iterable_construction_str_falls_back_to_list() -> None: + # str is iterable (over chars), but str(list_of_chars) produces the list's repr + # rather than reconstructing a string from items. We special-case str to fall + # back to list instead of attempting reconstruction. + class TypeWithIterable(TypedDict): + items: EagerIterable[str] + + class Model(BaseModel): + data: TypeWithIterable + + m = Model.model_validate({"data": {"items": "hello"}}) + + # falls back to list of chars rather than calling str(["h", "e", "l", "l", "o"]) + assert m.data["items"] == ["h", "e", "l", "l", "o"] + assert m.model_dump()["data"]["items"] == ["h", "e", "l", "l", "o"]