Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

A configured Sail client. Cheap to clone; shares transport across clones.

Implementations§

Source§

impl Client

Source

pub fn builder(api_key: impl Into<String>) -> ClientBuilder

Start a ClientBuilder.

Source

pub fn from_env() -> Result<Client, SailError>

Build a client from the environment (SAIL_API_KEY, …).

Source

pub fn from_config(config: Config) -> Result<Client, SailError>

Build a client from an already-resolved Config.

Source

pub fn config(&self) -> &Config

The resolved configuration.

Source

pub async fn create_sailbox( &self, req: &CreateSailboxRequest, timeout: Option<Duration>, ) -> Result<Sailbox, SailError>

Create a Sailbox. timeout bounds each attempt of the synchronous create (which can take minutes server-side); the call retries with one idempotency key so the backend can dedupe rather than duplicate, and gives up after roughly max_attempts * timeout. An interrupted or re-invoked create is a new request and may leave a prior Sailbox behind under the same name. 10 minutes is a good default; None leaves each attempt unbounded. If the budget is exhausted the Sailbox may still be coming up server-side; find or terminate it by name.

Source

pub async fn list_sailboxes( &self, query: &ListSailboxesQuery, ) -> Result<SailboxPage, SailError>

List Sailboxes in the current org.

Source

pub async fn sailbox_spend( &self, query: &SailboxSpendQuery, ) -> Result<SailboxSpendResponse, SailError>

Estimate Sailbox spend for the current organization over a time window.

Source

pub async fn sailbox_metrics( &self, sailbox_id: &str, query: &SailboxMetricsQuery, ) -> Result<SailboxMetricsResponse, SailError>

Fetch a Sailbox’s resource-usage time series.

Source

pub async fn create_from_checkpoint( &self, checkpoint_id: &str, name: Option<&str>, timeout: Option<Duration>, ) -> Result<Sailbox, SailError>

Create a new running Sailbox from a durable checkpoint handle. The new Sailbox restores the memory saved in the checkpoint as well as the writable disk, so processes the original was running carry on here, and it runs independently of the Sailbox that took the checkpoint. Commands started with Sailbox::exec stop here, though their writes up to the checkpoint are kept, and one started with background keeps running. Start the other execs the new Sailbox needs. Sometimes it comes up cold instead, with the disk intact and nothing running, and a Sailbox that mounts a volume always does. Volumes are mounted on it at the same paths as on the original, and they are the same volumes, so both Sailboxes read and write the same files.

name sets the new Sailbox’s display name, and the server derives one when it is omitted. timeout is accepted and ignored: the call blocks until the restore finishes, so apply your own deadline if you need one. It must be positive when given.

Source

pub async fn org_ssh_ca_public_key(&self) -> Result<String, SailError>

The caller org’s SSH CA public key (created on first use).

Source

pub async fn issue_user_cert( &self, public_key: &str, timeout: Option<Duration>, ) -> Result<IssuedUserCert, SailError>

Sign public_key into a short-lived org-CA certificate (principal root). timeout (seconds) bounds a single no-retry attempt; None retries.

Source

pub async fn get_volume( &self, name: &str, mint_if_missing: bool, ) -> Result<VolumeInfo, SailError>

Look up (optionally minting) an NFS volume by name.

Source

pub async fn list_volumes( &self, max_objects: Option<i64>, ) -> Result<Vec<VolumeInfo>, SailError>

List NFS volumes in the current org.

Source

pub async fn delete_volume( &self, volume_id: &str, allow_missing: bool, ) -> Result<Option<VolumeInfo>, SailError>

Delete a volume by id.

Source

pub async fn find_app( &self, name: &str, mint_if_missing: bool, ) -> Result<App, SailError>

Find an app by name, optionally minting it.

Source

pub async fn list_apps(&self) -> Result<Vec<App>, SailError>

Every app the current org owns, newest first.

Source§

impl Client

Source

pub async fn build_image( &self, spec: &ImageSpec, retry_timeout_secs: f64, mode: BuildMode, ) -> Result<ImageBuild, SailError>

Submit or resume a custom image build. Poll Client::get_image_build_status until the status is ready or failed, or use Client::build_image_definition for the whole pipeline.

mode selects whether an image already built for this spec satisfies the call or the image is built again; see BuildMode.

Source

pub async fn get_image_build_status( &self, image_id: &str, retry_timeout_secs: f64, ) -> Result<ImageBuild, SailError>

Poll one custom image build’s status.

Source

pub async fn resolve_image( &self, def: &ImageDefinition, ) -> Result<ImageSpec, SailError>

Resolve an ImageDefinition into a content-addressed ImageSpec: walk local directories, hash every file, and upload content the server does not already have.

Source

pub async fn build_image_definition( &self, def: &ImageDefinition, timeout: Duration, mode: BuildMode, ) -> Result<ImageSpec, SailError>

Resolve an ImageDefinition and build it to ready, returning the content-addressed ImageSpec to create Sailboxes from. A bare builtin base skips the build. timeout bounds the whole pipeline (hashing, uploads, and the build); 30 minutes is a good default, and Duration::MAX waits indefinitely. Local files are re-hashed on every call, so edits always reach the build, and rebuilding an unchanged, already-built image returns quickly. For an image imported from a registry (ImageDefinition::oci_ref), the returned spec is pinned to the exact registry version the build used, so Sailboxes created from it get those bytes even if the tag moves later.

mode selects whether the image already built for this definition satisfies the call or the image is built again; see BuildMode.

Source§

impl Client

Source

pub fn sailbox(&self, sailbox_id: impl Into<String>) -> Sailbox

Bind an existing Sailbox id to this client without a network call, giving the method-style surface over it.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more