Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions generation-provenance.json
Original file line number Diff line number Diff line change
@@ -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
Expand Down
81 changes: 29 additions & 52 deletions scalar-sdk.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down Expand Up @@ -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"
}
},
{
Expand Down Expand Up @@ -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"
}
},
{
Expand Down Expand Up @@ -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"
}
},
{
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 3 additions & 5 deletions src/dedalus_sdk/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sys
import json
import time
import uuid
import zlib
import email
import asyncio
Expand Down Expand Up @@ -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):
Expand Down
21 changes: 21 additions & 0 deletions src/dedalus_sdk/_uuid7.py
Original file line number Diff line number Diff line change
@@ -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))
10 changes: 5 additions & 5 deletions src/dedalus_sdk/resources/machines/autoresizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/dedalus_sdk/resources/organization/autoresizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/dedalus_sdk/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/dedalus_sdk/types/autoresizing_switch.py
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 5 additions & 3 deletions src/dedalus_sdk/types/machines/autoresizing_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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]
6 changes: 4 additions & 2 deletions src/dedalus_sdk/types/machines/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Loading