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
//! MockClient helpers for Service Usage 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 Service Usage helpers.
#[cfg(any(test, feature = "test-support"))]
pub trait ServiceUsageMockHelpers {
/// Helper to expect `get_service`: Returns the service configuration and enabled state for a
/// given service.
fn expect_get_service(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `enable_service`: Enable a service so that it can be used with a project.
fn expect_enable_service(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `disable_service`: Disable a service so that it can no longer be used with
/// a project. This prevents unintended usage that may cause unexpected billing charges or
/// security leaks. It is not valid to call the disable method on a service that is not
/// currently enabled. Callers will receive a `FAILED_PRECONDITION` status if the target service
/// is not currently enabled.
fn expect_disable_service(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `list_services`: List all services available to the specified project, and
/// the current state of those services with respect to the project. The list includes all
/// public services, all services for which the calling user has the
/// `servicemanagement.services.bind` permission, and all services that have already been
/// enabled on the project. The list can be filtered to only include services in a specific
/// state, for example to only include services enabled on the project. WARNING: If you need to
/// query enabled services frequently or across an organization, you should use [Cloud Asset
/// Inventory API](https://cloud.google.com/asset-inventory/docs/apis), which provides higher
/// throughput and richer filtering capability.
fn expect_list_services(
&mut self,
parent: &str,
page_token: &str,
filter: &str,
page_size: &str,
) -> ExpectationBuilder<'_>;
/// Helper to expect `batch_enable_services`: Enable multiple services on a project. The
/// operation is atomic: if enabling any service fails, then the entire batch fails, and no
/// state changes occur. To enable a single service, use the `EnableService` method instead.
fn expect_batch_enable_services(&mut self, parent: &str) -> ExpectationBuilder<'_>;
}
#[cfg(any(test, feature = "test-support"))]
impl ServiceUsageMockHelpers for MockClient {
/// Helper to expect `get_service`: Returns the service configuration and enabled state for a
/// given service.
fn expect_get_service(&mut self, name: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}");
self.expect_get(&path)
}
/// Helper to expect `enable_service`: Enable a service so that it can be used with a project.
fn expect_enable_service(&mut self, name: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}:enable");
self.expect_post(&path)
}
/// Helper to expect `disable_service`: Disable a service so that it can no longer be used with
/// a project. This prevents unintended usage that may cause unexpected billing charges or
/// security leaks. It is not valid to call the disable method on a service that is not
/// currently enabled. Callers will receive a `FAILED_PRECONDITION` status if the target service
/// is not currently enabled.
fn expect_disable_service(&mut self, name: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}:disable");
self.expect_post(&path)
}
/// Helper to expect `list_services`: List all services available to the specified project, and
/// the current state of those services with respect to the project. The list includes all
/// public services, all services for which the calling user has the
/// `servicemanagement.services.bind` permission, and all services that have already been
/// enabled on the project. The list can be filtered to only include services in a specific
/// state, for example to only include services enabled on the project. WARNING: If you need to
/// query enabled services frequently or across an organization, you should use [Cloud Asset
/// Inventory API](https://cloud.google.com/asset-inventory/docs/apis), which provides higher
/// throughput and richer filtering capability.
fn expect_list_services(
&mut self,
parent: &str,
page_token: &str,
filter: &str,
page_size: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let mut path = format!("/v1/{parent}/services");
let mut __qp: Vec<String> = Vec::new();
if !page_token.is_empty() {
__qp.push(format!("pageToken={}", page_token));
}
if !filter.is_empty() {
__qp.push(format!("filter={}", filter));
}
if !page_size.is_empty() {
__qp.push(format!("pageSize={}", page_size));
}
if !__qp.is_empty() {
path = format!("{}?{}", path, __qp.join("&"));
}
self.expect_get(&path)
}
/// Helper to expect `batch_enable_services`: Enable multiple services on a project. The
/// operation is atomic: if enabling any service fails, then the entire batch fails, and no
/// state changes occur. To enable a single service, use the `EnableService` method instead.
fn expect_batch_enable_services(
&mut self,
parent: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{parent}/services:batchEnable");
self.expect_post(&path)
}
}