Skip to main content

gcloud_sdk/
lib.rs

1//! # Google Cloud SDK for Rust
2//!
3//! Library provides all available Google gRPC APIs generated from their proto interfaces.
4//!
5//! The library also provides an easy-to-use client API for gRPC
6//! that supports Google Authentication natively.
7//!
8//! ## gRPC example
9//! ```ignore
10//!
11//!     let firestore_client: GoogleApi<FirestoreClient<GoogleAuthMiddleware>> =
12//!        GoogleApi::from_function(
13//!            FirestoreClient::new,
14//!            "https://firestore.googleapis.com",
15//!            // cloud resource prefix: used only for some of the APIs (such as Firestore)
16//!            Some(cloud_resource_prefix.clone()),
17//!        )
18//!        .await?;
19//!
20//!     let response = firestore_client
21//!         .get()
22//!         .list_documents(tonic::Request::new(ListDocumentsRequest {
23//!             parent: format!("{}/documents", cloud_resource_prefix),
24//!             ..Default::default()
25//!         }))
26//!         .await?;
27//!
28//! ```
29//!
30//! Complete examples available on [github](https://github.com/abdolence/gcloud-sdk-rs/tree/master/src/examples).
31//!
32
33#![allow(unexpected_cfgs)]
34
35// jsonwebtoken panics on its first verification without a crypto provider, and a
36// provider that some other dependency happens to enable is not one to rely on.
37#[cfg(all(
38    feature = "id-token-verify",
39    not(any(
40        feature = "jwt-aws-lc-rs",
41        feature = "jwt-rust-crypto",
42        feature = "jwt-custom-provider"
43    ))
44))]
45compile_error!(
46    "the `id-token-verify` feature needs a jsonwebtoken crypto provider: enable `jwt-aws-lc-rs` \
47     or `jwt-rust-crypto`, or `jwt-custom-provider` when the application installs its own"
48);
49
50mod apis;
51pub use apis::*;
52
53#[cfg(feature = "axum")]
54mod axum_layer;
55#[cfg(feature = "axum")]
56pub use axum_layer::{VerifyIdToken, VerifyIdTokenLayer};
57mod adc;
58mod auth_headers;
59pub mod error;
60mod id_token;
61#[cfg(feature = "id-token-verify")]
62pub mod id_token_verify;
63#[cfg(feature = "id-token-verify")]
64mod jwt_crypto;
65mod metadata;
66pub use auth_headers::GoogleAuthHeaders;
67pub use id_token::{IdTokenAudience, ServiceAccountEmail};
68pub use middleware::GoogleAuthMiddlewareLayer;
69
70mod api_client;
71pub use api_client::*;
72
73mod middleware;
74
75mod request_timeouts;
76pub use request_timeouts::{RequestTimeoutElapsed, RequestTimeouts};
77
78#[cfg(feature = "reqwest-middleware")]
79mod reqwest_auth_middleware;
80#[cfg(feature = "reqwest-middleware")]
81pub use reqwest_auth_middleware::GoogleAuthReqwestMiddleware;
82
83#[cfg(test)]
84mod test_support;
85
86pub mod proto_ext;
87
88pub const GCLOUD_SDK_USER_AGENT: &str = concat!("gcloud-sdk-rs/v", env!("CARGO_PKG_VERSION"));
89
90// Re-exports
91/// The crate that mints every token, at the version this crate is built against: build
92/// [`Credentials`](google_cloud_auth::credentials::Credentials) with it for
93/// [`GoogleApi::from_function_with_credentials`] and [`GoogleAuthHeaders`].
94pub use google_cloud_auth;
95pub use hyper::HeaderMap;
96pub use prost;
97pub use prost_types;
98pub use secret_vault_value::SecretValue;
99pub use tonic;