pub struct TalosClient { /* private fields */ }Implementations§
Source§impl TalosClient
impl TalosClient
pub async fn new(config: TalosClientConfig) -> Result<Self>
Sourcepub async fn from_talosconfig(
config: &TalosConfig,
context_name: Option<&str>,
) -> Result<Self>
pub async fn from_talosconfig( config: &TalosConfig, context_name: Option<&str>, ) -> Result<Self>
Create a client from a TalosConfig context
This loads credentials from the talosconfig and connects to the first endpoint.
§Example
use talos_api_rs::{TalosClient, config::TalosConfig};
let config = TalosConfig::load_with_env()?;
let client = TalosClient::from_talosconfig(&config, None).await?;§Arguments
config- The loaded TalosConfigcontext_name- Optional context name to use (defaults to active context)
Sourcepub fn with_node(&self, target: NodeTarget) -> Self
pub fn with_node(&self, target: NodeTarget) -> Self
Create a new client targeting a specific node
§Example
use talos_api_rs::{TalosClient, TalosClientConfig};
use talos_api_rs::client::NodeTarget;
let client = TalosClient::new(TalosClientConfig::default()).await?;
// Target a specific node for API calls
let targeted = client.with_node(NodeTarget::single("192.168.1.10"));
let hostname = targeted.hostname().await?;Sourcepub fn with_nodes(
&self,
nodes: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_nodes( &self, nodes: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Create a new client targeting multiple nodes
Convenience method for cluster-wide operations.
Sourcepub fn node_target(&self) -> &NodeTarget
pub fn node_target(&self) -> &NodeTarget
Get the current node target
Sourcepub fn version(&self) -> VersionServiceClient<Channel>
pub fn version(&self) -> VersionServiceClient<Channel>
Access the Version API group
Sourcepub fn machine(&self) -> MachineServiceClient<Channel>
pub fn machine(&self) -> MachineServiceClient<Channel>
Access the Machine API group
Sourcepub async fn apply_configuration(
&self,
request: ApplyConfigurationRequest,
) -> Result<ApplyConfigurationResponse>
pub async fn apply_configuration( &self, request: ApplyConfigurationRequest, ) -> Result<ApplyConfigurationResponse>
Apply a configuration to the node.
This is a high-level wrapper around the MachineService::ApplyConfiguration RPC.
§Example
use talos_api_rs::{TalosClient, TalosClientConfig, ApplyConfigurationRequest, ApplyMode};
let client = TalosClient::new(TalosClientConfig {
endpoint: "https://192.168.1.100:50000".to_string(),
insecure: true,
..Default::default()
}).await?;
// Apply configuration in dry-run mode
let request = ApplyConfigurationRequest::builder()
.config_yaml("machine:\n type: worker")
.mode(ApplyMode::NoReboot)
.dry_run(true)
.build();
let response = client.apply_configuration(request).await?;
println!("Warnings: {:?}", response.all_warnings());§Errors
Returns an error if the RPC call fails or the configuration is invalid.
Sourcepub async fn apply_configuration_yaml(
&self,
yaml: &str,
mode: ApplyMode,
dry_run: bool,
) -> Result<ApplyConfigurationResponse>
pub async fn apply_configuration_yaml( &self, yaml: &str, mode: ApplyMode, dry_run: bool, ) -> Result<ApplyConfigurationResponse>
Apply a YAML configuration string to the node.
Convenience method for simple configuration application.
§Example
use talos_api_rs::{TalosClient, TalosClientConfig, ApplyMode};
let client = TalosClient::new(TalosClientConfig::default()).await?;
let config_yaml = std::fs::read_to_string("machine.yaml")?;
let response = client.apply_configuration_yaml(&config_yaml, ApplyMode::Auto, false).await?;Sourcepub async fn bootstrap(
&self,
request: BootstrapRequest,
) -> Result<BootstrapResponse>
pub async fn bootstrap( &self, request: BootstrapRequest, ) -> Result<BootstrapResponse>
Bootstrap the etcd cluster on this node.
This initializes a new etcd cluster. This should only be called ONCE on the first control-plane node when creating a new Talos cluster.
§Example
use talos_api_rs::{TalosClient, TalosClientConfig, BootstrapRequest};
let client = TalosClient::new(TalosClientConfig::default()).await?;
// Bootstrap a new cluster
let response = client.bootstrap(BootstrapRequest::new()).await?;
println!("Bootstrap complete: {:?}", response.first());§Recovery
To recover from an etcd snapshot (uploaded via EtcdRecover RPC):
use talos_api_rs::{TalosClient, TalosClientConfig, BootstrapRequest};
let client = TalosClient::new(TalosClientConfig::default()).await?;
let response = client.bootstrap(BootstrapRequest::recovery()).await?;§Errors
Returns an error if:
- The node is not a control-plane node
- etcd is already bootstrapped
- Network/connection issues
Sourcepub async fn bootstrap_cluster(&self) -> Result<BootstrapResponse>
pub async fn bootstrap_cluster(&self) -> Result<BootstrapResponse>
Bootstrap a new etcd cluster (convenience method).
Equivalent to bootstrap(BootstrapRequest::new()).
Sourcepub async fn kubeconfig(&self) -> Result<KubeconfigResponse>
pub async fn kubeconfig(&self) -> Result<KubeconfigResponse>
Retrieve the kubeconfig from the cluster.
This is a server-streaming RPC that retrieves the kubeconfig file from a control-plane node. The kubeconfig can be used to access the Kubernetes API of the cluster.
§Example
use talos_api_rs::{TalosClient, TalosClientConfig};
let client = TalosClient::new(TalosClientConfig::default()).await?;
// Get kubeconfig
let kubeconfig = client.kubeconfig().await?;
println!("Kubeconfig from node: {:?}", kubeconfig.node);
// Write to file
kubeconfig.write_to_file("kubeconfig.yaml")?;
// Or get as string
let yaml = kubeconfig.as_str()?;
println!("{}", yaml);§Errors
Returns an error if:
- The node is not a control-plane node
- The cluster is not yet bootstrapped
- Network/connection issues
Sourcepub async fn reset(&self, request: ResetRequest) -> Result<ResetResponse>
pub async fn reset(&self, request: ResetRequest) -> Result<ResetResponse>
Reset a Talos node, optionally wiping disks.
§Warning
This is a destructive operation. The node will be reset and may lose all data depending on the wipe mode configured.
§Arguments
request- The reset request configuration
§Example
use talos_api_rs::{TalosClient, TalosClientConfig, ResetRequest};
let config = TalosClientConfig::new("https://192.168.1.100:50000".parse()?);
let client = TalosClient::new(config).await?;
// Graceful reset (leaves etcd cluster first)
let response = client.reset(ResetRequest::graceful()).await?;
// Force reset with full disk wipe
let response = client.reset(ResetRequest::force()).await?;
// Custom reset
let response = client.reset(
ResetRequest::builder()
.graceful(true)
.reboot(true)
.build()
).await?;Sourcepub async fn reset_graceful(&self) -> Result<ResetResponse>
pub async fn reset_graceful(&self) -> Result<ResetResponse>
Gracefully reset a Talos node.
This is a convenience method that performs a graceful reset, which:
- Leaves the etcd cluster gracefully (for control plane nodes)
- Reboots after reset
- Does not wipe disks
For more control, use reset with a custom ResetRequest.
Sourcepub async fn etcd_member_list(
&self,
request: EtcdMemberListRequest,
) -> Result<EtcdMemberListResponse>
pub async fn etcd_member_list( &self, request: EtcdMemberListRequest, ) -> Result<EtcdMemberListResponse>
List etcd cluster members.
§Example
use talos_api_rs::{TalosClient, TalosClientConfig, EtcdMemberListRequest};
let config = TalosClientConfig::new("https://192.168.1.100:50000".parse()?);
let client = TalosClient::new(config).await?;
let response = client.etcd_member_list(EtcdMemberListRequest::new()).await?;
for member in response.all_members() {
println!("{}: {}", member.id, member.hostname);
}Sourcepub async fn etcd_remove_member_by_id(
&self,
request: EtcdRemoveMemberByIdRequest,
) -> Result<EtcdRemoveMemberByIdResponse>
pub async fn etcd_remove_member_by_id( &self, request: EtcdRemoveMemberByIdRequest, ) -> Result<EtcdRemoveMemberByIdResponse>
Remove an etcd member by ID.
Use this to remove members that no longer have an associated Talos node.
For nodes that are still running, use etcd_leave_cluster.
§Example
use talos_api_rs::{TalosClient, TalosClientConfig, EtcdRemoveMemberByIdRequest};
let config = TalosClientConfig::new("https://192.168.1.100:50000".parse()?);
let client = TalosClient::new(config).await?;
// First, find the member ID
let members = client.etcd_member_list(Default::default()).await?;
if let Some(member) = members.find_by_hostname("old-node") {
client.etcd_remove_member_by_id(
EtcdRemoveMemberByIdRequest::new(member.id)
).await?;
}Sourcepub async fn etcd_leave_cluster(
&self,
request: EtcdLeaveClusterRequest,
) -> Result<EtcdLeaveClusterResponse>
pub async fn etcd_leave_cluster( &self, request: EtcdLeaveClusterRequest, ) -> Result<EtcdLeaveClusterResponse>
Make a node leave the etcd cluster gracefully.
This should be called on the node that is being removed.
Sourcepub async fn etcd_forfeit_leadership(
&self,
request: EtcdForfeitLeadershipRequest,
) -> Result<EtcdForfeitLeadershipResponse>
pub async fn etcd_forfeit_leadership( &self, request: EtcdForfeitLeadershipRequest, ) -> Result<EtcdForfeitLeadershipResponse>
Forfeit etcd leadership.
Causes the current leader to step down and trigger a new election.
Sourcepub async fn etcd_status(&self) -> Result<EtcdStatusResponse>
pub async fn etcd_status(&self) -> Result<EtcdStatusResponse>
Get etcd status for the current member.
Sourcepub async fn etcd_alarm_list(&self) -> Result<EtcdAlarmListResponse>
pub async fn etcd_alarm_list(&self) -> Result<EtcdAlarmListResponse>
List etcd alarms.
Sourcepub async fn etcd_alarm_disarm(&self) -> Result<EtcdAlarmDisarmResponse>
pub async fn etcd_alarm_disarm(&self) -> Result<EtcdAlarmDisarmResponse>
Disarm etcd alarms.
Sourcepub async fn etcd_defragment(&self) -> Result<EtcdDefragmentResponse>
pub async fn etcd_defragment(&self) -> Result<EtcdDefragmentResponse>
Defragment etcd storage.
Warning: This is a resource-heavy operation.
Sourcepub async fn dmesg(&self, request: DmesgRequest) -> Result<DmesgResponse>
pub async fn dmesg(&self, request: DmesgRequest) -> Result<DmesgResponse>
Get kernel message buffer (dmesg).
This is a server-streaming RPC that returns kernel messages.
§Example
use talos_api_rs::{TalosClient, TalosClientConfig, DmesgRequest};
let config = TalosClientConfig::new("https://192.168.1.100:50000".parse()?);
let client = TalosClient::new(config).await?;
let dmesg = client.dmesg(DmesgRequest::new()).await?;
println!("{}", dmesg.as_string_lossy());Sourcepub async fn upgrade(&self, request: UpgradeRequest) -> Result<UpgradeResponse>
pub async fn upgrade(&self, request: UpgradeRequest) -> Result<UpgradeResponse>
Upgrade a Talos node to a new version.
§Example
use talos_api_rs::{TalosClient, TalosClientConfig, UpgradeRequest};
let config = TalosClientConfig::new("https://192.168.1.100:50000".parse()?);
let client = TalosClient::new(config).await?;
// Upgrade to a specific version
let response = client.upgrade(
UpgradeRequest::new("ghcr.io/siderolabs/installer:v1.6.0")
).await?;
// Staged upgrade (downloads but doesn't apply until reboot)
let response = client.upgrade(
UpgradeRequest::builder("ghcr.io/siderolabs/installer:v1.6.0")
.stage(true)
.preserve(true)
.build()
).await?;Sourcepub async fn service_start(
&self,
request: ServiceStartRequest,
) -> Result<ServiceStartResponse>
pub async fn service_start( &self, request: ServiceStartRequest, ) -> Result<ServiceStartResponse>
Start a service.
Sourcepub async fn service_stop(
&self,
request: ServiceStopRequest,
) -> Result<ServiceStopResponse>
pub async fn service_stop( &self, request: ServiceStopRequest, ) -> Result<ServiceStopResponse>
Stop a service.
Sourcepub async fn service_restart(
&self,
request: ServiceRestartRequest,
) -> Result<ServiceRestartResponse>
pub async fn service_restart( &self, request: ServiceRestartRequest, ) -> Result<ServiceRestartResponse>
Restart a service.
Sourcepub async fn logs(&self, request: LogsRequest) -> Result<LogsResponse>
pub async fn logs(&self, request: LogsRequest) -> Result<LogsResponse>
Get service/container logs (server-streaming).
Sourcepub async fn load_avg(&self) -> Result<LoadAvgResponse>
pub async fn load_avg(&self) -> Result<LoadAvgResponse>
Get system load averages.
Sourcepub async fn memory(&self) -> Result<MemoryResponse>
pub async fn memory(&self) -> Result<MemoryResponse>
Get memory information.
Sourcepub async fn cpu_info(&self) -> Result<CpuInfoResponse>
pub async fn cpu_info(&self) -> Result<CpuInfoResponse>
Get CPU information.
Sourcepub async fn disk_stats(&self) -> Result<DiskStatsResponse>
pub async fn disk_stats(&self) -> Result<DiskStatsResponse>
Get disk statistics.
Sourcepub async fn network_device_stats(&self) -> Result<NetworkDeviceStatsResponse>
pub async fn network_device_stats(&self) -> Result<NetworkDeviceStatsResponse>
Get network device statistics.
Sourcepub async fn mounts(&self) -> Result<MountsResponse>
pub async fn mounts(&self) -> Result<MountsResponse>
Get mount points.
Sourcepub async fn processes(&self) -> Result<ProcessesResponse>
pub async fn processes(&self) -> Result<ProcessesResponse>
Get process list.
Sourcepub async fn list(&self, request: ListRequest) -> Result<ListResponse>
pub async fn list(&self, request: ListRequest) -> Result<ListResponse>
List directory contents (server-streaming).
Sourcepub async fn read(&self, request: ReadRequest) -> Result<ReadResponse>
pub async fn read(&self, request: ReadRequest) -> Result<ReadResponse>
Read a file (server-streaming).
Sourcepub async fn copy(&self, request: CopyRequest) -> Result<CopyResponse>
pub async fn copy(&self, request: CopyRequest) -> Result<CopyResponse>
Copy a file or directory as tar archive (server-streaming).
Sourcepub async fn disk_usage(
&self,
request: DiskUsageRequest,
) -> Result<DiskUsageResponse>
pub async fn disk_usage( &self, request: DiskUsageRequest, ) -> Result<DiskUsageResponse>
Get disk usage (server-streaming).
Sourcepub async fn rollback(&self) -> Result<RollbackResponse>
pub async fn rollback(&self) -> Result<RollbackResponse>
Rollback a Talos node to the previous installed version.
Sourcepub async fn generate_client_configuration(
&self,
request: GenerateClientConfigurationRequest,
) -> Result<GenerateClientConfigurationResponse>
pub async fn generate_client_configuration( &self, request: GenerateClientConfigurationRequest, ) -> Result<GenerateClientConfigurationResponse>
Generate client configuration (talosconfig).
Sourcepub async fn packet_capture(
&self,
request: PacketCaptureRequest,
) -> Result<PacketCaptureResponse>
pub async fn packet_capture( &self, request: PacketCaptureRequest, ) -> Result<PacketCaptureResponse>
Capture packets on a network interface (server-streaming).
Sourcepub async fn netstat(&self, request: NetstatRequest) -> Result<NetstatResponse>
pub async fn netstat(&self, request: NetstatRequest) -> Result<NetstatResponse>
Get network connection information (netstat).
Sourcepub async fn image_list(
&self,
request: ImageListRequest,
) -> Result<Vec<ImageInfo>>
pub async fn image_list( &self, request: ImageListRequest, ) -> Result<Vec<ImageInfo>>
List container images in the specified containerd namespace.
Returns a list of images from the node’s containerd registry.
§Arguments
request- The image list request specifying the namespace to query.
§Example
let config = TalosClientConfig::new("https://192.168.1.100:50000");
let client = TalosClient::new(config).await?;
// List all system images
let images = client.image_list(ImageListRequest::system()).await?;
for image in images {
println!("{}: {}", image.name, image.size_human());
}
// List Kubernetes images
let cri_images = client.image_list(ImageListRequest::cri()).await?;Sourcepub async fn image_pull(
&self,
request: ImagePullRequest,
) -> Result<ImagePullResponse>
pub async fn image_pull( &self, request: ImagePullRequest, ) -> Result<ImagePullResponse>
Pull a container image into the node’s containerd registry.
Downloads and stores the specified image so it’s available locally.
§Arguments
request- The image pull request specifying the image reference and namespace.
§Example
let config = TalosClientConfig::new("https://192.168.1.100:50000");
let client = TalosClient::new(config).await?;
// Pull a specific image
let response = client.image_pull(
ImagePullRequest::new("docker.io/library/nginx:latest")
).await?;
println!("Pulled images: {:?}", response.results);Trait Implementations§
Source§impl Clone for TalosClient
impl Clone for TalosClient
Source§fn clone(&self) -> TalosClient
fn clone(&self) -> TalosClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TalosClient
impl !RefUnwindSafe for TalosClient
impl Send for TalosClient
impl Sync for TalosClient
impl Unpin for TalosClient
impl !UnwindSafe for TalosClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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