google-cloud-trace-v1 1.8.0

Google Cloud Client Libraries for Rust - Cloud Trace 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.

/// Request and client builders for [TraceService][crate::client::TraceService].
pub mod trace_service {
    use crate::Result;

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

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

    /// The request builder for [TraceService::list_traces][crate::client::TraceService::list_traces] calls.
    ///
    /// # Example
    /// ```
    /// # use google_cloud_trace_v1::builder::trace_service::ListTraces;
    /// # async fn sample() -> google_cloud_trace_v1::Result<()> {
    /// use google_cloud_gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # Ok(()) }
    ///
    /// fn prepare_request_builder() -> ListTraces {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListTraces(RequestBuilder<crate::model::ListTracesRequest>);

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

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

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListTracesResponse, crate::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            google_cloud_gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl google_cloud_gax::paginator::ItemPaginator<
            crate::model::ListTracesResponse,
            crate::Error,
        > {
            use google_cloud_gax::paginator::Paginator;
            self.by_page().items()
        }

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

        /// Sets the value of [view][crate::model::ListTracesRequest::view].
        pub fn set_view<T: Into<crate::model::list_traces_request::ViewType>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.view = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListTracesRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

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

        /// Sets the value of [start_time][crate::model::ListTracesRequest::start_time].
        pub fn set_start_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.start_time = std::option::Option::Some(v.into());
            self
        }

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

        /// Sets the value of [end_time][crate::model::ListTracesRequest::end_time].
        pub fn set_end_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.end_time = std::option::Option::Some(v.into());
            self
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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