Skip to main content
See Services for usage and limits.

Service

Properties use the last response without making a request.

Microsandbox::Service.builder()

Start a builder for a Service.

Parameters

slugString
Globally unique Service slug.

Returns

A builder to set the target on, then create.

Microsandbox::Service.create()

Create a Service without retrying. A nil target or port zero raises InvalidConfigError before any request. Repeating a create with the same slug and target returns the existing Service while it is enabled.

Parameters

slugString
Globally unique Service slug.
Running sandbox and port that receive requests.

Microsandbox::Service.get()

Get a Service by slug.

Parameters

slugString
Service slug.

Returns

The Service’s current state.

Microsandbox::Service.list()

List one page in slug order, including disabled and detached Services. A limit outside 1 through 100 raises InvalidConfigError before any request.

Keyword parameters

sandboxString | nil
Only Services targeting this sandbox.
cursorString | nil
Opaque cursor returned by the previous page.
limitInteger | nil
Page size from 1 through 100; defaults to 20.

Returns

”services”Array<Service>
Services in this page, in slug order.
”next_cursor”String | nil
Cursor for the next page, or nil on the final page.

Instance properties

svc.slug

String — The Service slug.

svc.url

String — The public URL as returned by the backend.

svc.status

String — "enabled", "disabled", "detached", or "unknown", as of the read that returned this value. refresh returns a current copy.

svc.target

ServiceTarget | nil — The target, or nil when detached.

svc.created_at

String — RFC 3339 creation timestamp.

svc.updated_at

String — RFC 3339 timestamp of the latest state change.

Instance methods

svc.update()

Change the target without retrying. target: is required; a nil target or port zero raises InvalidConfigError before any request. Setting a target also enables or reattaches the Service.

Keyword parameters

Running target; also enables or reattaches the Service.

Returns

The Service as committed.

svc.enable()

Enable the Service without retrying. Set a target instead when it is detached.

svc.disable()

Disable the Service without retrying while retaining its target.

svc.remove()

Remove the Service and release its slug without retrying.

svc.refresh()

Get the Service again and return its current state. This object is not changed.

ServiceBuilder

builder.target()

Set the running sandbox and port that receive requests.

Parameters

sandboxString
Current name of a running sandbox.
portInteger
Sandbox port from 1 through 65,535. A negative number or one above 65,535 raises RangeError before any request.

builder.create()

Create the Service without retrying; consumes the builder.

ServiceTarget

A Data value; targets compare by value.

target.sandbox

String — Current name of the target sandbox.

target.port

Integer — Sandbox port from 1 through 65,535.

ServiceError

Microsandbox::ServiceError reports a refused Service change or an unknown outcome. A missing Service raises ServiceNotFoundError, an unavailable slug raises ServiceAlreadyExistsError, and a missing target sandbox raises SandboxNotFoundError.

error.slug

String — Service slug.

error.reason

String — One of the Microsandbox::ServiceErrorReason constants below.

error.retry_after

Float | nil — Retry delay in seconds when the backend returns one.

error.changed

String — "unchanged" or "unknown". Unknown means the change may have been applied; get and check the Service. Every Microsandbox::Error raised by create, update, enable, disable, or remove exposes this property, not only ServiceError.

error.raw_code

String | nil — Unrecognized refusal code when reason is ServiceErrorReason::OTHER.

error.raw_status

Integer | nil — Raw HTTP status when reason is ServiceErrorReason::OTHER.

error.raw_message

String | nil — Raw refusal message when reason is ServiceErrorReason::OTHER.

Service error reasons

ServiceErrorReason::SERVICE_QUOTA_EXCEEDED
The organization’s Service limit was reached. Remove a Service or request a higher limit.
ServiceErrorReason::SANDBOX_SERVICE_LIMIT_EXCEEDED
The target sandbox’s Service limit was reached. Remove or move a Service, or request a higher limit.
ServiceErrorReason::SERVICE_CONFLICT
Another change to the Service committed first. Get it, then retry.
ServiceErrorReason::SERVICE_DETACHED
The Service is detached. Set a target.
ServiceErrorReason::TARGET_UNREACHABLE
The target sandbox cannot be reached right now. Retry later, after retry_after when set.
ServiceErrorReason::SANDBOX_NOT_RUNNING
The target sandbox is not running. Start it, then retry.
ServiceErrorReason::SERVICE_CHANGES_PAUSED
Service changes are paused. Retry later, after retry_after when set.
ServiceErrorReason::OUTCOME_UNKNOWN
The change may have been applied. Get and check the Service before retrying.
ServiceErrorReason::OTHER
A refusal this SDK does not recognize. raw_code, raw_status, and raw_message hold what was returned; changed still reports the outcome.