diff --git a/generation-provenance.json b/generation-provenance.json index 0d44c1f..bb83127 100644 --- a/generation-provenance.json +++ b/generation-provenance.json @@ -1,11 +1,11 @@ { - "source_spec_sha": "9f8d54f123e81b8bc7252f855c52ecbf7cc8ae42", - "source_spec_sha256": "c0b2db893e3017c5c83c14375e6085581584641f617ee7ea1305ab80e9b50421", + "source_spec_sha": "f5b640b324aafb001a8da6facd807f13197630bb", + "source_spec_sha256": "a717ed108ea8bbb6b9c0b70255a07da7e9a01224c6941546089084e02097a632", "generator_version": "0.38.0", - "build_version": "0.1.16", - "configuration_sha256": "10d2f59b8a69dce627060e1104eac425cec104dd90d3177c08a29a902cb48875", + "build_version": "0.1.19", + "configuration_sha256": "477d944077da8e1163423c505fe3f773cce14eda953aa934fe91582d04e4e915", "operation_count": 31, - "generated_commit": "bc3e12c4dd8d4d0557b5e2847049a2ecc7df21df", + "generated_commit": "947b94cdb9da7800aa5fea9c117e49616bc966a4", "download_sha256": null, "integration_base": "scalar-next", "published_package": false diff --git a/scalar-sdk.manifest.json b/scalar-sdk.manifest.json index 6896011..affc8a1 100644 --- a/scalar-sdk.manifest.json +++ b/scalar-sdk.manifest.json @@ -198,19 +198,8 @@ "required": true, "deprecated": false, "type": { - "kind": "enum", - "values": [ - "on", - "off" - ], - "names": [ - "On", - "Off" - ], - "deprecations": [ - false, - false - ] + "kind": "ref", + "name": "autoresizing_switch" } }, { @@ -294,19 +283,8 @@ "required": true, "deprecated": false, "type": { - "kind": "enum", - "values": [ - "on", - "off" - ], - "names": [ - "On", - "Off" - ], - "deprecations": [ - false, - false - ] + "kind": "ref", + "name": "autoresizing_switch" } }, { @@ -370,19 +348,8 @@ "required": false, "deprecated": false, "type": { - "kind": "enum", - "values": [ - "on", - "off" - ], - "names": [ - "On", - "Off" - ], - "deprecations": [ - false, - false - ] + "kind": "ref", + "name": "autoresizing_switch" } }, { @@ -414,19 +381,8 @@ "required": false, "deprecated": false, "type": { - "kind": "enum", - "values": [ - "on", - "off" - ], - "names": [ - "On", - "Off" - ], - "deprecations": [ - false, - false - ] + "kind": "ref", + "name": "autoresizing_switch" } }, { @@ -3180,6 +3136,27 @@ "additionalProperties": false } }, + { + "name": "autoresizing_switch", + "source": "autoresizing_switch", + "publicAliases": [], + "deprecated": false, + "type": { + "kind": "enum", + "values": [ + "on", + "off" + ], + "names": [ + "On", + "Off" + ], + "deprecations": [ + false, + false + ] + } + }, { "name": "CreateResponseHeaders", "source": "CreateResponseHeaders", diff --git a/src/dedalus_sdk/_base_client.py b/src/dedalus_sdk/_base_client.py index 15f5274..efe4146 100644 --- a/src/dedalus_sdk/_base_client.py +++ b/src/dedalus_sdk/_base_client.py @@ -3,7 +3,6 @@ import sys import json import time -import uuid import zlib import email import asyncio @@ -1458,10 +1457,9 @@ def _should_retry(self, response: httpx.Response) -> bool: return False def _idempotency_key(self) -> str: - # @custom start - # The API requires a compact UUIDv7; retries reuse this generated key. - return f"{time.time_ns() // 1_000_000:012x}7{uuid.uuid4().hex[13:]}" - # @custom end + from ._uuid7 import uuid7 + + return uuid7().hex class _DefaultHttpxClient(httpx.Client): diff --git a/src/dedalus_sdk/_uuid7.py b/src/dedalus_sdk/_uuid7.py new file mode 100644 index 0000000..494be86 --- /dev/null +++ b/src/dedalus_sdk/_uuid7.py @@ -0,0 +1,21 @@ +"""Time-ordered (version 7) UUIDs for idempotency keys. + +The standard library gains `uuid.uuid7` only in Python 3.14, and the SDK supports older versions +without a third-party dependency, so this module builds one by hand per RFC 9562. +""" + +from __future__ import annotations + +import os +import time +import uuid + + +def uuid7() -> uuid.UUID: + """A version 7 UUID: a 48-bit Unix millisecond timestamp, then version and variant bits, the rest random.""" + value = bytearray(os.urandom(16)) + # Clamped, because `to_bytes` rejects a negative int: a clock set before 1970 writes a zero timestamp. + value[0:6] = max(0, time.time_ns() // 1_000_000).to_bytes(6, "big") + value[6] = (value[6] & 0x0F) | 0x70 + value[8] = (value[8] & 0x3F) | 0x80 + return uuid.UUID(bytes=bytes(value)) diff --git a/src/dedalus_sdk/resources/machines/autoresizing.py b/src/dedalus_sdk/resources/machines/autoresizing.py index 519ce04..db809c9 100644 --- a/src/dedalus_sdk/resources/machines/autoresizing.py +++ b/src/dedalus_sdk/resources/machines/autoresizing.py @@ -5,7 +5,6 @@ import httpx from typing import Optional -from typing_extensions import Literal from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ..._utils import path_template, maybe_transform, async_maybe_transform @@ -19,6 +18,7 @@ ) from ..._base_client import make_request_options from ...types.machines.policy import Policy +from ...types.autoresizing_switch import AutoresizingSwitch from ...types.machines import autoresizing_update_params __all__ = ["AutoresizingResource", "AsyncAutoresizingResource"] @@ -78,9 +78,9 @@ def update( self, *, machine_id: str, - cpu: Literal["on", "off"] | Omit = omit, + cpu: AutoresizingSwitch | Omit = omit, cpu_max_vcpu: Optional[float] | Omit = omit, - memory: Literal["on", "off"] | Omit = omit, + memory: AutoresizingSwitch | Omit = omit, memory_max_mib: Optional[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. @@ -194,9 +194,9 @@ async def update( self, *, machine_id: str, - cpu: Literal["on", "off"] | Omit = omit, + cpu: AutoresizingSwitch | Omit = omit, cpu_max_vcpu: Optional[float] | Omit = omit, - memory: Literal["on", "off"] | Omit = omit, + memory: AutoresizingSwitch | Omit = omit, memory_max_mib: Optional[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. diff --git a/src/dedalus_sdk/resources/organization/autoresizing.py b/src/dedalus_sdk/resources/organization/autoresizing.py index 1fed981..83f062c 100644 --- a/src/dedalus_sdk/resources/organization/autoresizing.py +++ b/src/dedalus_sdk/resources/organization/autoresizing.py @@ -5,7 +5,6 @@ import httpx from typing import Optional -from typing_extensions import Literal from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ..._utils import maybe_transform, async_maybe_transform @@ -19,6 +18,7 @@ ) from ..._base_client import make_request_options from ...types.machines.policy import Policy +from ...types.autoresizing_switch import AutoresizingSwitch from ...types.organization import autoresizing_update_params __all__ = ["AutoresizingResource", "AsyncAutoresizingResource"] @@ -71,9 +71,9 @@ def retrieve( def update( self, *, - cpu: Literal["on", "off"] | Omit = omit, + cpu: AutoresizingSwitch | Omit = omit, cpu_max_vcpu: Optional[float] | Omit = omit, - memory: Literal["on", "off"] | Omit = omit, + memory: AutoresizingSwitch | Omit = omit, memory_max_mib: Optional[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. @@ -176,9 +176,9 @@ async def retrieve( async def update( self, *, - cpu: Literal["on", "off"] | Omit = omit, + cpu: AutoresizingSwitch | Omit = omit, cpu_max_vcpu: Optional[float] | Omit = omit, - memory: Literal["on", "off"] | Omit = omit, + memory: AutoresizingSwitch | Omit = omit, memory_max_mib: Optional[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. diff --git a/src/dedalus_sdk/types/__init__.py b/src/dedalus_sdk/types/__init__.py index 54b6050..7df9672 100644 --- a/src/dedalus_sdk/types/__init__.py +++ b/src/dedalus_sdk/types/__init__.py @@ -10,6 +10,7 @@ from .machine_list import MachineList as MachineList from .image import Image as Image from .source import Source as Source +from .autoresizing_switch import AutoresizingSwitch as AutoresizingSwitch from .source_param import SourceParam as SourceParam from .machine_list_params import MachineListParams as MachineListParams from .machine_create_params import MachineCreateParams as MachineCreateParams diff --git a/src/dedalus_sdk/types/autoresizing_switch.py b/src/dedalus_sdk/types/autoresizing_switch.py new file mode 100644 index 0000000..fad9bb7 --- /dev/null +++ b/src/dedalus_sdk/types/autoresizing_switch.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Scalar. See README.md for details. + +from typing_extensions import Literal, TypeAlias + +__all__ = ["AutoresizingSwitch"] + +AutoresizingSwitch: TypeAlias = Literal["on", "off"] diff --git a/src/dedalus_sdk/types/machines/autoresizing_update_params.py b/src/dedalus_sdk/types/machines/autoresizing_update_params.py index c00cb0b..d8f83e8 100644 --- a/src/dedalus_sdk/types/machines/autoresizing_update_params.py +++ b/src/dedalus_sdk/types/machines/autoresizing_update_params.py @@ -3,7 +3,9 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Required, TypedDict + +from ..autoresizing_switch import AutoresizingSwitch __all__ = ["AutoresizingUpdateParams"] @@ -12,10 +14,10 @@ class AutoresizingUpdateParams(TypedDict, total=False): machine_id: Required[str] """Bare, lowercase, hyphenated Machine UUID. Pass the returned machine_id unchanged.""" - cpu: Literal["on", "off"] + cpu: AutoresizingSwitch cpu_max_vcpu: Optional[float] - memory: Literal["on", "off"] + memory: AutoresizingSwitch memory_max_mib: Optional[int] diff --git a/src/dedalus_sdk/types/machines/policy.py b/src/dedalus_sdk/types/machines/policy.py index 03fa595..176d70a 100644 --- a/src/dedalus_sdk/types/machines/policy.py +++ b/src/dedalus_sdk/types/machines/policy.py @@ -5,11 +5,13 @@ from ..._models import BaseModel +from ..autoresizing_switch import AutoresizingSwitch + __all__ = ["Policy"] class Policy(BaseModel): - cpu: Literal["on", "off"] + cpu: AutoresizingSwitch """Permit automatic CPU growth independently of RAM.""" cpu_limit_source: Literal["plan", "configured", "platform"] @@ -26,7 +28,7 @@ class Policy(BaseModel): enabled: bool """Deprecated RAM permission alias. Use memory.""" - memory: Literal["on", "off"] + memory: AutoresizingSwitch """Permit automatic RAM growth. Automatic shrink remains internal.""" memory_limit_source: Literal["plan", "configured", "platform"] diff --git a/src/dedalus_sdk/types/organization/autoresizing_update_params.py b/src/dedalus_sdk/types/organization/autoresizing_update_params.py index 425325b..907a7de 100644 --- a/src/dedalus_sdk/types/organization/autoresizing_update_params.py +++ b/src/dedalus_sdk/types/organization/autoresizing_update_params.py @@ -3,16 +3,18 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Literal, TypedDict +from typing_extensions import TypedDict + +from ..autoresizing_switch import AutoresizingSwitch __all__ = ["AutoresizingUpdateParams"] class AutoresizingUpdateParams(TypedDict, total=False): - cpu: Literal["on", "off"] + cpu: AutoresizingSwitch cpu_max_vcpu: Optional[float] - memory: Literal["on", "off"] + memory: AutoresizingSwitch memory_max_mib: Optional[int]