Service
Properties use the last response without making a request.Microsandbox::Service.builder()
Parameters
slugStringGlobally unique Service slug.
Returns
A builder to set the target on, then create.
Microsandbox::Service.create()
Example
Example
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
slugStringGlobally unique Service slug.
targetServiceTargetRunning sandbox and port that receive requests.
Microsandbox::Service.get()
Parameters
slugStringService slug.
Returns
The Service’s current state.
Microsandbox::Service.list()
InvalidConfigError before any request.
Example
Example
Keyword parameters
sandboxString | nilOnly Services targeting this sandbox.
cursorString | nilOpaque cursor returned by the previous page.
limitInteger | nilPage size from 1 through 100; defaults to 20.
Returns
”services”Array<Service>Services in this page, in slug order.
”next_cursor”String | nilCursor 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()
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
targetServiceTargetRunning target; also enables or reattaches the Service.
Returns
The Service as committed.
svc.enable()
svc.disable()
svc.remove()
svc.refresh()
ServiceBuilder
builder.target()
Parameters
sandboxStringCurrent name of a running sandbox.
portIntegerSandbox port from 1 through 65,535. A negative number or one above 65,535 raises
RangeError before any request.builder.create()
Example
Example
ServiceTarget
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_EXCEEDEDThe organization’s Service limit was reached. Remove a Service or request a higher limit.
ServiceErrorReason::SANDBOX_SERVICE_LIMIT_EXCEEDEDThe target sandbox’s Service limit was reached. Remove or move a Service, or request a higher limit.
ServiceErrorReason::SERVICE_CONFLICTAnother change to the Service committed first. Get it, then retry.
ServiceErrorReason::SERVICE_DETACHEDThe Service is detached. Set a target.
ServiceErrorReason::TARGET_UNREACHABLEThe target sandbox cannot be reached right now. Retry later, after
retry_after when set.ServiceErrorReason::SANDBOX_NOT_RUNNINGThe target sandbox is not running. Start it, then retry.
ServiceErrorReason::SERVICE_CHANGES_PAUSEDService changes are paused. Retry later, after
retry_after when set.ServiceErrorReason::OUTCOME_UNKNOWNThe change may have been applied. Get and check the Service before retrying.
ServiceErrorReason::OTHERA refusal this SDK does not recognize.
raw_code, raw_status, and raw_message hold what was returned; changed still reports the outcome.