Service
Properties use the last response without making a request.Static methods
Service.create()
Example
Example
InvalidConfigError before any request. Repeating a create with the same slug and target returns the existing Service while it is enabled. Get and check the Service if the task is cancelled after the request is sent.
Parameters
slugstrService slug, e.g.
“my-app”.targetServiceTargetThe running sandbox and port that receive requests. The port is 1 through 65535.
Returns
The Service as committed.
Service.get()
Parameters
slugstrService slug.
Returns
The Service’s current state.
Service.list()
Returns
One page of Services.
Service.list_with()
Example
Example
InvalidConfigError before any request.
Parameters
sandboxstr | NoneTarget sandbox; an unknown name returns an empty page.
cursorstr | NoneA previous
next_cursor.limitint | NonePage size from 1 to 100; defaults to 20.
Returns
One page of Services.
Instance properties
svc.slug
str
The Service slug.
svc.url
str
The public URL as returned by the backend.
svc.status
ServiceStatus
Whether the Service routes requests, is disabled, or has no target, as of the read that returned this value. refresh() returns a current copy.
svc.target
ServiceTarget | None
The target, or None when the Service is detached.
svc.created_at
float
The creation time in milliseconds since epoch.
svc.updated_at
float
The last state-change time in milliseconds since epoch.
Instance methods
svc.update()
Example
Example
target is required; None or port zero raises InvalidConfigError before any request. Get and check the Service if the task is cancelled after the request is sent.
Parameters
targetServiceTargetRunning target; also enables or reattaches the Service.
Returns
The Service as committed.
svc.enable()
update() instead.
svc.disable()
svc.remove()
svc.refresh()
Returns
The Service’s current state.
ServiceStatus
ServiceStatus.ENABLED”enabled”Routes requests to its target.
ServiceStatus.DISABLED”disabled”Retains its target without routing requests.
ServiceStatus.DETACHED”detached”Has no target.
ServiceStatus.UNKNOWN”unknown”The backend returned an unrecognized status.
ServiceTarget
sandboxstrCurrent name of the target sandbox.
portintSandbox port, 1 through 65535. A negative number or one above 65535 raises
OverflowError before any request.ServicePage
serviceslist[Service]Services in this page, in slug order.
next_cursorstr | NoneCursor for the next page, or
None on the final page.ServiceError
A refused Service change or an unknown outcome. A missing Service raisesServiceNotFoundError, an unavailable slug raises ServiceAlreadyExistsError, and a missing target sandbox raises SandboxNotFoundError.
Every exception raised by Service create, update, enable, disable, or remove carries changed, not only ServiceError: MicrosandboxError.changed is a ChangeState for those calls and None for other calls.
slugstrService slug.
reasonServiceErrorReasonReason for the failure.
retry_afterfloat | NoneRetry delay returned with the refusal, in seconds, or
None.changedChangeStateChangeState.UNKNOWN means the change may have been applied; get and check the Service.raw_codestr | NoneRaw error code of a refusal with reason
OTHER, or None.raw_statusint | NoneHTTP status of a refusal with reason
OTHER, or None.raw_messagestr | NoneMessage of a refusal with reason
OTHER, or None.ServiceErrorReason
SERVICE_QUOTA_EXCEEDEDThe organization’s Service limit was reached. Remove a Service or request a higher limit.
SANDBOX_SERVICE_LIMIT_EXCEEDEDThe target sandbox’s Service limit was reached. Remove or move a Service, or request a higher limit.
SERVICE_CONFLICTAnother change to the Service committed first. Get it, then retry.
SERVICE_DETACHEDThe Service is detached. Set a target.
TARGET_UNREACHABLEThe target sandbox cannot be reached right now. Retry later, after
retry_after when set.SANDBOX_NOT_RUNNINGThe target sandbox is not running. Start it, then retry.
SERVICE_CHANGES_PAUSEDService changes are paused. Retry later, after
retry_after when set.OUTCOME_UNKNOWNThe change may have been applied. Get and check the Service before retrying.
OTHERA refusal this SDK does not recognize.
raw_code, raw_status, and raw_message hold what was returned; changed still reports the outcome.ChangeState
ChangeState.UNCHANGED”unchanged”Nothing changed.
ChangeState.UNKNOWN”unknown”The change may have been applied. Get and check the Service before retrying.