pub struct CommandsClient { /* private fields */ }Expand description
High-level client for invoking commands on Alien deployments.
Implementations§
Source§impl CommandsClient
impl CommandsClient
Sourcepub fn new(manager_url: &str, deployment_id: &str, token: &str) -> Self
pub fn new(manager_url: &str, deployment_id: &str, token: &str) -> Self
Create a new commands client with default config.
Sourcepub fn with_config(
manager_url: &str,
deployment_id: &str,
token: &str,
config: CommandsClientConfig,
) -> Self
pub fn with_config( manager_url: &str, deployment_id: &str, token: &str, config: CommandsClientConfig, ) -> Self
Create a new commands client with custom config.
Sourcepub fn with_http_client(
manager_url: &str,
deployment_id: &str,
http_client: Client,
config: CommandsClientConfig,
) -> Self
pub fn with_http_client( manager_url: &str, deployment_id: &str, http_client: Client, config: CommandsClientConfig, ) -> Self
Build a client over a caller-supplied HTTP client, reusing the headers
it already carries (the auth header, and the workspace header used in
platform mode). with_config builds a token-only client and can’t add
those.
Sourcepub async fn invoke<P: Serialize, R: DeserializeOwned>(
&self,
command: &str,
params: P,
) -> Result<R, CommandError>
pub async fn invoke<P: Serialize, R: DeserializeOwned>( &self, command: &str, params: P, ) -> Result<R, CommandError>
Invoke a command and wait for the result.
Sends params inline, polls for completion, and decodes the response.
Sourcepub async fn invoke_with_options<P: Serialize, R: DeserializeOwned>(
&self,
command: &str,
params: P,
options: Option<InvokeOptions>,
) -> Result<R, CommandError>
pub async fn invoke_with_options<P: Serialize, R: DeserializeOwned>( &self, command: &str, params: P, options: Option<InvokeOptions>, ) -> Result<R, CommandError>
Invoke a command with options and wait for the result.
Sourcepub fn target(&self, resource_id: impl Into<String>) -> TargetedCommands<'_>
pub fn target(&self, resource_id: impl Into<String>) -> TargetedCommands<'_>
Scope this client to one target command-capable resource: every
invoke/invoke_with_options/create call made through the
returned builder presets target_resource_id to resource_id,
mirroring the TypeScript .target(name).invoke(...) shorthand.
If the caller also passes an InvokeOptions with its own
target_resource_id set, the builder’s target silently wins —
passing two different targets is a programmer error, not a runtime
conflict this builder tries to detect.
Sourcepub async fn create<P: Serialize>(
&self,
command: &str,
params: P,
options: Option<&InvokeOptions>,
) -> Result<String, CommandError>
pub async fn create<P: Serialize>( &self, command: &str, params: P, options: Option<&InvokeOptions>, ) -> Result<String, CommandError>
Create a command without waiting for the result. Returns the command ID.