talos-rust-client 0.1.3

Rust gRPC client for SideroLabs Talos (mTLS, tonic, rustls)
Documentation
// This file is @generated by prost-build.
/// Disk represents a disk.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Disk {
    /// Size indicates the disk size in bytes.
    #[prost(uint64, tag = "1")]
    pub size: u64,
    /// Model idicates the disk model.
    #[prost(string, tag = "2")]
    pub model: ::prost::alloc::string::String,
    /// DeviceName indicates the disk name (e.g. `sda`).
    #[prost(string, tag = "3")]
    pub device_name: ::prost::alloc::string::String,
    /// Name as in `/sys/block/<dev>/device/name`.
    #[prost(string, tag = "4")]
    pub name: ::prost::alloc::string::String,
    /// Serial as in `/sys/block/<dev>/device/serial`.
    #[prost(string, tag = "5")]
    pub serial: ::prost::alloc::string::String,
    /// Modalias as in `/sys/block/<dev>/device/modalias`.
    #[prost(string, tag = "6")]
    pub modalias: ::prost::alloc::string::String,
    /// Uuid as in `/sys/block/<dev>/device/uuid`.
    #[prost(string, tag = "7")]
    pub uuid: ::prost::alloc::string::String,
    /// Wwid as in `/sys/block/<dev>/device/wwid`.
    #[prost(string, tag = "8")]
    pub wwid: ::prost::alloc::string::String,
    /// Type is a type of the disk: nvme, ssd, hdd, sd card.
    #[prost(enumeration = "disk::DiskType", tag = "9")]
    pub r#type: i32,
    /// BusPath is the bus path of the disk.
    #[prost(string, tag = "10")]
    pub bus_path: ::prost::alloc::string::String,
    /// SystemDisk indicates that the disk is used as Talos system disk.
    #[prost(bool, tag = "11")]
    pub system_disk: bool,
    /// Subsystem is the symlink path in the `/sys/block/<dev>/subsystem`.
    #[prost(string, tag = "12")]
    pub subsystem: ::prost::alloc::string::String,
    /// Readonly specifies if the disk is read only.
    #[prost(bool, tag = "13")]
    pub readonly: bool,
}
/// Nested message and enum types in `Disk`.
pub mod disk {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[serde(rename_all = "camelCase")]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum DiskType {
        Unknown = 0,
        Ssd = 1,
        Hdd = 2,
        Nvme = 3,
        Sd = 4,
        Cd = 5,
    }
    impl DiskType {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Unknown => "UNKNOWN",
                Self::Ssd => "SSD",
                Self::Hdd => "HDD",
                Self::Nvme => "NVME",
                Self::Sd => "SD",
                Self::Cd => "CD",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "UNKNOWN" => Some(Self::Unknown),
                "SSD" => Some(Self::Ssd),
                "HDD" => Some(Self::Hdd),
                "NVME" => Some(Self::Nvme),
                "SD" => Some(Self::Sd),
                "CD" => Some(Self::Cd),
                _ => None,
            }
        }
    }
}
/// DisksResponse represents the response of the `Disks` RPC.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Disks {
    #[prost(message, optional, tag = "1")]
    pub metadata: ::core::option::Option<super::common::Metadata>,
    #[prost(message, repeated, tag = "2")]
    pub disks: ::prost::alloc::vec::Vec<Disk>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DisksResponse {
    #[prost(message, repeated, tag = "1")]
    pub messages: ::prost::alloc::vec::Vec<Disks>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BlockDeviceWipeRequest {
    #[prost(message, repeated, tag = "1")]
    pub devices: ::prost::alloc::vec::Vec<BlockDeviceWipeDescriptor>,
}
/// BlockDeviceWipeDescriptor represents a single block device to be wiped.
///
/// The device can be either a full disk (e.g. vda) or a partition (vda5).
/// The device should not be used in any of active volumes.
/// The device should not be used as a secondary (e.g. part of LVM).
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BlockDeviceWipeDescriptor {
    /// Device name to wipe (e.g. sda or sda5).
    ///
    /// The name should be submitted without `/dev/` prefix.
    #[prost(string, tag = "1")]
    pub device: ::prost::alloc::string::String,
    /// Wipe method to use.
    #[prost(enumeration = "block_device_wipe_descriptor::Method", tag = "2")]
    pub method: i32,
    /// Skip the volume in use check.
    #[prost(bool, tag = "3")]
    pub skip_volume_check: bool,
    /// Drop the partition (only applies if the device is a partition).
    #[prost(bool, tag = "4")]
    pub drop_partition: bool,
}
/// Nested message and enum types in `BlockDeviceWipeDescriptor`.
pub mod block_device_wipe_descriptor {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[serde(rename_all = "camelCase")]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Method {
        /// Fast wipe - wipe only filesystem signatures.
        Fast = 0,
        /// Zeroes wipe - wipe by overwriting with zeroes (might be slow depending on the disk size and available hardware features).
        Zeroes = 1,
    }
    impl Method {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Fast => "FAST",
                Self::Zeroes => "ZEROES",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "FAST" => Some(Self::Fast),
                "ZEROES" => Some(Self::Zeroes),
                _ => None,
            }
        }
    }
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BlockDeviceWipeResponse {
    #[prost(message, repeated, tag = "1")]
    pub messages: ::prost::alloc::vec::Vec<BlockDeviceWipe>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BlockDeviceWipe {
    #[prost(message, optional, tag = "1")]
    pub metadata: ::core::option::Option<super::common::Metadata>,
}
/// Generated client implementations.
pub mod storage_service_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// StorageService represents the storage service.
    #[derive(Debug, Clone)]
    pub struct StorageServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl StorageServiceClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> StorageServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::BoxBody>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> StorageServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::BoxBody>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::BoxBody>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            StorageServiceClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        pub async fn disks(
            &mut self,
            request: impl tonic::IntoRequest<super::super::google::protobuf::Empty>,
        ) -> std::result::Result<tonic::Response<super::DisksResponse>, tonic::Status> {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/storage.StorageService/Disks",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("storage.StorageService", "Disks"));
            self.inner.unary(req, path, codec).await
        }
        /// BlockDeviceWipe performs a wipe of the blockdevice (partition or disk).
        ///
        /// The method doesn't require a reboot, and it can only wipe blockdevices which are not
        /// being used as volumes at the moment.
        /// Wiping of volumes requires a different API.
        pub async fn block_device_wipe(
            &mut self,
            request: impl tonic::IntoRequest<super::BlockDeviceWipeRequest>,
        ) -> std::result::Result<
            tonic::Response<super::BlockDeviceWipeResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/storage.StorageService/BlockDeviceWipe",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("storage.StorageService", "BlockDeviceWipe"));
            self.inner.unary(req, path, codec).await
        }
    }
}