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