google-cloud-cloudcontrolspartner-v1 1.8.0

Google Cloud Client Libraries for Rust - Cloud Controls Partner 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.
use crate::Result;

/// Implements a [CloudControlsPartnerCore](super::stub::CloudControlsPartnerCore) decorator for logging and tracing.
#[derive(Clone, Debug)]
pub struct CloudControlsPartnerCore<T>
where
    T: super::stub::CloudControlsPartnerCore + std::fmt::Debug + Send + Sync,
{
    inner: T,
    duration: gaxi::observability::DurationMetric,
}

impl<T> CloudControlsPartnerCore<T>
where
    T: super::stub::CloudControlsPartnerCore + std::fmt::Debug + Send + Sync,
{
    pub fn new(inner: T) -> Self {
        Self {
            inner,
            duration: gaxi::observability::DurationMetric::new(&info::INSTRUMENTATION_CLIENT_INFO),
        }
    }
}

impl<T> super::stub::CloudControlsPartnerCore for CloudControlsPartnerCore<T>
where
    T: super::stub::CloudControlsPartnerCore + std::fmt::Debug + Send + Sync,
{
    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn get_workload(
        &self,
        req: crate::model::GetWorkloadRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Workload>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::get_workload",
            self.inner.get_workload(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn list_workloads(
        &self,
        req: crate::model::ListWorkloadsRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::ListWorkloadsResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::list_workloads",
            self.inner.list_workloads(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn get_customer(
        &self,
        req: crate::model::GetCustomerRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Customer>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::get_customer",
            self.inner.get_customer(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn list_customers(
        &self,
        req: crate::model::ListCustomersRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::ListCustomersResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::list_customers",
            self.inner.list_customers(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn get_ekm_connections(
        &self,
        req: crate::model::GetEkmConnectionsRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::EkmConnections>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::get_ekm_connections",
            self.inner.get_ekm_connections(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn get_partner_permissions(
        &self,
        req: crate::model::GetPartnerPermissionsRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::PartnerPermissions>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::get_partner_permissions",
            self.inner.get_partner_permissions(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn list_access_approval_requests(
        &self,
        req: crate::model::ListAccessApprovalRequestsRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::ListAccessApprovalRequestsResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::list_access_approval_requests",
            self.inner.list_access_approval_requests(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn get_partner(
        &self,
        req: crate::model::GetPartnerRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Partner>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::get_partner",
            self.inner.get_partner(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn create_customer(
        &self,
        req: crate::model::CreateCustomerRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Customer>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::create_customer",
            self.inner.create_customer(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn update_customer(
        &self,
        req: crate::model::UpdateCustomerRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Customer>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::update_customer",
            self.inner.update_customer(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn delete_customer(
        &self,
        req: crate::model::DeleteCustomerRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<()>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerCore::delete_customer",
            self.inner.delete_customer(req, options));
        pending.await
    }
}

/// Implements a [CloudControlsPartnerMonitoring](super::stub::CloudControlsPartnerMonitoring) decorator for logging and tracing.
#[derive(Clone, Debug)]
pub struct CloudControlsPartnerMonitoring<T>
where
    T: super::stub::CloudControlsPartnerMonitoring + std::fmt::Debug + Send + Sync,
{
    inner: T,
    duration: gaxi::observability::DurationMetric,
}

impl<T> CloudControlsPartnerMonitoring<T>
where
    T: super::stub::CloudControlsPartnerMonitoring + std::fmt::Debug + Send + Sync,
{
    pub fn new(inner: T) -> Self {
        Self {
            inner,
            duration: gaxi::observability::DurationMetric::new(&info::INSTRUMENTATION_CLIENT_INFO),
        }
    }
}

impl<T> super::stub::CloudControlsPartnerMonitoring for CloudControlsPartnerMonitoring<T>
where
    T: super::stub::CloudControlsPartnerMonitoring + std::fmt::Debug + Send + Sync,
{
    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn list_violations(
        &self,
        req: crate::model::ListViolationsRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::ListViolationsResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerMonitoring::list_violations",
            self.inner.list_violations(req, options));
        pending.await
    }

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn get_violation(
        &self,
        req: crate::model::GetViolationRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Violation>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CloudControlsPartnerMonitoring::get_violation",
            self.inner.get_violation(req, options));
        pending.await
    }
}

pub(crate) mod info {
    const NAME: &str = env!("CARGO_PKG_NAME");
    const VERSION: &str = env!("CARGO_PKG_VERSION");
    pub(crate) static INSTRUMENTATION_CLIENT_INFO: std::sync::LazyLock<
        gaxi::options::InstrumentationClientInfo,
    > = std::sync::LazyLock::new(|| {
        let mut info = gaxi::options::InstrumentationClientInfo::default();
        info.service_name = "cloudcontrolspartner";
        info.client_version = VERSION;
        info.client_artifact = NAME;
        info.default_host = "cloudcontrolspartner";
        info
    });
}