google-cloud-workflows-executions-v1 1.7.0

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

#[allow(unused_imports)]
use crate::Error;
use crate::Result;

/// Implements [Executions](super::stub::Executions) using a [gaxi::http::ReqwestClient].
#[derive(Clone)]
pub struct Executions {
    inner: gaxi::http::ReqwestClient,
}

impl std::fmt::Debug for Executions {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        f.debug_struct("Executions")
            .field("inner", &self.inner)
            .finish()
    }
}

impl Executions {
    pub async fn new(config: gaxi::options::ClientConfig) -> crate::ClientBuilderResult<Self> {
        let inner = gaxi::http::ReqwestClient::new(config, crate::DEFAULT_HOST).await?;
        Ok(Self { inner })
    }
}

impl super::stub::Executions for Executions {
    async fn list_executions(
        &self,
        req: crate::model::ListExecutionsRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::ListExecutionsResponse>> {
        use gaxi::http::reqwest::{HeaderValue, Method};
        use gaxi::path_parameter::PathMismatchBuilder;
        use gaxi::path_parameter::try_match;
        use gaxi::routing_parameter::Segment;
        use google_cloud_gax::error::binding::BindingError;
        let (builder, method) = None
            .or_else(|| {
                let var_parent = try_match(
                    Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/locations/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/workflows/"),
                        Segment::SingleWildcard,
                    ],
                )?;
                let path = format!("/v1/{}/executions", var_parent,);

                let builder = self.inner.builder(Method::GET, path);
                let builder = builder.query(&[("pageSize", &req.page_size)]);
                let builder = builder.query(&[("pageToken", &req.page_token)]);
                let builder = builder.query(&[("view", &req.view)]);
                let builder = builder.query(&[("filter", &req.filter)]);
                let builder = builder.query(&[("orderBy", &req.order_by)]);
                let builder = Ok(builder);
                Some(builder.map(|b| (b, Method::GET)))
            })
            .ok_or_else(|| {
                let mut paths = Vec::new();
                {
                    let builder = PathMismatchBuilder::default();
                    let builder = builder.maybe_add(
                        Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/locations/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/workflows/"),
                            Segment::SingleWildcard,
                        ],
                        "parent",
                        "projects/*/locations/*/workflows/*",
                    );
                    paths.push(builder.build());
                }
                google_cloud_gax::error::Error::binding(BindingError { paths })
            })??;
        let options = google_cloud_gax::options::internal::set_default_idempotency(
            options,
            gaxi::http::default_idempotency(&method),
        );
        let builder = builder.query(&[("$alt", "json;enum-encoding=int")]).header(
            "x-goog-api-client",
            HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER),
        );
        let body = gaxi::http::handle_empty(None::<gaxi::http::NoBody>, &method);
        self.inner.execute(builder, body, options).await
    }

    async fn create_execution(
        &self,
        req: crate::model::CreateExecutionRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Execution>> {
        use gaxi::http::reqwest::{HeaderValue, Method};
        use gaxi::path_parameter::PathMismatchBuilder;
        use gaxi::path_parameter::try_match;
        use gaxi::routing_parameter::Segment;
        use google_cloud_gax::error::binding::BindingError;
        let (builder, method) = None
            .or_else(|| {
                let var_parent = try_match(
                    Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/locations/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/workflows/"),
                        Segment::SingleWildcard,
                    ],
                )?;
                let path = format!("/v1/{}/executions", var_parent,);

                let builder = self.inner.builder(Method::POST, path);
                let builder = Ok(builder);
                Some(builder.map(|b| (b, Method::POST)))
            })
            .ok_or_else(|| {
                let mut paths = Vec::new();
                {
                    let builder = PathMismatchBuilder::default();
                    let builder = builder.maybe_add(
                        Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/locations/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/workflows/"),
                            Segment::SingleWildcard,
                        ],
                        "parent",
                        "projects/*/locations/*/workflows/*",
                    );
                    paths.push(builder.build());
                }
                google_cloud_gax::error::Error::binding(BindingError { paths })
            })??;
        let options = google_cloud_gax::options::internal::set_default_idempotency(
            options,
            gaxi::http::default_idempotency(&method),
        );
        let builder = builder.query(&[("$alt", "json;enum-encoding=int")]).header(
            "x-goog-api-client",
            HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER),
        );
        let body = gaxi::http::handle_empty(req.execution, &method);
        self.inner.execute(builder, body, options).await
    }

    async fn get_execution(
        &self,
        req: crate::model::GetExecutionRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Execution>> {
        use gaxi::http::reqwest::{HeaderValue, Method};
        use gaxi::path_parameter::PathMismatchBuilder;
        use gaxi::path_parameter::try_match;
        use gaxi::routing_parameter::Segment;
        use google_cloud_gax::error::binding::BindingError;
        let (builder, method) = None
            .or_else(|| {
                let var_name = try_match(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/locations/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/workflows/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/executions/"),
                        Segment::SingleWildcard,
                    ],
                )?;
                let path = format!("/v1/{}", var_name,);

                let builder = self.inner.builder(Method::GET, path);
                let builder = builder.query(&[("view", &req.view)]);
                let builder = Ok(builder);
                Some(builder.map(|b| (b, Method::GET)))
            })
            .ok_or_else(|| {
                let mut paths = Vec::new();
                {
                    let builder = PathMismatchBuilder::default();
                    let builder = builder.maybe_add(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/locations/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/workflows/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/executions/"),
                            Segment::SingleWildcard,
                        ],
                        "name",
                        "projects/*/locations/*/workflows/*/executions/*",
                    );
                    paths.push(builder.build());
                }
                google_cloud_gax::error::Error::binding(BindingError { paths })
            })??;
        let options = google_cloud_gax::options::internal::set_default_idempotency(
            options,
            gaxi::http::default_idempotency(&method),
        );
        let builder = builder.query(&[("$alt", "json;enum-encoding=int")]).header(
            "x-goog-api-client",
            HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER),
        );
        let body = gaxi::http::handle_empty(None::<gaxi::http::NoBody>, &method);
        self.inner.execute(builder, body, options).await
    }

    async fn cancel_execution(
        &self,
        req: crate::model::CancelExecutionRequest,
        options: crate::RequestOptions,
    ) -> Result<crate::Response<crate::model::Execution>> {
        use gaxi::http::reqwest::{HeaderValue, Method};
        use gaxi::path_parameter::PathMismatchBuilder;
        use gaxi::path_parameter::try_match;
        use gaxi::routing_parameter::Segment;
        use google_cloud_gax::error::binding::BindingError;
        let (builder, method) = None
            .or_else(|| {
                let var_name = try_match(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/locations/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/workflows/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/executions/"),
                        Segment::SingleWildcard,
                    ],
                )?;
                let path = format!("/v1/{}:cancel", var_name,);

                let builder = self.inner.builder(Method::POST, path);
                let builder = Ok(builder);
                Some(builder.map(|b| (b, Method::POST)))
            })
            .ok_or_else(|| {
                let mut paths = Vec::new();
                {
                    let builder = PathMismatchBuilder::default();
                    let builder = builder.maybe_add(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/locations/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/workflows/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/executions/"),
                            Segment::SingleWildcard,
                        ],
                        "name",
                        "projects/*/locations/*/workflows/*/executions/*",
                    );
                    paths.push(builder.build());
                }
                google_cloud_gax::error::Error::binding(BindingError { paths })
            })??;
        let options = google_cloud_gax::options::internal::set_default_idempotency(
            options,
            gaxi::http::default_idempotency(&method),
        );
        let builder = builder.query(&[("$alt", "json;enum-encoding=int")]).header(
            "x-goog-api-client",
            HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER),
        );
        let body = gaxi::http::handle_empty(Some(req), &method);
        self.inner.execute(builder, body, options).await
    }
}