Sign Up

ReservationService

class ReservationService()

Dedicated-Mac reservations, which macOS sandboxes run on.

A macOS sandbox runs on a Mac the organization has reserved: reserve one here, or let a macOS create buy one (reservation="new", or the organization's auto-reserve). A reservation lasts 24-hour periods, each charged when it starts. Reserving, renewing and turning auto-renew on need the organization's macos_sandboxes feature flag (otherwise 403 FEATURE_FLAG_DISABLED, raised as ForbiddenError); listing, reading and turning auto-renew off do not.

ReservationService.__init__

def __init__(transport: AsyncTransport) -> None

ReservationService.create

async def create(*,
                 region: str,
                 vms_per_mac: Optional[int] = None,
                 idempotency_key: Optional[str] = None,
                 auto_renew: Optional[bool] = None) -> MacReservation

Reserve a Mac in region.

The request always carries an Idempotency-Key: idempotency_key when given, otherwise a random UUID the SDK generates for this call. Pass your own key if you may retry, so a retry after a lost response returns the same reservation instead of reserving a second Mac. vms_per_mac defaults server-side to 2, the maximum. auto_renew defaults server-side to the organization's auto-reserve setting. Raises ConflictError with code == "NO_MAC_AVAILABLE" when the region has no free Mac.

ReservationService.list

async def list() -> List[MacReservation]

Every reservation of the organization, in one response.

ReservationService.get

async def get(reservation_id: str) -> MacReservation

ReservationService.renew

async def renew(reservation_id: str) -> MacReservation

Renew the reservation for its next 24-hour period, which the server charges.

ReservationService.update

async def update(reservation_id: str, *, auto_renew: bool) -> MacReservation

Turn the lease's auto-renewal on or off.

Turning it on needs the organization's macos_sandboxes feature flag; turning it off works without it, so an organization can stop a lease renewing. Raises ConflictError when the lease is no longer live.

SyncReservationService

class SyncReservationService()

Dedicated-Mac reservations, which macOS sandboxes run on.

SyncReservationService.__init__

def __init__(impl: ReservationService, bridge: SyncBridge) -> None

SyncReservationService.create

def create(*,
           region: str,
           vms_per_mac: Optional[int] = None,
           idempotency_key: Optional[str] = None,
           auto_renew: Optional[bool] = None) -> MacReservation

Reserve a Mac in region.

SyncReservationService.get

def get(reservation_id: str) -> MacReservation

SyncReservationService.list

def list() -> List[MacReservation]

Every reservation of the organization, in one response.

SyncReservationService.renew

def renew(reservation_id: str) -> MacReservation

Renew the reservation for its next 24-hour period, which the server charges.

SyncReservationService.update

def update(reservation_id: str, *, auto_renew: bool) -> MacReservation

Turn the lease's auto-renewal on or off.

MacReservation

class MacReservation(BaseModel)

A Mac lease.

Attributes:

  • activated_at Optional[datetime] = None
  • auto_renew StrictBool = Field(description='The lease renews itself shortly before period_end (an hour by default) while a macOS sandbox is active on it; an idle lease lapses instead.')
  • created_at datetime
  • end_reason Optional[StrictStr] = Field(default=None, description='expired | released | charge_failed | not_accepted | reissued | operator.')
  • ended_at Optional[datetime] = None
  • id StrictStr = Field(description='External reservation id (region-tagged).')
  • lease_generation StrictInt
  • leasing_since Optional[datetime] = None
  • org_id StrictStr
  • origin StrictStr = Field(description='explicit (bought by POST /reservations or a create with reservation: "new") | auto (bought by a macOS create under the organization\'s auto-reserve setting).')
  • period_end Optional[datetime] = Field(default=None, description='When the lease ends unless renewed. Absent until a Mac first claims it (period 1 starts at the claim, so waiting for a Mac is not paid time).')
  • period_hours StrictInt = Field(description='The period length in hours.')
  • period_n StrictInt = Field(description='The current paid period (1-based).')
  • period_start Optional[datetime] = None
  • project_id StrictStr = Field(description="The project whose key bought the lease. The lease serves every project of the org; this project's monthly budget gates its renewals, manual and automatic (project_budget_exceeded while the project is held).")
  • region StrictStr
  • reissued_at Optional[datetime] = Field(default=None, description='Set when the lease moved to another Mac after its Mac was lost.')
  • renewal_error Optional[StrictStr] = Field(default=None, description='Why the renewal of the next period failed (billing refused it, or the balance was too low); the lease ends at period_end unless renewed by hand. Null when no renewal has failed.')
  • renewal_pending StrictBool = Field(description="A renewal charge is still waiting for billing's answer.")
  • runner_id Optional[StrictStr] = Field(default=None, description='The Mac holding the lease; absent until a Mac claims it.')
  • slots_used StrictInt = Field(description="macOS VMs currently occupying this lease's Mac.")
  • status StrictStr = Field(description='pending_charge | leasing | active | ending | released | failed.')
  • vms_per_mac StrictInt
  • additional_properties Dict[str, Any] = {}
model_config
model_config = ConfigDict(populate_by_name=True, validate_assignment=True, protected_namespaces=())

MacReservation.to_str

def to_str() -> str

Returns the string representation of the model using alias

MacReservation.to_json

def to_json() -> str

Returns the JSON representation of the model using alias

MacReservation.from_json

@classmethod
def from_json(json_str: str) -> Optional[Self]

Create an instance of MacReservation from a JSON string

MacReservation.to_dict

def to_dict() -> Dict[str, Any]

Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's self.model_dump(by_alias=True):

  • None is only added to the output dict for nullable fields that were set at model initialization. Other fields with value None are ignored.
  • Fields in self.additional_properties are added to the output dict.

MacReservation.from_dict

@classmethod
def from_dict(obj: Optional[Dict[str, Any]]) -> Optional[Self]

Create an instance of MacReservation from a dict