#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UsageRecord {
#[prost(string, tag = "1")]
pub uuid: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub sku_id: ::prost::alloc::string::String,
#[prost(int64, tag = "3")]
pub quantity: i64,
#[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 {
#[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 {
#[prost(string, tag = "1")]
pub uuid: ::prost::alloc::string::String,
#[prost(enumeration = "rejected_usage_record::Reason", tag = "2")]
pub reason: i32,
}
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 {
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",
}
}
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 {
#[prost(bool, tag = "1")]
pub validate_only: bool,
#[prost(string, tag = "2")]
pub product_id: ::prost::alloc::string::String,
#[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 {
#[prost(message, repeated, tag = "1")]
pub accepted: ::prost::alloc::vec::Vec<AcceptedUsageRecord>,
#[prost(message, repeated, tag = "2")]
pub rejected: ::prost::alloc::vec::Vec<RejectedUsageRecord>,
}
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;
#[derive(Debug, Clone)]
pub struct ImageProductUsageServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ImageProductUsageServiceClient<tonic::transport::Channel> {
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),
)
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[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 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.metering.v1.ImageProductUsageService/Write",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"yandex.cloud.marketplace.metering.v1.ImageProductUsageService",
"Write",
),
);
self.inner.unary(req, path, codec).await
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteUsageRequest {
#[prost(bool, tag = "1")]
pub dry_run: bool,
#[prost(string, tag = "2")]
pub product_instance_id: ::prost::alloc::string::String,
#[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 WriteUsageResponse {
#[prost(message, repeated, tag = "1")]
pub accepted: ::prost::alloc::vec::Vec<AcceptedUsageRecord>,
#[prost(message, repeated, tag = "2")]
pub rejected: ::prost::alloc::vec::Vec<RejectedUsageRecord>,
}
pub mod product_usage_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct ProductUsageServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ProductUsageServiceClient<tonic::transport::Channel> {
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> ProductUsageServiceClient<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,
) -> ProductUsageServiceClient<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,
{
ProductUsageServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[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 write(
&mut self,
request: impl tonic::IntoRequest<super::WriteUsageRequest>,
) -> std::result::Result<
tonic::Response<super::WriteUsageResponse>,
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.metering.v1.ProductUsageService/Write",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"yandex.cloud.marketplace.metering.v1.ProductUsageService",
"Write",
),
);
self.inner.unary(req, path, codec).await
}
}
}