pub mod service_usage {
use crate::Result;
use std::sync::Arc;
#[derive(Clone, Debug)]
pub struct RequestBuilder<R: std::default::Default> {
stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>,
request: R,
options: gax::options::RequestOptions,
}
impl<R> RequestBuilder<R>
where
R: std::default::Default,
{
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self {
stub,
request: R::default(),
options: gax::options::RequestOptions::default(),
}
}
}
#[derive(Clone, Debug)]
pub struct EnableService(RequestBuilder<crate::model::EnableServiceRequest>);
impl EnableService {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::EnableServiceRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<longrunning::model::Operation> {
(*self.0.stub)
.enable_service(self.0.request, self.0.options)
.await
}
pub fn poller(
self,
) -> impl lro::Poller<crate::model::EnableServiceResponse, crate::model::OperationMetadata>
{
type Operation = lro::Operation<
crate::model::EnableServiceResponse,
crate::model::OperationMetadata,
>;
let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
let stub = self.0.stub.clone();
let mut options = self.0.options.clone();
options.set_retry_policy(gax::retry_policy::NeverRetry);
let query = move |name| {
let stub = stub.clone();
let options = options.clone();
async {
let op = GetOperation::new(stub)
.set_name(name)
.with_options(options)
.send()
.await?;
Ok(Operation::new(op))
}
};
let start = move || async {
let op = self.send().await?;
Ok(Operation::new(op))
};
lro::new_poller(polling_policy, polling_backoff_policy, start, query)
}
pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.name = v.into();
self
}
}
impl gax::options::RequestBuilder for EnableService {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct DisableService(RequestBuilder<crate::model::DisableServiceRequest>);
impl DisableService {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::DisableServiceRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<longrunning::model::Operation> {
(*self.0.stub)
.disable_service(self.0.request, self.0.options)
.await
}
pub fn poller(
self,
) -> impl lro::Poller<crate::model::DisableServiceResponse, crate::model::OperationMetadata>
{
type Operation = lro::Operation<
crate::model::DisableServiceResponse,
crate::model::OperationMetadata,
>;
let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
let stub = self.0.stub.clone();
let mut options = self.0.options.clone();
options.set_retry_policy(gax::retry_policy::NeverRetry);
let query = move |name| {
let stub = stub.clone();
let options = options.clone();
async {
let op = GetOperation::new(stub)
.set_name(name)
.with_options(options)
.send()
.await?;
Ok(Operation::new(op))
}
};
let start = move || async {
let op = self.send().await?;
Ok(Operation::new(op))
};
lro::new_poller(polling_policy, polling_backoff_policy, start, query)
}
pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.name = v.into();
self
}
pub fn set_disable_dependent_services<T: Into<bool>>(mut self, v: T) -> Self {
self.0.request.disable_dependent_services = v.into();
self
}
pub fn set_check_if_service_has_usage<
T: Into<crate::model::disable_service_request::CheckIfServiceHasUsage>,
>(
mut self,
v: T,
) -> Self {
self.0.request.check_if_service_has_usage = v.into();
self
}
}
impl gax::options::RequestBuilder for DisableService {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct GetService(RequestBuilder<crate::model::GetServiceRequest>);
impl GetService {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::GetServiceRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::Service> {
(*self.0.stub)
.get_service(self.0.request, self.0.options)
.await
}
pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.name = v.into();
self
}
}
impl gax::options::RequestBuilder for GetService {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct ListServices(RequestBuilder<crate::model::ListServicesRequest>);
impl ListServices {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::ListServicesRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::ListServicesResponse> {
(*self.0.stub)
.list_services(self.0.request, self.0.options)
.await
}
#[cfg(feature = "unstable-stream")]
pub async fn stream(
self,
) -> gax::paginator::Paginator<crate::model::ListServicesResponse, gax::error::Error>
{
let token = gax::paginator::extract_token(&self.0.request.page_token);
let execute = move |token: String| {
let builder = self.clone();
builder.0.request.clone().set_page_token(token);
builder.send()
};
gax::paginator::Paginator::new(token, execute)
}
pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.parent = v.into();
self
}
pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
self.0.request.page_size = v.into();
self
}
pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.page_token = v.into();
self
}
pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.filter = v.into();
self
}
}
impl gax::options::RequestBuilder for ListServices {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct BatchEnableServices(RequestBuilder<crate::model::BatchEnableServicesRequest>);
impl BatchEnableServices {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::BatchEnableServicesRequest>>(
mut self,
v: V,
) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<longrunning::model::Operation> {
(*self.0.stub)
.batch_enable_services(self.0.request, self.0.options)
.await
}
pub fn poller(
self,
) -> impl lro::Poller<crate::model::BatchEnableServicesResponse, crate::model::OperationMetadata>
{
type Operation = lro::Operation<
crate::model::BatchEnableServicesResponse,
crate::model::OperationMetadata,
>;
let polling_policy = self.0.stub.get_polling_policy(&self.0.options);
let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
let stub = self.0.stub.clone();
let mut options = self.0.options.clone();
options.set_retry_policy(gax::retry_policy::NeverRetry);
let query = move |name| {
let stub = stub.clone();
let options = options.clone();
async {
let op = GetOperation::new(stub)
.set_name(name)
.with_options(options)
.send()
.await?;
Ok(Operation::new(op))
}
};
let start = move || async {
let op = self.send().await?;
Ok(Operation::new(op))
};
lro::new_poller(polling_policy, polling_backoff_policy, start, query)
}
pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.parent = v.into();
self
}
pub fn set_service_ids<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.0.request.service_ids = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl gax::options::RequestBuilder for BatchEnableServices {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct BatchGetServices(RequestBuilder<crate::model::BatchGetServicesRequest>);
impl BatchGetServices {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::BatchGetServicesRequest>>(
mut self,
v: V,
) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::BatchGetServicesResponse> {
(*self.0.stub)
.batch_get_services(self.0.request, self.0.options)
.await
}
pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.parent = v.into();
self
}
pub fn set_names<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.0.request.names = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl gax::options::RequestBuilder for BatchGetServices {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
impl ListOperations {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
mut self,
v: V,
) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
(*self.0.stub)
.list_operations(self.0.request, self.0.options)
.await
}
#[cfg(feature = "unstable-stream")]
pub async fn stream(
self,
) -> gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
{
let token = gax::paginator::extract_token(&self.0.request.page_token);
let execute = move |token: String| {
let builder = self.clone();
builder.0.request.clone().set_page_token(token);
builder.send()
};
gax::paginator::Paginator::new(token, execute)
}
pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.name = v.into();
self
}
pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.filter = v.into();
self
}
pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
self.0.request.page_size = v.into();
self
}
pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.page_token = v.into();
self
}
}
impl gax::options::RequestBuilder for ListOperations {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
impl GetOperation {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceUsage>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
mut self,
v: V,
) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<longrunning::model::Operation> {
(*self.0.stub)
.get_operation(self.0.request, self.0.options)
.await
}
pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.name = v.into();
self
}
}
impl gax::options::RequestBuilder for GetOperation {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
}