yandex-cloud 2025.4.14

Generated gRPC clients for the Yandex Cloud API
Documentation
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UsageRecord {
    /// Unique identifier of the usage record (UUID format).
    #[prost(string, tag = "1")]
    pub uuid: ::prost::alloc::string::String,
    /// Consumed Marketplace SKU ID, linked to `UsageRecord.product_id`.
    #[prost(string, tag = "2")]
    pub sku_id: ::prost::alloc::string::String,
    /// Quantity of SKU consumed, measured in `sku.usage_unit` units (e.g. bytes).
    #[prost(int64, tag = "3")]
    pub quantity: i64,
    /// Timestamp in UTC for which the usage is being reported.
    #[prost(message, optional, tag = "4")]
    pub timestamp: ::core::option::Option<::prost_types::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AcceptedUsageRecord {
    /// Unique identifier of the usage record (UUID format).
    #[prost(string, tag = "1")]
    pub uuid: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RejectedUsageRecord {
    /// Unique identifier of the usage record (UUID format).
    #[prost(string, tag = "1")]
    pub uuid: ::prost::alloc::string::String,
    /// The reason of rejection.
    #[prost(enumeration = "rejected_usage_record::Reason", tag = "2")]
    pub reason: i32,
}
/// Nested message and enum types in `RejectedUsageRecord`.
pub mod rejected_usage_record {
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Reason {
        Unspecified = 0,
        Duplicate = 1,
        Expired = 2,
        InvalidTimestamp = 3,
        InvalidSkuId = 4,
        InvalidProductId = 5,
        InvalidQuantity = 6,
        InvalidId = 7,
    }
    impl Reason {
        /// 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 {
                Reason::Unspecified => "REASON_UNSPECIFIED",
                Reason::Duplicate => "DUPLICATE",
                Reason::Expired => "EXPIRED",
                Reason::InvalidTimestamp => "INVALID_TIMESTAMP",
                Reason::InvalidSkuId => "INVALID_SKU_ID",
                Reason::InvalidProductId => "INVALID_PRODUCT_ID",
                Reason::InvalidQuantity => "INVALID_QUANTITY",
                Reason::InvalidId => "INVALID_ID",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "REASON_UNSPECIFIED" => Some(Self::Unspecified),
                "DUPLICATE" => Some(Self::Duplicate),
                "EXPIRED" => Some(Self::Expired),
                "INVALID_TIMESTAMP" => Some(Self::InvalidTimestamp),
                "INVALID_SKU_ID" => Some(Self::InvalidSkuId),
                "INVALID_PRODUCT_ID" => Some(Self::InvalidProductId),
                "INVALID_QUANTITY" => Some(Self::InvalidQuantity),
                "INVALID_ID" => Some(Self::InvalidId),
                _ => None,
            }
        }
    }
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteImageProductUsageRequest {
    /// Checks whether you have the access required for the emit usage.
    #[prost(bool, tag = "1")]
    pub validate_only: bool,
    /// Marketplace Product's ID.
    #[prost(string, tag = "2")]
    pub product_id: ::prost::alloc::string::String,
    /// List of product usage records (up to 25 per request).
    #[prost(message, repeated, tag = "3")]
    pub usage_records: ::prost::alloc::vec::Vec<UsageRecord>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteImageProductUsageResponse {
    /// List of accepted product usage records.
    #[prost(message, repeated, tag = "1")]
    pub accepted: ::prost::alloc::vec::Vec<AcceptedUsageRecord>,
    /// List of rejected product usage records (with reason).
    #[prost(message, repeated, tag = "2")]
    pub rejected: ::prost::alloc::vec::Vec<RejectedUsageRecord>,
}
/// Generated client implementations.
pub mod image_product_usage_service_client {
    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// A set of methods for managing image product's usage.
    #[derive(Debug, Clone)]
    pub struct ImageProductUsageServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl ImageProductUsageServiceClient<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> ImageProductUsageServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::BoxBody>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + 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,
        ) -> ImageProductUsageServiceClient<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> + Send + Sync,
        {
            ImageProductUsageServiceClient::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
        }
        /// Writes image product's usage. Authentication is by user's service account.
        pub async fn write(
            &mut self,
            request: impl tonic::IntoRequest<super::WriteImageProductUsageRequest>,
        ) -> std::result::Result<
            tonic::Response<super::WriteImageProductUsageResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/yandex.cloud.marketplace.v1.metering.ImageProductUsageService/Write",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "yandex.cloud.marketplace.v1.metering.ImageProductUsageService",
                        "Write",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}