google-cloud-support-v2 1.9.0

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

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

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

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

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

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

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

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

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

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

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

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

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

    #[tracing::instrument(level = tracing::Level::DEBUG, ret)]
    async fn create_comment(
        &self,
        req: crate::model::CreateCommentRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Comment>> {
        let (_span, pending) = gaxi::client_request_signals!(
            metric: self.duration.clone(),
            info: *info::INSTRUMENTATION_CLIENT_INFO,
            method: "client::CommentService::create_comment",
            self.inner.create_comment(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 = "cloudsupport";
        info.client_version = VERSION;
        info.client_artifact = NAME;
        info.default_host = "cloudsupport";
        info
    });
}