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 Cloud Scheduler 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 Cloud Scheduler helpers.
#[cfg(any(test, feature = "test-support"))]
pub trait CloudschedulerMockHelpers {
/// Helper to expect `create_job`: Creates a job.
fn expect_create_job(&mut self, parent: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `get_job`: Gets a job.
fn expect_get_job(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `list_jobs`: Lists jobs.
fn expect_list_jobs(&mut self, parent: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `update_job`: Updates a job. If successful, the updated Job is returned. If
/// the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return,
/// it is possible for the job to be in an Job.State.UPDATE_FAILED state. A job in this state
/// may not be executed. If this happens, retry the UpdateJob request until a successful
/// response is received.
fn expect_update_job(&mut self, name: &str, update_mask: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `delete_job`: Deletes a job.
fn expect_delete_job(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `pause_job`: Pauses a job. If a job is paused then the system will stop
/// executing the job until it is re-enabled via ResumeJob. The state of the job is stored in
/// state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to
/// be paused.
fn expect_pause_job(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `resume_job`: Resume a job. This method reenables a job after it has been
/// Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it
/// will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
fn expect_resume_job(&mut self, name: &str) -> ExpectationBuilder<'_>;
/// Helper to expect `run_job`: Forces a job to run now. When this method is called, Cloud
/// Scheduler will dispatch the job, even if the job is already running.
fn expect_run_job(&mut self, name: &str) -> ExpectationBuilder<'_>;
}
#[cfg(any(test, feature = "test-support"))]
impl CloudschedulerMockHelpers for MockClient {
/// Helper to expect `create_job`: Creates a job.
fn expect_create_job(&mut self, parent: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{parent}/jobs");
self.expect_post(&path)
}
/// Helper to expect `get_job`: Gets a job.
fn expect_get_job(&mut self, name: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}");
self.expect_get(&path)
}
/// Helper to expect `list_jobs`: Lists jobs.
fn expect_list_jobs(&mut self, parent: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{parent}/jobs");
self.expect_get(&path)
}
/// Helper to expect `update_job`: Updates a job. If successful, the updated Job is returned. If
/// the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return,
/// it is possible for the job to be in an Job.State.UPDATE_FAILED state. A job in this state
/// may not be executed. If this happens, retry the UpdateJob request until a successful
/// response is received.
fn expect_update_job(
&mut self,
name: &str,
update_mask: &str,
) -> crate::mock_client::ExpectationBuilder<'_> {
let mut path = format!("/v1/{name}");
let mut __qp: Vec<String> = Vec::new();
if !update_mask.is_empty() {
__qp.push(format!("updateMask={}", update_mask));
}
if !__qp.is_empty() {
path = format!("{}?{}", path, __qp.join("&"));
}
self.expect_patch(&path)
}
/// Helper to expect `delete_job`: Deletes a job.
fn expect_delete_job(&mut self, name: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}");
self.expect_delete(&path)
}
/// Helper to expect `pause_job`: Pauses a job. If a job is paused then the system will stop
/// executing the job until it is re-enabled via ResumeJob. The state of the job is stored in
/// state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to
/// be paused.
fn expect_pause_job(&mut self, name: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}:pause");
self.expect_post(&path)
}
/// Helper to expect `resume_job`: Resume a job. This method reenables a job after it has been
/// Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it
/// will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
fn expect_resume_job(&mut self, name: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}:resume");
self.expect_post(&path)
}
/// Helper to expect `run_job`: Forces a job to run now. When this method is called, Cloud
/// Scheduler will dispatch the job, even if the job is already running.
fn expect_run_job(&mut self, name: &str) -> crate::mock_client::ExpectationBuilder<'_> {
let path = format!("/v1/{name}:run");
self.expect_post(&path)
}
}