Skip to main content
See Services for usage and limits.

Service

Accessors use the last response without making a request.

Service::builder()

Start a ServiceBuilder.

Parameters

slugimpl Into<String>
Service slug, e.g. “my-app”.

Returns

Builder for the new Service.

Service::get()

Get a Service by slug.

Parameters

slug&str
Service slug.

Returns

The Service’s current state.

Service::list()

List the first page in slug order, including disabled and detached Services.

Returns

One page of Services.

Service::list_with()

List a configured page in slug order. A limit outside 1 through 100 fails with MicrosandboxError::InvalidConfig before any request.

Parameters

configureimpl FnOnce(ServiceListBuilder) -> ServiceListBuilder
Sets the list options.

Returns

One page of Services.

svc.slug()

The Service slug.

svc.url()

The public URL as returned by the backend.

svc.status()

Whether the Service routes requests, is disabled, or has no target, as of the read that returned this value. refresh() returns a current copy. An unrecognized backend value is ServiceStatus::Unknown.

svc.target()

The target, or None when the Service is detached.

Returns

The current target, or None when detached.

svc.created_at()

The creation time.

svc.updated_at()

The last state-change time.

svc.update()

Change the target without retrying. After OutcomeUnknown, get and check the Service.

Parameters

configureimpl FnOnce(ServiceUpdate) -> ServiceUpdate

Returns

The Service as committed.

svc.enable()

Enable the Service without retrying. To enable a detached Service, set a running target with update() instead.

svc.disable()

Disable the Service without retrying while retaining its target.

svc.remove()

Remove the Service and release its slug without retrying. This consumes the Service.

svc.refresh()

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

Returns

The Service’s current state.

ServiceBuilder

builder.target()

Set the running sandbox and port that receive requests.

Parameters

sandboximpl Into<String>
Target sandbox name.
portu16
Sandbox port, 1 through 65535.

builder.create()

Create the Service without retrying. A missing target or port zero fails with MicrosandboxError::InvalidConfig before any request. Repeating a create with the same slug and target returns the existing Service while it is enabled.

Returns

The Service as committed.

ServiceUpdate

Fields for one target update. No fields or port zero fails with MicrosandboxError::InvalidConfig before any request.

u.target()

Set the running target. This also enables or reattaches the Service.

Parameters

sandboximpl Into<String>
Target sandbox name.
portu16
Sandbox port, 1 through 65535.

ServiceListBuilder

l.sandbox()

Filter by target sandbox. An unknown name returns an empty page.

Parameters

nameimpl Into<String>
Sandbox name.

l.limit()

Set the page size from 1 to 100; the default is 20.

Parameters

limitu32
Page size.

l.cursor()

Continue from a previous next_cursor.

Parameters

cursorimpl Into<String>
Opaque cursor.

ServicePage

servicesVec<Service>
Services in this page, in slug order.
next_cursorOption<String>
Cursor for the next page, or None on the final page.

ServiceStatus

This enum may gain variants, so a match needs a wildcard arm.
Enabled
Routes requests to its target.
Disabled
Retains its target without routing requests.
Detached
Has no target.
Unknown
The backend returned an unrecognized status.

ServiceTarget

sandboxString
Current name of the target sandbox.
portu16
Sandbox port that receives requests.

ServiceError

A refused Service change or an unknown outcome, returned as MicrosandboxError::Service { slug, error }. changed() on either error returns a ChangeState. A missing Service returns MicrosandboxError::ServiceNotFound, an unavailable slug returns MicrosandboxError::ServiceAlreadyExists, and a missing target sandbox returns MicrosandboxError::SandboxNotFound.
QuotaExceeded
The organization’s Service limit was reached. Remove a Service or request a higher limit.
SandboxLimitExceeded
The target sandbox’s Service limit was reached. Remove or move a Service, or request a higher limit.
Conflict
Another change to the Service committed first. Get it, then retry.
Detached
The Service is detached. Set a target.
TargetUnreachableretry_after: Option<Duration>
The target sandbox cannot be reached right now. Retry later, after retry_after when set.
TargetNotRunning
The target sandbox is not running. Start it, then retry.
ChangesPausedretry_after: Option<Duration>
Service changes are paused. Retry later, after retry_after when set.
OutcomeUnknown
The change may have been applied. Get and check the Service before retrying.
Othercode: String, status: u16, message: String
The change was refused with a reason this SDK does not recognize. The raw code, HTTP status, and message remain available.

ChangeState

Returned by changed() on MicrosandboxError and on ServiceError. Call changed() on every error from Service create, update, enable, disable, or remove, not only MicrosandboxError::Service. Invalid input, refusals, missing Services or sandboxes, unavailable slugs, unsupported backends, and connections that failed before the request was sent report Unchanged; other errors report Unknown.
Unchanged
Nothing changed.
Unknown
The change may have been applied. Get and check the Service before retrying.