google-cloud-binaryauthorization-v1 1.8.0

Google Cloud Client Libraries for Rust - Binary Authorization 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 [BinauthzManagementServiceV1](super::stub::BinauthzManagementServiceV1) decorator for logging and tracing.
#[derive(Clone, Debug)]
pub struct BinauthzManagementServiceV1<T>
where
    T: super::stub::BinauthzManagementServiceV1 + std::fmt::Debug + Send + Sync,
{
    inner: T,
    duration: gaxi::observability::DurationMetric,
}

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

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

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

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

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

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

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

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

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

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

impl<T> ValidationHelperV1<T>
where
    T: super::stub::ValidationHelperV1 + 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::ValidationHelperV1 for ValidationHelperV1<T>
where
    T: super::stub::ValidationHelperV1 + std::fmt::Debug + Send + Sync,
{
    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn validate_attestation_occurrence(
        &self,
        req: crate::model::ValidateAttestationOccurrenceRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::ValidateAttestationOccurrenceResponse>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::ValidationHelperV1::validate_attestation_occurrence",
            self.inner.validate_attestation_occurrence(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 = "binaryauthorization";
        info.client_version = VERSION;
        info.client_artifact = NAME;
        info.default_host = "binaryauthorization";
        info
    });
}