gcloud_kms/lib.rs
1//! # google-cloud-kms
2//!
3//! Google Cloud Platform Key Management Service Client library.
4//!
5//! ## Quickstart
6//!
7//! ### Authentication
8//! There are two ways to create a client that is authenticated against the google cloud.
9//!
10//! #### Automatically
11//!
12//! The function `with_auth()` will try and read the credentials from a file specified in the environment variable `GOOGLE_APPLICATION_CREDENTIALS`, `GOOGLE_APPLICATION_CREDENTIALS_JSON` or
13//! from a metadata server.
14//!
15//! This is also described in [google-cloud-auth](https://github.com/yoshidan/google-cloud-rust/blob/main/foundation/auth/README.md)
16//!
17//! ```rust
18//! use google_cloud_kms::client::{Client, ClientConfig};
19//!
20//! async fn run() {
21//! let config = ClientConfig::default().with_auth().await.unwrap();
22//! let client = Client::new(config);
23//! }
24//! ```
25//!
26//! #### Manually
27//!
28//! When you can't use the `gcloud` authentication but you have a different way to get your credentials (e.g a different environment variable)
29//! you can parse your own version of the 'credentials-file' and use it like that:
30//!
31//! ```rust
32//! use google_cloud_auth::credentials::CredentialsFile;
33//! // or google_cloud_kms::client::google_cloud_auth::credentials::CredentialsFile
34//! use google_cloud_kms::client::{Client, ClientConfig};
35//!
36//! async fn run(cred: CredentialsFile) {
37//! let config = ClientConfig::default().with_credentials(cred).await.unwrap();
38//! let client = Client::new(config);
39//! }
40//! ```
41//!
42//! ### Usage
43//!
44//! #### Key ring operations
45//!
46//! ```
47//! use std::collections::HashMap;
48//! use prost_types::FieldMask;
49//! use google_cloud_googleapis::cloud::kms::v1::{CreateKeyRingRequest, GetKeyRingRequest, ListKeyRingsRequest};
50//! use google_cloud_kms::client::{Client, ClientConfig};
51//!
52//! async fn run(config: ClientConfig) {
53//!
54//! // Create client
55//! let client = Client::new(config).await.unwrap();
56//!
57//! // Key ring
58//! // create
59//! match client
60//! .create_key_ring(
61//! CreateKeyRingRequest {
62//! parent: "projects/qovery-gcp-tests/locations/europe-west9".to_string(),
63//! key_ring_id: "123-456".to_string(),
64//! key_ring: None,
65//! },
66//! None,
67//! )
68//! .await
69//! {
70//! Ok(mut r) => println!("Created key ring {:?}", r),
71//! Err(err) => panic!("err: {:?}", err),
72//! };
73//!
74//! // list
75//! match client
76//! .list_key_rings(
77//! ListKeyRingsRequest {
78//! parent: "projects/qovery-gcp-tests/locations/europe-west9".to_string(),
79//! page_size: 5,
80//! page_token: "".to_string(),
81//! filter: "".to_string(),
82//! order_by: "".to_string(),
83//! },
84//! None,
85//! )
86//! .await
87//! {
88//! Ok(response) => {
89//! println!("List key rings");
90//! for r in response.key_rings {
91//! println!("- {:?}", r);
92//! }
93//! }
94//! Err(err) => panic!("err: {:?}", err),
95//! };
96//!
97//! // get
98//! match client
99//! .get_key_ring(
100//! GetKeyRingRequest {
101//! name: "projects/qovery-gcp-tests/locations/europe-west9/keyRings/key-ring-for-documentation"
102//! .to_string(),
103//! },
104//! None,
105//! )
106//! .await
107//! {
108//! Ok(response) => {
109//! println!("Get keyring: {:?}", response);
110//! }
111//! Err(err) => panic!("err: {:?}", err),
112//! }
113//!}
114//!```
115//!
116pub mod client;
117pub mod grpc;