gcp_sdk_longrunning/
builders.rspub mod operations {
use crate::Result;
use std::sync::Arc;
#[derive(Clone, Debug)]
pub struct RequestBuilder<R: std::default::Default> {
stub: Arc<dyn crate::stubs::dynamic::Operations>,
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::Operations>) -> Self {
Self {
stub,
request: R::default(),
options: gax::options::RequestOptions::default(),
}
}
}
#[derive(Clone, Debug)]
pub struct ListOperations(RequestBuilder<crate::model::ListOperationsRequest>);
impl ListOperations {
pub(crate) fn new(stub: Arc<dyn crate::stubs::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<gax::options::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
}
#[cfg(feature = "unstable-stream")]
pub async fn stream(
self,
) -> gax::paginator::Paginator<crate::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<crate::model::GetOperationRequest>);
impl GetOperation {
pub(crate) fn new(stub: Arc<dyn crate::stubs::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<gax::options::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
}
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
}
}
#[derive(Clone, Debug)]
pub struct DeleteOperation(RequestBuilder<crate::model::DeleteOperationRequest>);
impl DeleteOperation {
pub(crate) fn new(stub: Arc<dyn crate::stubs::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<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<wkt::Empty> {
(*self.0.stub)
.delete_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 DeleteOperation {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct CancelOperation(RequestBuilder<crate::model::CancelOperationRequest>);
impl CancelOperation {
pub(crate) fn new(stub: Arc<dyn crate::stubs::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<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<wkt::Empty> {
(*self.0.stub)
.cancel_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 CancelOperation {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
}