pub struct RunbeamClient { /* private fields */ }Expand description
HTTP client for Runbeam Cloud API
This client handles all communication with the Runbeam Cloud control plane, including gateway authorization and future component loading.
Implementations§
Source§impl RunbeamClient
impl RunbeamClient
Authorize a gateway and obtain a machine-scoped token
This method exchanges a user authentication token (either JWT or Laravel Sanctum) for a machine-scoped token that the gateway can use for autonomous API access. The machine token has a 30-day expiry (configured server-side).
§Authentication
This method accepts both JWT tokens and Laravel Sanctum API tokens:
- JWT tokens: Validated locally with RS256 signature verification (legacy behavior)
- Sanctum tokens: Passed directly to server for validation (format:
{id}|{token})
The token is passed to the Runbeam Cloud API in both the Authorization header and request body, where final validation and authorization occurs.
§Arguments
user_token- The user’s JWT or Sanctum API token from CLI authenticationgateway_code- The gateway instance IDmachine_public_key- Optional public key for secure communicationmetadata- Optional metadata about the gateway (array of strings)
§Returns
Returns Ok(AuthorizeResponse) with machine token and gateway details,
or Err(RunbeamError) if authorization fails.
§Example
use runbeam_sdk::RunbeamClient;
let client = RunbeamClient::new("http://runbeam.lndo.site");
// Using JWT token
let response = client.authorize_gateway(
"eyJhbGci...",
"gateway-123",
None,
None
).await?;
// Using Sanctum token
let response = client.authorize_gateway(
"1|abc123def456...",
"gateway-123",
None,
None
).await?;
println!("Machine token: {}", response.machine_token);
println!("Expires at: {}", response.expires_at);Sourcepub async fn list_gateways(
&self,
token: impl Into<String>,
) -> Result<PaginatedResponse<Gateway>, RunbeamError>
pub async fn list_gateways( &self, token: impl Into<String>, ) -> Result<PaginatedResponse<Gateway>, RunbeamError>
Sourcepub async fn get_gateway(
&self,
token: impl Into<String>,
gateway_id: impl Into<String>,
) -> Result<ResourceResponse<Gateway>, RunbeamError>
pub async fn get_gateway( &self, token: impl Into<String>, gateway_id: impl Into<String>, ) -> Result<ResourceResponse<Gateway>, RunbeamError>
Get a specific gateway by ID or code
§Authentication
Accepts JWT tokens, Sanctum API tokens, or machine tokens. The token is passed to the server for validation without local verification.
§Arguments
token- JWT, Sanctum API token, or machine token for authenticationgateway_id- The gateway ID or code
Sourcepub async fn list_services(
&self,
token: impl Into<String>,
) -> Result<PaginatedResponse<Service>, RunbeamError>
pub async fn list_services( &self, token: impl Into<String>, ) -> Result<PaginatedResponse<Service>, RunbeamError>
List all services for the authenticated team
Returns a paginated list of services across all gateways.
§Authentication
Accepts either JWT tokens or Laravel Sanctum API tokens. The token is passed to the server for validation without local verification.
§Arguments
token- JWT or Sanctum API token for authentication
Sourcepub async fn get_service(
&self,
token: impl Into<String>,
service_id: impl Into<String>,
) -> Result<ResourceResponse<Service>, RunbeamError>
pub async fn get_service( &self, token: impl Into<String>, service_id: impl Into<String>, ) -> Result<ResourceResponse<Service>, RunbeamError>
Sourcepub async fn list_endpoints(
&self,
token: impl Into<String>,
) -> Result<PaginatedResponse<Endpoint>, RunbeamError>
pub async fn list_endpoints( &self, token: impl Into<String>, ) -> Result<PaginatedResponse<Endpoint>, RunbeamError>
Sourcepub async fn list_backends(
&self,
token: impl Into<String>,
) -> Result<PaginatedResponse<Backend>, RunbeamError>
pub async fn list_backends( &self, token: impl Into<String>, ) -> Result<PaginatedResponse<Backend>, RunbeamError>
Sourcepub async fn list_pipelines(
&self,
token: impl Into<String>,
) -> Result<PaginatedResponse<Pipeline>, RunbeamError>
pub async fn list_pipelines( &self, token: impl Into<String>, ) -> Result<PaginatedResponse<Pipeline>, RunbeamError>
Trait Implementations§
Source§impl Clone for RunbeamClient
impl Clone for RunbeamClient
Source§fn clone(&self) -> RunbeamClient
fn clone(&self) -> RunbeamClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more