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) -> NoneReservationService.create
async def create(*,
region: str,
vms_per_mac: Optional[int] = None,
idempotency_key: Optional[str] = None,
auto_renew: Optional[bool] = None) -> MacReservationReserve 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) -> MacReservationReservationService.renew
async def renew(reservation_id: str) -> MacReservationRenew the reservation for its next 24-hour period, which the server charges.
ReservationService.update
async def update(reservation_id: str, *, auto_renew: bool) -> MacReservationTurn 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) -> NoneSyncReservationService.create
def create(*,
region: str,
vms_per_mac: Optional[int] = None,
idempotency_key: Optional[str] = None,
auto_renew: Optional[bool] = None) -> MacReservationReserve a Mac in region.
SyncReservationService.get
def get(reservation_id: str) -> MacReservationSyncReservationService.list
def list() -> List[MacReservation]Every reservation of the organization, in one response.
SyncReservationService.renew
def renew(reservation_id: str) -> MacReservationRenew the reservation for its next 24-hour period, which the server charges.
SyncReservationService.update
def update(reservation_id: str, *, auto_renew: bool) -> MacReservationTurn the lease's auto-renewal on or off.
MacReservation
class MacReservation(BaseModel)A Mac lease.
Attributes:
activated_atOptional[datetime] = Noneauto_renewStrictBool = Field(description='The lease renews itself shortly beforeperiod_end(an hour by default) while a macOS sandbox is active on it; an idle lease lapses instead.')created_atdatetimeend_reasonOptional[StrictStr] = Field(default=None, description='expired|released|charge_failed|not_accepted|reissued|operator.')ended_atOptional[datetime] = NoneidStrictStr = Field(description='External reservation id (region-tagged).')lease_generationStrictIntleasing_sinceOptional[datetime] = Noneorg_idStrictStroriginStrictStr = Field(description='explicit(bought byPOST /reservationsor a create withreservation: "new") |auto(bought by a macOS create under the organization\'s auto-reserve setting).')period_endOptional[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_hoursStrictInt = Field(description='The period length in hours.')period_nStrictInt = Field(description='The current paid period (1-based).')period_startOptional[datetime] = Noneproject_idStrictStr = 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_exceededwhile the project is held).")regionStrictStrreissued_atOptional[datetime] = Field(default=None, description='Set when the lease moved to another Mac after its Mac was lost.')renewal_errorOptional[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 atperiod_endunless renewed by hand. Null when no renewal has failed.')renewal_pendingStrictBool = Field(description="A renewal charge is still waiting for billing's answer.")runner_idOptional[StrictStr] = Field(default=None, description='The Mac holding the lease; absent until a Mac claims it.')slots_usedStrictInt = Field(description="macOS VMs currently occupying this lease's Mac.")statusStrictStr = Field(description='pending_charge|leasing|active|ending|released|failed.')vms_per_macStrictIntadditional_propertiesDict[str, Any] = {}
model_config
model_config = ConfigDict(populate_by_name=True, validate_assignment=True, protected_namespaces=())MacReservation.to_str
def to_str() -> strReturns the string representation of the model using alias
MacReservation.to_json
def to_json() -> strReturns 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):
Noneis only added to the output dict for nullable fields that were set at model initialization. Other fields with valueNoneare ignored.- Fields in
self.additional_propertiesare 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