google-cloud-api-servicecontrol-v2 1.8.0

Google Cloud Client Libraries for Rust - Service Control API
Documentation
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

pub mod service_controller {
    use crate::Result;

    /// A builder for [ServiceController][crate::client::ServiceController].
    ///
    /// ```
    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
    /// # use google_cloud_api_servicecontrol_v2::*;
    /// # use builder::service_controller::ClientBuilder;
    /// # use client::ServiceController;
    /// let builder : ClientBuilder = ServiceController::builder();
    /// let client = builder
    ///     .with_endpoint("https://servicecontrol.googleapis.com")
    ///     .build().await?;
    /// # Ok(()) }
    /// ```
    pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ServiceController;
        pub struct Factory;
        impl crate::ClientFactory for Factory {
            type Client = ServiceController;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> crate::ClientBuilderResult<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ServiceController] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
        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::ServiceController>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: crate::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ServiceController::check][crate::client::ServiceController::check] calls.
    ///
    /// # Example
    /// ```
    /// # use google_cloud_api_servicecontrol_v2::builder::service_controller::Check;
    /// # async fn sample() -> google_cloud_api_servicecontrol_v2::Result<()> {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # Ok(()) }
    ///
    /// fn prepare_request_builder() -> Check {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Check(RequestBuilder<crate::model::CheckRequest>);

    impl Check {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CheckRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::CheckResponse> {
            (*self.0.stub)
                .check(self.0.request, self.0.options)
                .await
                .map(crate::Response::into_body)
        }

        /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
        pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.service_name = v.into();
            self
        }

        /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
        pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.service_config_id = v.into();
            self
        }

        /// Sets the value of [attributes][crate::model::CheckRequest::attributes].
        pub fn set_attributes<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
        {
            self.0.request.attributes = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [attributes][crate::model::CheckRequest::attributes].
        pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
        {
            self.0.request.attributes = v.map(|x| x.into());
            self
        }

        /// Sets the value of [resources][crate::model::CheckRequest::resources].
        pub fn set_resources<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::ResourceInfo>,
        {
            use std::iter::Iterator;
            self.0.request.resources = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [flags][crate::model::CheckRequest::flags].
        pub fn set_flags<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.flags = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl crate::RequestBuilder for Check {
        fn request_options(&mut self) -> &mut crate::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServiceController::report][crate::client::ServiceController::report] calls.
    ///
    /// # Example
    /// ```
    /// # use google_cloud_api_servicecontrol_v2::builder::service_controller::Report;
    /// # async fn sample() -> google_cloud_api_servicecontrol_v2::Result<()> {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # Ok(()) }
    ///
    /// fn prepare_request_builder() -> Report {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Report(RequestBuilder<crate::model::ReportRequest>);

    impl Report {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ReportRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ReportResponse> {
            (*self.0.stub)
                .report(self.0.request, self.0.options)
                .await
                .map(crate::Response::into_body)
        }

        /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
        pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.service_name = v.into();
            self
        }

        /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
        pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.service_config_id = v.into();
            self
        }

        /// Sets the value of [operations][crate::model::ReportRequest::operations].
        pub fn set_operations<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
        {
            use std::iter::Iterator;
            self.0.request.operations = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    #[doc(hidden)]
    impl crate::RequestBuilder for Report {
        fn request_options(&mut self) -> &mut crate::RequestOptions {
            &mut self.0.options
        }
    }
}