pub struct Client { /* private fields */ }Expand description
A configured Sail client. Cheap to clone; shares transport across clones.
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder(api_key: impl Into<String>) -> ClientBuilder
pub fn builder(api_key: impl Into<String>) -> ClientBuilder
Start a ClientBuilder.
Sourcepub fn from_env() -> Result<Client, SailError>
pub fn from_env() -> Result<Client, SailError>
Build a client from the environment (SAIL_API_KEY, …).
Sourcepub fn from_config(config: Config) -> Result<Client, SailError>
pub fn from_config(config: Config) -> Result<Client, SailError>
Build a client from an already-resolved Config.
Sourcepub async fn create_sailbox(
&self,
req: &CreateSailboxRequest,
timeout: Option<Duration>,
) -> Result<Sailbox, SailError>
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.
Sourcepub async fn list_sailboxes(
&self,
query: &ListSailboxesQuery,
) -> Result<SailboxPage, SailError>
pub async fn list_sailboxes( &self, query: &ListSailboxesQuery, ) -> Result<SailboxPage, SailError>
List Sailboxes in the current org.
Sourcepub async fn sailbox_spend(
&self,
query: &SailboxSpendQuery,
) -> Result<SailboxSpendResponse, SailError>
pub async fn sailbox_spend( &self, query: &SailboxSpendQuery, ) -> Result<SailboxSpendResponse, SailError>
Estimate Sailbox spend for the current organization over a time window.
Sourcepub async fn sailbox_metrics(
&self,
sailbox_id: &str,
query: &SailboxMetricsQuery,
) -> Result<SailboxMetricsResponse, SailError>
pub async fn sailbox_metrics( &self, sailbox_id: &str, query: &SailboxMetricsQuery, ) -> Result<SailboxMetricsResponse, SailError>
Fetch a Sailbox’s resource-usage time series.
Sourcepub async fn create_from_checkpoint(
&self,
checkpoint_id: &str,
name: Option<&str>,
timeout: Option<Duration>,
) -> Result<Sailbox, SailError>
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. timeout bounds the
restore call, which otherwise blocks until the new Sailbox is
running; restoring can take many minutes while the new Sailbox
queues for capacity. A call that times out fails, and the
restore may still finish in the background; the new Sailbox then
shows up in Client::list_sailboxes. timeout must be positive
when given.
Sourcepub async fn org_ssh_ca_public_key(&self) -> Result<String, SailError>
pub async fn org_ssh_ca_public_key(&self) -> Result<String, SailError>
The caller org’s SSH CA public key (created on first use).
Sourcepub async fn issue_user_cert(
&self,
public_key: &str,
timeout: Option<Duration>,
) -> Result<IssuedUserCert, SailError>
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.
Sourcepub async fn get_volume(
&self,
name: &str,
mint_if_missing: bool,
) -> Result<VolumeInfo, SailError>
pub async fn get_volume( &self, name: &str, mint_if_missing: bool, ) -> Result<VolumeInfo, SailError>
Look up (optionally minting) an NFS volume by name.
Sourcepub async fn list_volumes(
&self,
max_objects: Option<i64>,
) -> Result<Vec<VolumeInfo>, SailError>
pub async fn list_volumes( &self, max_objects: Option<i64>, ) -> Result<Vec<VolumeInfo>, SailError>
List NFS volumes in the current org.
Sourcepub async fn delete_volume(
&self,
volume_id: &str,
allow_missing: bool,
) -> Result<Option<VolumeInfo>, SailError>
pub async fn delete_volume( &self, volume_id: &str, allow_missing: bool, ) -> Result<Option<VolumeInfo>, SailError>
Delete a volume by id.
Source§impl Client
impl Client
Sourcepub async fn build_image(
&self,
spec: &ImageSpec,
retry_timeout_secs: f64,
mode: BuildMode,
) -> Result<ImageBuild, SailError>
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.
Sourcepub async fn get_image_build_status(
&self,
image_id: &str,
retry_timeout_secs: f64,
) -> Result<ImageBuild, SailError>
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.
Sourcepub async fn resolve_image(
&self,
def: &ImageDefinition,
) -> Result<ImageSpec, SailError>
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.
Sourcepub async fn build_image_definition(
&self,
def: &ImageDefinition,
timeout: Duration,
mode: BuildMode,
) -> Result<ImageSpec, SailError>
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
base image skips the build. timeout bounds the whole pipeline,
including hashing, uploads, the build, and any automatic retries;
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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request