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
116
117
118
119
120
121
122
//! MockClient helpers for IAM API.
//!
//! Auto-generated extension methods for ergonomic test setup.
//! **Do not edit manually** — modify the manifest and re-run codegen.
#[cfg(any(test, feature = "test-support"))]
use crate::mock_client::{ExpectationBuilder, MockClient};
/// Extension trait for MockClient with IAM helpers.
#[cfg(any(test, feature = "test-support"))]
pub trait IamMockHelpers {
/// Helper to expect `create_service_account`: Creates a ServiceAccount.
fn expect_create_service_account(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `get_service_account`: Gets a ServiceAccount.
fn expect_get_service_account(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `list_service_accounts`: Lists every ServiceAccount that belongs to a
/// specific project.
fn expect_list_service_accounts(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `delete_service_account`: Deletes a ServiceAccount. **Warning:** After you
/// delete a service account, you might not be able to undelete it. If you know that you need to
/// re-enable the service account in the future, use DisableServiceAccount instead. If you
/// delete a service account, IAM permanently removes the service account 30 days later. Google
/// Cloud cannot recover the service account after it is permanently removed, even if you file a
/// support request. To help avoid unplanned outages, we recommend that you disable the service
/// account before you delete it. Use DisableServiceAccount to disable the service account, then
/// wait at least 24 hours and watch for unintended consequences. If there are no unintended
/// consequences, you can delete the service account.
fn expect_delete_service_account(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `create_service_account_key`: Creates a ServiceAccountKey.
fn expect_create_service_account_key(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `list_service_account_keys`: Lists every ServiceAccountKey for a service
/// account.
fn expect_list_service_account_keys(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `delete_service_account_key`: Deletes a ServiceAccountKey. Deleting a
/// service account key does not revoke short-lived credentials that have been issued based on
/// the service account key.
fn expect_delete_service_account_key(&mut self, name: &str) -> ExpectationBuilder<'_>;
}
#[cfg(any(test, feature = "test-support"))]
impl IamMockHelpers for MockClient {
/// Helper to expect `create_service_account`: Creates a ServiceAccount.
fn expect_create_service_account(
&mut self,
name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}/serviceAccounts");
self.expect_post(&path)
}
/// Helper to expect `get_service_account`: Gets a ServiceAccount.
fn expect_get_service_account(
&mut self,
name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}");
self.expect_get(&path)
}
/// Helper to expect `list_service_accounts`: Lists every ServiceAccount that belongs to a
/// specific project.
fn expect_list_service_accounts(
&mut self,
name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}/serviceAccounts");
self.expect_get(&path)
}
/// Helper to expect `delete_service_account`: Deletes a ServiceAccount. **Warning:** After you
/// delete a service account, you might not be able to undelete it. If you know that you need to
/// re-enable the service account in the future, use DisableServiceAccount instead. If you
/// delete a service account, IAM permanently removes the service account 30 days later. Google
/// Cloud cannot recover the service account after it is permanently removed, even if you file a
/// support request. To help avoid unplanned outages, we recommend that you disable the service
/// account before you delete it. Use DisableServiceAccount to disable the service account, then
/// wait at least 24 hours and watch for unintended consequences. If there are no unintended
/// consequences, you can delete the service account.
fn expect_delete_service_account(
&mut self,
name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}");
self.expect_delete(&path)
}
/// Helper to expect `create_service_account_key`: Creates a ServiceAccountKey.
fn expect_create_service_account_key(
&mut self,
name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}/keys");
self.expect_post(&path)
}
/// Helper to expect `list_service_account_keys`: Lists every ServiceAccountKey for a service
/// account.
fn expect_list_service_account_keys(
&mut self,
name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}/keys");
self.expect_get(&path)
}
/// Helper to expect `delete_service_account_key`: Deletes a ServiceAccountKey. Deleting a
/// service account key does not revoke short-lived credentials that have been issued based on
/// the service account key.
fn expect_delete_service_account_key(
&mut self,
name: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}");
self.expect_delete(&path)
}
}