google-cloud-security-publicca-v1 1.7.0

Google Cloud Client Libraries for Rust - Public Certificate Authority 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 public_certificate_authority_service {
    use crate::Result;

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

    pub(crate) mod client {
        use super::super::super::client::PublicCertificateAuthorityService;
        pub struct Factory;
        impl crate::ClientFactory for Factory {
            type Client = PublicCertificateAuthorityService;
            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::PublicCertificateAuthorityService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::PublicCertificateAuthorityService>,
        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::PublicCertificateAuthorityService,
            >,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: crate::RequestOptions::default(),
            }
        }
    }

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

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

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateExternalAccountKeyRequest>>(
            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::ExternalAccountKey> {
            (*self.0.stub)
                .create_external_account_key(self.0.request, self.0.options)
                .await
                .map(crate::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateExternalAccountKeyRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [external_account_key][crate::model::CreateExternalAccountKeyRequest::external_account_key].
        ///
        /// This is a **required** field for requests.
        pub fn set_external_account_key<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ExternalAccountKey>,
        {
            self.0.request.external_account_key = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [external_account_key][crate::model::CreateExternalAccountKeyRequest::external_account_key].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_external_account_key<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ExternalAccountKey>,
        {
            self.0.request.external_account_key = v.map(|x| x.into());
            self
        }
    }

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