pub mod operations {
use crate::Result;
pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
pub(crate) mod client {
use super::super::super::client::Operations;
pub struct Factory;
impl crate::ClientFactory for Factory {
type Client = Operations;
type Credentials = gaxi::options::Credentials;
async fn build(
self,
config: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<Self::Client> {
Self::Client::new(config).await
}
}
}
#[derive(Clone, Debug)]
pub(crate) struct RequestBuilder<R: std::default::Default> {
stub: std::sync::Arc<dyn super::super::stub::dynamic::Operations>,
request: R,
options: crate::RequestOptions,
}
impl<R> RequestBuilder<R>
where
R: std::default::Default,
{
pub(crate) fn new(
stub: std::sync::Arc<dyn super::super::stub::dynamic::Operations>,
) -> Self {
Self {
stub,
request: R::default(),
options: crate::RequestOptions::default(),
}
}
}
#[derive(Clone, Debug)]
pub struct ListOperations(RequestBuilder<crate::model::ListOperationsRequest>);
impl ListOperations {
pub(crate) fn new(
stub: std::sync::Arc<dyn super::super::stub::dynamic::Operations>,
) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::ListOperationsRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::ListOperationsResponse> {
(*self.0.stub)
.list_operations(self.0.request, self.0.options)
.await
.map(crate::Response::into_body)
}
pub fn by_page(
self,
) -> impl google_cloud_gax::paginator::Paginator<
crate::model::ListOperationsResponse,
crate::Error,
> {
use std::clone::Clone;
let token = self.0.request.page_token.clone();
let execute = move |token: String| {
let mut builder = self.clone();
builder.0.request = builder.0.request.set_page_token(token);
builder.send()
};
google_cloud_gax::paginator::internal::new_paginator(token, execute)
}
pub fn by_item(
self,
) -> impl google_cloud_gax::paginator::ItemPaginator<
crate::model::ListOperationsResponse,
crate::Error,
> {
use google_cloud_gax::paginator::Paginator;
self.by_page().items()
}
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
}
pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
self.0.request.return_partial_success = v.into();
self
}
}
#[doc(hidden)]
impl crate::RequestBuilder for ListOperations {
fn request_options(&mut self) -> &mut crate::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct GetOperation(RequestBuilder<crate::model::GetOperationRequest>);
impl GetOperation {
pub(crate) fn new(
stub: std::sync::Arc<dyn super::super::stub::dynamic::Operations>,
) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::GetOperationRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::Operation> {
(*self.0.stub)
.get_operation(self.0.request, self.0.options)
.await
.map(crate::Response::into_body)
}
pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.name = v.into();
self
}
}
#[doc(hidden)]
impl crate::RequestBuilder for GetOperation {
fn request_options(&mut self) -> &mut crate::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct DeleteOperation(RequestBuilder<crate::model::DeleteOperationRequest>);
impl DeleteOperation {
pub(crate) fn new(
stub: std::sync::Arc<dyn super::super::stub::dynamic::Operations>,
) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::DeleteOperationRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<()> {
(*self.0.stub)
.delete_operation(self.0.request, self.0.options)
.await
.map(crate::Response::into_body)
}
pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.name = v.into();
self
}
}
#[doc(hidden)]
impl crate::RequestBuilder for DeleteOperation {
fn request_options(&mut self) -> &mut crate::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct CancelOperation(RequestBuilder<crate::model::CancelOperationRequest>);
impl CancelOperation {
pub(crate) fn new(
stub: std::sync::Arc<dyn super::super::stub::dynamic::Operations>,
) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::CancelOperationRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<()> {
(*self.0.stub)
.cancel_operation(self.0.request, self.0.options)
.await
.map(crate::Response::into_body)
}
pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.name = v.into();
self
}
}
#[doc(hidden)]
impl crate::RequestBuilder for CancelOperation {
fn request_options(&mut self) -> &mut crate::RequestOptions {
&mut self.0.options
}
}
}