Skip to main content

taskcluster/generated/
workermanager.rs

1#![allow(unused_imports)]
2#![cfg_attr(rustfmt, rustfmt_skip)]
3/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */
4use crate::{Client, ClientBuilder, Credentials, Retry};
5use anyhow::Error;
6use serde_json::Value;
7use std::time::Duration;
8use crate::util::urlencode;
9
10/// Worker Manager Service
11///
12/// This service manages workers, including provisioning for dynamic worker pools.
13///
14/// Methods interacting with a provider may return a 503 response if that provider has
15/// not been able to start up, such as if the service to which it interfaces has an
16/// outage.  Such requests can be retried as for any other 5xx response.
17pub struct WorkerManager {
18    /// The underlying client used to make API calls for this service.
19    pub client: Client
20}
21
22#[allow(non_snake_case)]
23impl WorkerManager {
24    /// Create a new WorkerManager instance, based on the given client builder
25    pub fn new<CB: Into<ClientBuilder>>(client_builder: CB) -> Result<Self, Error> {
26        Ok(Self{
27            client: client_builder
28                .into()
29                .path_prefix("api/worker-manager/v1/")
30                .build()?,
31        })
32    }
33
34    /// Ping Server
35    ///
36    /// Respond without doing anything.
37    /// This endpoint is used to check that the service is up.
38    pub async fn ping(&self) -> Result<(), Error> {
39        let method = "GET";
40        let (path, query) = Self::ping_details();
41        let body = None;
42        let resp = self.client.request(method, path, query, body).await?;
43        resp.bytes().await?;
44        Ok(())
45    }
46
47    /// Generate an unsigned URL for the ping endpoint
48    pub fn ping_url(&self) -> Result<String, Error> {
49        let (path, query) = Self::ping_details();
50        self.client.make_url(path, query)
51    }
52
53    /// Generate a signed URL for the ping endpoint
54    pub fn ping_signed_url(&self, ttl: Duration) -> Result<String, Error> {
55        let (path, query) = Self::ping_details();
56        self.client.make_signed_url(path, query, ttl)
57    }
58
59    /// Determine the HTTP request details for ping
60    fn ping_details<'a>() -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
61        let path = "ping";
62        let query = None;
63
64        (path, query)
65    }
66
67    /// Load Balancer Heartbeat
68    ///
69    /// Respond without doing anything.
70    /// This endpoint is used to check that the service is up.
71    pub async fn lbheartbeat(&self) -> Result<(), Error> {
72        let method = "GET";
73        let (path, query) = Self::lbheartbeat_details();
74        let body = None;
75        let resp = self.client.request(method, path, query, body).await?;
76        resp.bytes().await?;
77        Ok(())
78    }
79
80    /// Generate an unsigned URL for the lbheartbeat endpoint
81    pub fn lbheartbeat_url(&self) -> Result<String, Error> {
82        let (path, query) = Self::lbheartbeat_details();
83        self.client.make_url(path, query)
84    }
85
86    /// Generate a signed URL for the lbheartbeat endpoint
87    pub fn lbheartbeat_signed_url(&self, ttl: Duration) -> Result<String, Error> {
88        let (path, query) = Self::lbheartbeat_details();
89        self.client.make_signed_url(path, query, ttl)
90    }
91
92    /// Determine the HTTP request details for lbheartbeat
93    fn lbheartbeat_details<'a>() -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
94        let path = "__lbheartbeat__";
95        let query = None;
96
97        (path, query)
98    }
99
100    /// Taskcluster Version
101    ///
102    /// Respond with the JSON version object.
103    /// https://github.com/mozilla-services/Dockerflow/blob/main/docs/version_object.md
104    pub async fn version(&self) -> Result<(), Error> {
105        let method = "GET";
106        let (path, query) = Self::version_details();
107        let body = None;
108        let resp = self.client.request(method, path, query, body).await?;
109        resp.bytes().await?;
110        Ok(())
111    }
112
113    /// Generate an unsigned URL for the version endpoint
114    pub fn version_url(&self) -> Result<String, Error> {
115        let (path, query) = Self::version_details();
116        self.client.make_url(path, query)
117    }
118
119    /// Generate a signed URL for the version endpoint
120    pub fn version_signed_url(&self, ttl: Duration) -> Result<String, Error> {
121        let (path, query) = Self::version_details();
122        self.client.make_signed_url(path, query, ttl)
123    }
124
125    /// Determine the HTTP request details for version
126    fn version_details<'a>() -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
127        let path = "__version__";
128        let query = None;
129
130        (path, query)
131    }
132
133    /// List Providers
134    ///
135    /// Retrieve a list of providers that are available for worker pools.
136    pub async fn listProviders(&self, continuationToken: Option<&str>, limit: Option<&str>) -> Result<Value, Error> {
137        let method = "GET";
138        let (path, query) = Self::listProviders_details(continuationToken, limit);
139        let body = None;
140        let resp = self.client.request(method, path, query, body).await?;
141        Ok(resp.json().await?)
142    }
143
144    /// Generate an unsigned URL for the listProviders endpoint
145    pub fn listProviders_url(&self, continuationToken: Option<&str>, limit: Option<&str>) -> Result<String, Error> {
146        let (path, query) = Self::listProviders_details(continuationToken, limit);
147        self.client.make_url(path, query)
148    }
149
150    /// Generate a signed URL for the listProviders endpoint
151    pub fn listProviders_signed_url(&self, continuationToken: Option<&str>, limit: Option<&str>, ttl: Duration) -> Result<String, Error> {
152        let (path, query) = Self::listProviders_details(continuationToken, limit);
153        self.client.make_signed_url(path, query, ttl)
154    }
155
156    /// Determine the HTTP request details for listProviders
157    fn listProviders_details<'a>(continuationToken: Option<&'a str>, limit: Option<&'a str>) -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
158        let path = "providers";
159        let mut query = None;
160        if let Some(q) = continuationToken {
161            query.get_or_insert_with(Vec::new).push(("continuationToken", q));
162        }
163        if let Some(q) = limit {
164            query.get_or_insert_with(Vec::new).push(("limit", q));
165        }
166
167        (path, query)
168    }
169
170    /// Create Worker Pool
171    ///
172    /// Create a new worker pool. If the worker pool already exists, this will throw an error.
173    pub async fn createWorkerPool(&self, workerPoolId: &str, payload: &Value) -> Result<Value, Error> {
174        let method = "PUT";
175        let (path, query) = Self::createWorkerPool_details(workerPoolId);
176        let body = Some(payload);
177        let resp = self.client.request(method, &path, query, body).await?;
178        Ok(resp.json().await?)
179    }
180
181    /// Determine the HTTP request details for createWorkerPool
182    fn createWorkerPool_details<'a>(workerPoolId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
183        let path = format!("worker-pool/{}", urlencode(workerPoolId));
184        let query = None;
185
186        (path, query)
187    }
188
189    /// Update Worker Pool
190    ///
191    /// Given an existing worker pool definition, this will modify it and return
192    /// the new definition.
193    ///
194    /// To delete a worker pool, set its `providerId` to `"null-provider"`.
195    /// After any existing workers have exited, a cleanup job will remove the
196    /// worker pool.  During that time, the worker pool can be updated again, such
197    /// as to set its `providerId` to a real provider.
198    pub async fn updateWorkerPool(&self, workerPoolId: &str, payload: &Value) -> Result<Value, Error> {
199        let method = "POST";
200        let (path, query) = Self::updateWorkerPool_details(workerPoolId);
201        let body = Some(payload);
202        let resp = self.client.request(method, &path, query, body).await?;
203        Ok(resp.json().await?)
204    }
205
206    /// Determine the HTTP request details for updateWorkerPool
207    fn updateWorkerPool_details<'a>(workerPoolId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
208        let path = format!("worker-pool/{}", urlencode(workerPoolId));
209        let query = None;
210
211        (path, query)
212    }
213
214    /// Delete Worker Pool
215    ///
216    /// Mark a worker pool for deletion.  This is the same as updating the pool to
217    /// set its providerId to `"null-provider"`, but does not require scope
218    /// `worker-manager:provider:null-provider`.
219    /// This will also mark all launch configurations as archived.
220    pub async fn deleteWorkerPool(&self, workerPoolId: &str) -> Result<Value, Error> {
221        let method = "DELETE";
222        let (path, query) = Self::deleteWorkerPool_details(workerPoolId);
223        let body = None;
224        let resp = self.client.request(method, &path, query, body).await?;
225        Ok(resp.json().await?)
226    }
227
228    /// Determine the HTTP request details for deleteWorkerPool
229    fn deleteWorkerPool_details<'a>(workerPoolId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
230        let path = format!("worker-pool/{}", urlencode(workerPoolId));
231        let query = None;
232
233        (path, query)
234    }
235
236    /// List Worker Pool Launch Configs
237    ///
238    /// Get the list of launch configurations for a given worker pool.
239    /// Include archived launch configurations by setting includeArchived=true.
240    /// By default, only active launch configurations are returned.
241    pub async fn listWorkerPoolLaunchConfigs(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, includeArchived: Option<&str>) -> Result<Value, Error> {
242        let method = "GET";
243        let (path, query) = Self::listWorkerPoolLaunchConfigs_details(workerPoolId, continuationToken, limit, includeArchived);
244        let body = None;
245        let resp = self.client.request(method, &path, query, body).await?;
246        Ok(resp.json().await?)
247    }
248
249    /// Generate an unsigned URL for the listWorkerPoolLaunchConfigs endpoint
250    pub fn listWorkerPoolLaunchConfigs_url(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, includeArchived: Option<&str>) -> Result<String, Error> {
251        let (path, query) = Self::listWorkerPoolLaunchConfigs_details(workerPoolId, continuationToken, limit, includeArchived);
252        self.client.make_url(&path, query)
253    }
254
255    /// Generate a signed URL for the listWorkerPoolLaunchConfigs endpoint
256    pub fn listWorkerPoolLaunchConfigs_signed_url(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, includeArchived: Option<&str>, ttl: Duration) -> Result<String, Error> {
257        let (path, query) = Self::listWorkerPoolLaunchConfigs_details(workerPoolId, continuationToken, limit, includeArchived);
258        self.client.make_signed_url(&path, query, ttl)
259    }
260
261    /// Determine the HTTP request details for listWorkerPoolLaunchConfigs
262    fn listWorkerPoolLaunchConfigs_details<'a>(workerPoolId: &'a str, continuationToken: Option<&'a str>, limit: Option<&'a str>, includeArchived: Option<&'a str>) -> (String, Option<Vec<(&'static str, &'a str)>>) {
263        let path = format!("worker-pool/{}/launch-configs", urlencode(workerPoolId));
264        let mut query = None;
265        if let Some(q) = continuationToken {
266            query.get_or_insert_with(Vec::new).push(("continuationToken", q));
267        }
268        if let Some(q) = limit {
269            query.get_or_insert_with(Vec::new).push(("limit", q));
270        }
271        if let Some(q) = includeArchived {
272            query.get_or_insert_with(Vec::new).push(("includeArchived", q));
273        }
274
275        (path, query)
276    }
277
278    /// Get Worker Pool Statistics
279    ///
280    /// Fetch statistics for an existing worker pool, broken down by launch configuration.
281    /// This includes counts and capacities of requested, running, stopping, and stopped workers.
282    pub async fn workerPoolStats(&self, workerPoolId: &str) -> Result<Value, Error> {
283        let method = "GET";
284        let (path, query) = Self::workerPoolStats_details(workerPoolId);
285        let body = None;
286        let resp = self.client.request(method, &path, query, body).await?;
287        Ok(resp.json().await?)
288    }
289
290    /// Generate an unsigned URL for the workerPoolStats endpoint
291    pub fn workerPoolStats_url(&self, workerPoolId: &str) -> Result<String, Error> {
292        let (path, query) = Self::workerPoolStats_details(workerPoolId);
293        self.client.make_url(&path, query)
294    }
295
296    /// Generate a signed URL for the workerPoolStats endpoint
297    pub fn workerPoolStats_signed_url(&self, workerPoolId: &str, ttl: Duration) -> Result<String, Error> {
298        let (path, query) = Self::workerPoolStats_details(workerPoolId);
299        self.client.make_signed_url(&path, query, ttl)
300    }
301
302    /// Determine the HTTP request details for workerPoolStats
303    fn workerPoolStats_details<'a>(workerPoolId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
304        let path = format!("worker-pool/{}/stats", urlencode(workerPoolId));
305        let query = None;
306
307        (path, query)
308    }
309
310    /// Get Worker Pool
311    ///
312    /// Fetch an existing worker pool defition.
313    pub async fn workerPool(&self, workerPoolId: &str) -> Result<Value, Error> {
314        let method = "GET";
315        let (path, query) = Self::workerPool_details(workerPoolId);
316        let body = None;
317        let resp = self.client.request(method, &path, query, body).await?;
318        Ok(resp.json().await?)
319    }
320
321    /// Generate an unsigned URL for the workerPool endpoint
322    pub fn workerPool_url(&self, workerPoolId: &str) -> Result<String, Error> {
323        let (path, query) = Self::workerPool_details(workerPoolId);
324        self.client.make_url(&path, query)
325    }
326
327    /// Generate a signed URL for the workerPool endpoint
328    pub fn workerPool_signed_url(&self, workerPoolId: &str, ttl: Duration) -> Result<String, Error> {
329        let (path, query) = Self::workerPool_details(workerPoolId);
330        self.client.make_signed_url(&path, query, ttl)
331    }
332
333    /// Determine the HTTP request details for workerPool
334    fn workerPool_details<'a>(workerPoolId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
335        let path = format!("worker-pool/{}", urlencode(workerPoolId));
336        let query = None;
337
338        (path, query)
339    }
340
341    /// List All Worker Pools
342    ///
343    /// Get the list of all the existing worker pools.
344    pub async fn listWorkerPools(&self, continuationToken: Option<&str>, limit: Option<&str>) -> Result<Value, Error> {
345        let method = "GET";
346        let (path, query) = Self::listWorkerPools_details(continuationToken, limit);
347        let body = None;
348        let resp = self.client.request(method, path, query, body).await?;
349        Ok(resp.json().await?)
350    }
351
352    /// Generate an unsigned URL for the listWorkerPools endpoint
353    pub fn listWorkerPools_url(&self, continuationToken: Option<&str>, limit: Option<&str>) -> Result<String, Error> {
354        let (path, query) = Self::listWorkerPools_details(continuationToken, limit);
355        self.client.make_url(path, query)
356    }
357
358    /// Generate a signed URL for the listWorkerPools endpoint
359    pub fn listWorkerPools_signed_url(&self, continuationToken: Option<&str>, limit: Option<&str>, ttl: Duration) -> Result<String, Error> {
360        let (path, query) = Self::listWorkerPools_details(continuationToken, limit);
361        self.client.make_signed_url(path, query, ttl)
362    }
363
364    /// Determine the HTTP request details for listWorkerPools
365    fn listWorkerPools_details<'a>(continuationToken: Option<&'a str>, limit: Option<&'a str>) -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
366        let path = "worker-pools";
367        let mut query = None;
368        if let Some(q) = continuationToken {
369            query.get_or_insert_with(Vec::new).push(("continuationToken", q));
370        }
371        if let Some(q) = limit {
372            query.get_or_insert_with(Vec::new).push(("limit", q));
373        }
374
375        (path, query)
376    }
377
378    /// List All Worker Pools Stats
379    ///
380    /// Get the stats for all worker pools - number of requested, running, stopping and stopped capacity
381    pub async fn listWorkerPoolsStats(&self, continuationToken: Option<&str>, limit: Option<&str>) -> Result<Value, Error> {
382        let method = "GET";
383        let (path, query) = Self::listWorkerPoolsStats_details(continuationToken, limit);
384        let body = None;
385        let resp = self.client.request(method, path, query, body).await?;
386        Ok(resp.json().await?)
387    }
388
389    /// Generate an unsigned URL for the listWorkerPoolsStats endpoint
390    pub fn listWorkerPoolsStats_url(&self, continuationToken: Option<&str>, limit: Option<&str>) -> Result<String, Error> {
391        let (path, query) = Self::listWorkerPoolsStats_details(continuationToken, limit);
392        self.client.make_url(path, query)
393    }
394
395    /// Generate a signed URL for the listWorkerPoolsStats endpoint
396    pub fn listWorkerPoolsStats_signed_url(&self, continuationToken: Option<&str>, limit: Option<&str>, ttl: Duration) -> Result<String, Error> {
397        let (path, query) = Self::listWorkerPoolsStats_details(continuationToken, limit);
398        self.client.make_signed_url(path, query, ttl)
399    }
400
401    /// Determine the HTTP request details for listWorkerPoolsStats
402    fn listWorkerPoolsStats_details<'a>(continuationToken: Option<&'a str>, limit: Option<&'a str>) -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
403        let path = "worker-pools/stats";
404        let mut query = None;
405        if let Some(q) = continuationToken {
406            query.get_or_insert_with(Vec::new).push(("continuationToken", q));
407        }
408        if let Some(q) = limit {
409            query.get_or_insert_with(Vec::new).push(("limit", q));
410        }
411
412        (path, query)
413    }
414
415    /// Report an error from a worker
416    ///
417    /// Report an error that occurred on a worker.  This error will be included
418    /// with the other errors in `listWorkerPoolErrors(workerPoolId)`.
419    ///
420    /// Workers can use this endpoint to report startup or configuration errors
421    /// that might be associated with the worker pool configuration and thus of
422    /// interest to a worker-pool administrator.
423    ///
424    /// NOTE: errors are publicly visible.  Ensure that none of the content
425    /// contains secrets or other sensitive information.
426    pub async fn reportWorkerError(&self, workerPoolId: &str, payload: &Value) -> Result<Value, Error> {
427        let method = "POST";
428        let (path, query) = Self::reportWorkerError_details(workerPoolId);
429        let body = Some(payload);
430        let resp = self.client.request(method, &path, query, body).await?;
431        Ok(resp.json().await?)
432    }
433
434    /// Determine the HTTP request details for reportWorkerError
435    fn reportWorkerError_details<'a>(workerPoolId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
436        let path = format!("worker-pool-errors/{}", urlencode(workerPoolId));
437        let query = None;
438
439        (path, query)
440    }
441
442    /// List Worker Pool Errors Count
443    ///
444    /// Get the list of worker pool errors count.
445    /// Contains total count of errors for the past 7 days and 24 hours
446    /// Also includes total counts grouped by titles of error and error code.
447    ///
448    /// If `workerPoolId` is not specified, it will return the count of all errors
449    pub async fn workerPoolErrorStats(&self, workerPoolId: Option<&str>) -> Result<Value, Error> {
450        let method = "GET";
451        let (path, query) = Self::workerPoolErrorStats_details(workerPoolId);
452        let body = None;
453        let resp = self.client.request(method, path, query, body).await?;
454        Ok(resp.json().await?)
455    }
456
457    /// Generate an unsigned URL for the workerPoolErrorStats endpoint
458    pub fn workerPoolErrorStats_url(&self, workerPoolId: Option<&str>) -> Result<String, Error> {
459        let (path, query) = Self::workerPoolErrorStats_details(workerPoolId);
460        self.client.make_url(path, query)
461    }
462
463    /// Generate a signed URL for the workerPoolErrorStats endpoint
464    pub fn workerPoolErrorStats_signed_url(&self, workerPoolId: Option<&str>, ttl: Duration) -> Result<String, Error> {
465        let (path, query) = Self::workerPoolErrorStats_details(workerPoolId);
466        self.client.make_signed_url(path, query, ttl)
467    }
468
469    /// Determine the HTTP request details for workerPoolErrorStats
470    fn workerPoolErrorStats_details<'a>(workerPoolId: Option<&'a str>) -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
471        let path = "worker-pool-errors/stats";
472        let mut query = None;
473        if let Some(q) = workerPoolId {
474            query.get_or_insert_with(Vec::new).push(("workerPoolId", q));
475        }
476
477        (path, query)
478    }
479
480    /// List Worker Pool Errors
481    ///
482    /// Get the list of worker pool errors.
483    pub async fn listWorkerPoolErrors(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, errorId: Option<&str>) -> Result<Value, Error> {
484        let method = "GET";
485        let (path, query) = Self::listWorkerPoolErrors_details(workerPoolId, continuationToken, limit, launchConfigId, errorId);
486        let body = None;
487        let resp = self.client.request(method, &path, query, body).await?;
488        Ok(resp.json().await?)
489    }
490
491    /// Generate an unsigned URL for the listWorkerPoolErrors endpoint
492    pub fn listWorkerPoolErrors_url(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, errorId: Option<&str>) -> Result<String, Error> {
493        let (path, query) = Self::listWorkerPoolErrors_details(workerPoolId, continuationToken, limit, launchConfigId, errorId);
494        self.client.make_url(&path, query)
495    }
496
497    /// Generate a signed URL for the listWorkerPoolErrors endpoint
498    pub fn listWorkerPoolErrors_signed_url(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, errorId: Option<&str>, ttl: Duration) -> Result<String, Error> {
499        let (path, query) = Self::listWorkerPoolErrors_details(workerPoolId, continuationToken, limit, launchConfigId, errorId);
500        self.client.make_signed_url(&path, query, ttl)
501    }
502
503    /// Determine the HTTP request details for listWorkerPoolErrors
504    fn listWorkerPoolErrors_details<'a>(workerPoolId: &'a str, continuationToken: Option<&'a str>, limit: Option<&'a str>, launchConfigId: Option<&'a str>, errorId: Option<&'a str>) -> (String, Option<Vec<(&'static str, &'a str)>>) {
505        let path = format!("worker-pool-errors/{}", urlencode(workerPoolId));
506        let mut query = None;
507        if let Some(q) = continuationToken {
508            query.get_or_insert_with(Vec::new).push(("continuationToken", q));
509        }
510        if let Some(q) = limit {
511            query.get_or_insert_with(Vec::new).push(("limit", q));
512        }
513        if let Some(q) = launchConfigId {
514            query.get_or_insert_with(Vec::new).push(("launchConfigId", q));
515        }
516        if let Some(q) = errorId {
517            query.get_or_insert_with(Vec::new).push(("errorId", q));
518        }
519
520        (path, query)
521    }
522
523    /// Workers in a specific Worker Group in a Worker Pool
524    ///
525    /// Get the list of all the existing workers in a given group in a given worker pool.
526    pub async fn listWorkersForWorkerGroup(&self, workerPoolId: &str, workerGroup: &str, continuationToken: Option<&str>, limit: Option<&str>) -> Result<Value, Error> {
527        let method = "GET";
528        let (path, query) = Self::listWorkersForWorkerGroup_details(workerPoolId, workerGroup, continuationToken, limit);
529        let body = None;
530        let resp = self.client.request(method, &path, query, body).await?;
531        Ok(resp.json().await?)
532    }
533
534    /// Generate an unsigned URL for the listWorkersForWorkerGroup endpoint
535    pub fn listWorkersForWorkerGroup_url(&self, workerPoolId: &str, workerGroup: &str, continuationToken: Option<&str>, limit: Option<&str>) -> Result<String, Error> {
536        let (path, query) = Self::listWorkersForWorkerGroup_details(workerPoolId, workerGroup, continuationToken, limit);
537        self.client.make_url(&path, query)
538    }
539
540    /// Generate a signed URL for the listWorkersForWorkerGroup endpoint
541    pub fn listWorkersForWorkerGroup_signed_url(&self, workerPoolId: &str, workerGroup: &str, continuationToken: Option<&str>, limit: Option<&str>, ttl: Duration) -> Result<String, Error> {
542        let (path, query) = Self::listWorkersForWorkerGroup_details(workerPoolId, workerGroup, continuationToken, limit);
543        self.client.make_signed_url(&path, query, ttl)
544    }
545
546    /// Determine the HTTP request details for listWorkersForWorkerGroup
547    fn listWorkersForWorkerGroup_details<'a>(workerPoolId: &'a str, workerGroup: &'a str, continuationToken: Option<&'a str>, limit: Option<&'a str>) -> (String, Option<Vec<(&'static str, &'a str)>>) {
548        let path = format!("workers/{}/{}", urlencode(workerPoolId), urlencode(workerGroup));
549        let mut query = None;
550        if let Some(q) = continuationToken {
551            query.get_or_insert_with(Vec::new).push(("continuationToken", q));
552        }
553        if let Some(q) = limit {
554            query.get_or_insert_with(Vec::new).push(("limit", q));
555        }
556
557        (path, query)
558    }
559
560    /// Get a Worker
561    ///
562    /// Get a single worker.
563    pub async fn worker(&self, workerPoolId: &str, workerGroup: &str, workerId: &str) -> Result<Value, Error> {
564        let method = "GET";
565        let (path, query) = Self::worker_details(workerPoolId, workerGroup, workerId);
566        let body = None;
567        let resp = self.client.request(method, &path, query, body).await?;
568        Ok(resp.json().await?)
569    }
570
571    /// Generate an unsigned URL for the worker endpoint
572    pub fn worker_url(&self, workerPoolId: &str, workerGroup: &str, workerId: &str) -> Result<String, Error> {
573        let (path, query) = Self::worker_details(workerPoolId, workerGroup, workerId);
574        self.client.make_url(&path, query)
575    }
576
577    /// Generate a signed URL for the worker endpoint
578    pub fn worker_signed_url(&self, workerPoolId: &str, workerGroup: &str, workerId: &str, ttl: Duration) -> Result<String, Error> {
579        let (path, query) = Self::worker_details(workerPoolId, workerGroup, workerId);
580        self.client.make_signed_url(&path, query, ttl)
581    }
582
583    /// Determine the HTTP request details for worker
584    fn worker_details<'a>(workerPoolId: &'a str, workerGroup: &'a str, workerId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
585        let path = format!("workers/{}/{}/{}", urlencode(workerPoolId), urlencode(workerGroup), urlencode(workerId));
586        let query = None;
587
588        (path, query)
589    }
590
591    /// Create a Worker
592    ///
593    /// Create a new worker.  This is only useful for worker pools where the provider
594    /// does not create workers automatically, such as those with a `static` provider
595    /// type.  Providers that do not support creating workers will return a 400 error.
596    /// See the documentation for the individual providers, and in particular the
597    /// [static provider](https://docs.taskcluster.net/docs/reference/core/worker-manager/)
598    /// for more information.
599    pub async fn createWorker(&self, workerPoolId: &str, workerGroup: &str, workerId: &str, payload: &Value) -> Result<Value, Error> {
600        let method = "PUT";
601        let (path, query) = Self::createWorker_details(workerPoolId, workerGroup, workerId);
602        let body = Some(payload);
603        let resp = self.client.request(method, &path, query, body).await?;
604        Ok(resp.json().await?)
605    }
606
607    /// Determine the HTTP request details for createWorker
608    fn createWorker_details<'a>(workerPoolId: &'a str, workerGroup: &'a str, workerId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
609        let path = format!("workers/{}/{}/{}", urlencode(workerPoolId), urlencode(workerGroup), urlencode(workerId));
610        let query = None;
611
612        (path, query)
613    }
614
615    /// Update an existing Worker
616    ///
617    /// Update an existing worker in-place.  Like `createWorker`, this is only useful for
618    /// worker pools where the provider does not create workers automatically.
619    /// This method allows updating all fields in the schema unless otherwise indicated
620    /// in the provider documentation.
621    /// See the documentation for the individual providers, and in particular the
622    /// [static provider](https://docs.taskcluster.net/docs/reference/core/worker-manager/)
623    /// for more information.
624    pub async fn updateWorker(&self, workerPoolId: &str, workerGroup: &str, workerId: &str, payload: &Value) -> Result<Value, Error> {
625        let method = "POST";
626        let (path, query) = Self::updateWorker_details(workerPoolId, workerGroup, workerId);
627        let body = Some(payload);
628        let resp = self.client.request(method, &path, query, body).await?;
629        Ok(resp.json().await?)
630    }
631
632    /// Determine the HTTP request details for updateWorker
633    fn updateWorker_details<'a>(workerPoolId: &'a str, workerGroup: &'a str, workerId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
634        let path = format!("workers/{}/{}/{}", urlencode(workerPoolId), urlencode(workerGroup), urlencode(workerId));
635        let query = None;
636
637        (path, query)
638    }
639
640    /// Remove a Worker
641    ///
642    /// Remove an existing worker.  The precise behavior of this method depends
643    /// on the provider implementing the given worker.  Some providers
644    /// do not support removing workers at all, and will return a 400 error.
645    /// Others may begin removing the worker, but it may remain available via
646    /// the API (perhaps even in state RUNNING) afterward.
647    pub async fn removeWorker(&self, workerPoolId: &str, workerGroup: &str, workerId: &str) -> Result<(), Error> {
648        let method = "DELETE";
649        let (path, query) = Self::removeWorker_details(workerPoolId, workerGroup, workerId);
650        let body = None;
651        let resp = self.client.request(method, &path, query, body).await?;
652        resp.bytes().await?;
653        Ok(())
654    }
655
656    /// Determine the HTTP request details for removeWorker
657    fn removeWorker_details<'a>(workerPoolId: &'a str, workerGroup: &'a str, workerId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
658        let path = format!("workers/{}/{}/{}", urlencode(workerPoolId), urlencode(workerGroup), urlencode(workerId));
659        let query = None;
660
661        (path, query)
662    }
663
664    /// Should worker terminate
665    ///
666    /// Informs if worker should terminate or keep working.
667    /// Worker might no longer be needed based on the set of factors:
668    ///  - current capacity of the worker pool
669    ///  - amount of pending and claimed tasks
670    ///  - launch configuration changes
671    ///
672    /// Decision is made during provision or scanning loop based on above mentioned conditions.
673    pub async fn shouldWorkerTerminate(&self, workerPoolId: &str, workerGroup: &str, workerId: &str) -> Result<Value, Error> {
674        let method = "GET";
675        let (path, query) = Self::shouldWorkerTerminate_details(workerPoolId, workerGroup, workerId);
676        let body = None;
677        let resp = self.client.request(method, &path, query, body).await?;
678        Ok(resp.json().await?)
679    }
680
681    /// Generate an unsigned URL for the shouldWorkerTerminate endpoint
682    pub fn shouldWorkerTerminate_url(&self, workerPoolId: &str, workerGroup: &str, workerId: &str) -> Result<String, Error> {
683        let (path, query) = Self::shouldWorkerTerminate_details(workerPoolId, workerGroup, workerId);
684        self.client.make_url(&path, query)
685    }
686
687    /// Generate a signed URL for the shouldWorkerTerminate endpoint
688    pub fn shouldWorkerTerminate_signed_url(&self, workerPoolId: &str, workerGroup: &str, workerId: &str, ttl: Duration) -> Result<String, Error> {
689        let (path, query) = Self::shouldWorkerTerminate_details(workerPoolId, workerGroup, workerId);
690        self.client.make_signed_url(&path, query, ttl)
691    }
692
693    /// Determine the HTTP request details for shouldWorkerTerminate
694    fn shouldWorkerTerminate_details<'a>(workerPoolId: &'a str, workerGroup: &'a str, workerId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
695        let path = format!("workers/{}/{}/{}/should-terminate", urlencode(workerPoolId), urlencode(workerGroup), urlencode(workerId));
696        let query = None;
697
698        (path, query)
699    }
700
701    /// Workers in a Worker Pool
702    ///
703    /// Get the list of all the existing workers in a given worker pool.
704    pub async fn listWorkersForWorkerPool(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, state: Option<&str>) -> Result<Value, Error> {
705        let method = "GET";
706        let (path, query) = Self::listWorkersForWorkerPool_details(workerPoolId, continuationToken, limit, launchConfigId, state);
707        let body = None;
708        let resp = self.client.request(method, &path, query, body).await?;
709        Ok(resp.json().await?)
710    }
711
712    /// Generate an unsigned URL for the listWorkersForWorkerPool endpoint
713    pub fn listWorkersForWorkerPool_url(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, state: Option<&str>) -> Result<String, Error> {
714        let (path, query) = Self::listWorkersForWorkerPool_details(workerPoolId, continuationToken, limit, launchConfigId, state);
715        self.client.make_url(&path, query)
716    }
717
718    /// Generate a signed URL for the listWorkersForWorkerPool endpoint
719    pub fn listWorkersForWorkerPool_signed_url(&self, workerPoolId: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, state: Option<&str>, ttl: Duration) -> Result<String, Error> {
720        let (path, query) = Self::listWorkersForWorkerPool_details(workerPoolId, continuationToken, limit, launchConfigId, state);
721        self.client.make_signed_url(&path, query, ttl)
722    }
723
724    /// Determine the HTTP request details for listWorkersForWorkerPool
725    fn listWorkersForWorkerPool_details<'a>(workerPoolId: &'a str, continuationToken: Option<&'a str>, limit: Option<&'a str>, launchConfigId: Option<&'a str>, state: Option<&'a str>) -> (String, Option<Vec<(&'static str, &'a str)>>) {
726        let path = format!("workers/{}", urlencode(workerPoolId));
727        let mut query = None;
728        if let Some(q) = continuationToken {
729            query.get_or_insert_with(Vec::new).push(("continuationToken", q));
730        }
731        if let Some(q) = limit {
732            query.get_or_insert_with(Vec::new).push(("limit", q));
733        }
734        if let Some(q) = launchConfigId {
735            query.get_or_insert_with(Vec::new).push(("launchConfigId", q));
736        }
737        if let Some(q) = state {
738            query.get_or_insert_with(Vec::new).push(("state", q));
739        }
740
741        (path, query)
742    }
743
744    /// Register a running worker
745    ///
746    /// Register a running worker.  Workers call this method on worker start-up.
747    ///
748    /// This call both marks the worker as running and returns the credentials
749    /// the worker will require to perform its work.  The worker must provide
750    /// some proof of its identity, and that proof varies by provider type.
751    pub async fn registerWorker(&self, payload: &Value) -> Result<Value, Error> {
752        let method = "POST";
753        let (path, query) = Self::registerWorker_details();
754        let body = Some(payload);
755        let resp = self.client.request(method, path, query, body).await?;
756        Ok(resp.json().await?)
757    }
758
759    /// Determine the HTTP request details for registerWorker
760    fn registerWorker_details<'a>() -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
761        let path = "worker/register";
762        let query = None;
763
764        (path, query)
765    }
766
767    /// Reregister a Worker
768    ///
769    /// Reregister a running worker.
770    ///
771    /// This will generate and return new Taskcluster credentials for the worker
772    /// on that instance to use. The credentials will not live longer the
773    /// `registrationTimeout` for that worker. The endpoint will update `terminateAfter`
774    /// for the worker so that worker-manager does not terminate the instance.
775    pub async fn reregisterWorker(&self, payload: &Value) -> Result<Value, Error> {
776        let method = "POST";
777        let (path, query) = Self::reregisterWorker_details();
778        let body = Some(payload);
779        let resp = self.client.request(method, path, query, body).await?;
780        Ok(resp.json().await?)
781    }
782
783    /// Determine the HTTP request details for reregisterWorker
784    fn reregisterWorker_details<'a>() -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
785        let path = "worker/reregister";
786        let query = None;
787
788        (path, query)
789    }
790
791    /// Get a list of all active workers of a workerType
792    ///
793    /// Get a list of all active workers of a workerType.
794    ///
795    /// `listWorkers` allows a response to be filtered by quarantined and non quarantined workers,
796    /// as well as the current state of the worker.
797    /// To filter the query, you should call the end-point with one of [`quarantined`, `workerState`]
798    /// as a query-string option with a true or false value.
799    ///
800    /// The response is paged. If this end-point returns a `continuationToken`, you
801    /// should call the end-point again with the `continuationToken` as a query-string
802    /// option. By default this end-point will list up to 1000 workers in a single
803    /// page. You may limit this with the query-string parameter `limit`.
804    pub async fn listWorkers(&self, provisionerId: &str, workerType: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, quarantined: Option<&str>, workerState: Option<&str>) -> Result<Value, Error> {
805        let method = "GET";
806        let (path, query) = Self::listWorkers_details(provisionerId, workerType, continuationToken, limit, launchConfigId, quarantined, workerState);
807        let body = None;
808        let resp = self.client.request(method, &path, query, body).await?;
809        Ok(resp.json().await?)
810    }
811
812    /// Generate an unsigned URL for the listWorkers endpoint
813    pub fn listWorkers_url(&self, provisionerId: &str, workerType: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, quarantined: Option<&str>, workerState: Option<&str>) -> Result<String, Error> {
814        let (path, query) = Self::listWorkers_details(provisionerId, workerType, continuationToken, limit, launchConfigId, quarantined, workerState);
815        self.client.make_url(&path, query)
816    }
817
818    /// Generate a signed URL for the listWorkers endpoint
819    pub fn listWorkers_signed_url(&self, provisionerId: &str, workerType: &str, continuationToken: Option<&str>, limit: Option<&str>, launchConfigId: Option<&str>, quarantined: Option<&str>, workerState: Option<&str>, ttl: Duration) -> Result<String, Error> {
820        let (path, query) = Self::listWorkers_details(provisionerId, workerType, continuationToken, limit, launchConfigId, quarantined, workerState);
821        self.client.make_signed_url(&path, query, ttl)
822    }
823
824    /// Determine the HTTP request details for listWorkers
825    fn listWorkers_details<'a>(provisionerId: &'a str, workerType: &'a str, continuationToken: Option<&'a str>, limit: Option<&'a str>, launchConfigId: Option<&'a str>, quarantined: Option<&'a str>, workerState: Option<&'a str>) -> (String, Option<Vec<(&'static str, &'a str)>>) {
826        let path = format!("provisioners/{}/worker-types/{}/workers", urlencode(provisionerId), urlencode(workerType));
827        let mut query = None;
828        if let Some(q) = continuationToken {
829            query.get_or_insert_with(Vec::new).push(("continuationToken", q));
830        }
831        if let Some(q) = limit {
832            query.get_or_insert_with(Vec::new).push(("limit", q));
833        }
834        if let Some(q) = launchConfigId {
835            query.get_or_insert_with(Vec::new).push(("launchConfigId", q));
836        }
837        if let Some(q) = quarantined {
838            query.get_or_insert_with(Vec::new).push(("quarantined", q));
839        }
840        if let Some(q) = workerState {
841            query.get_or_insert_with(Vec::new).push(("workerState", q));
842        }
843
844        (path, query)
845    }
846
847    /// Get a worker
848    ///
849    /// Get a worker from a worker-type.
850    pub async fn getWorker(&self, provisionerId: &str, workerType: &str, workerGroup: &str, workerId: &str) -> Result<Value, Error> {
851        let method = "GET";
852        let (path, query) = Self::getWorker_details(provisionerId, workerType, workerGroup, workerId);
853        let body = None;
854        let resp = self.client.request(method, &path, query, body).await?;
855        Ok(resp.json().await?)
856    }
857
858    /// Generate an unsigned URL for the getWorker endpoint
859    pub fn getWorker_url(&self, provisionerId: &str, workerType: &str, workerGroup: &str, workerId: &str) -> Result<String, Error> {
860        let (path, query) = Self::getWorker_details(provisionerId, workerType, workerGroup, workerId);
861        self.client.make_url(&path, query)
862    }
863
864    /// Generate a signed URL for the getWorker endpoint
865    pub fn getWorker_signed_url(&self, provisionerId: &str, workerType: &str, workerGroup: &str, workerId: &str, ttl: Duration) -> Result<String, Error> {
866        let (path, query) = Self::getWorker_details(provisionerId, workerType, workerGroup, workerId);
867        self.client.make_signed_url(&path, query, ttl)
868    }
869
870    /// Determine the HTTP request details for getWorker
871    fn getWorker_details<'a>(provisionerId: &'a str, workerType: &'a str, workerGroup: &'a str, workerId: &'a str) -> (String, Option<Vec<(&'static str, &'a str)>>) {
872        let path = format!("provisioners/{}/worker-types/{}/workers/{}/{}", urlencode(provisionerId), urlencode(workerType), urlencode(workerGroup), urlencode(workerId));
873        let query = None;
874
875        (path, query)
876    }
877
878    /// Heartbeat
879    ///
880    /// Respond with a service heartbeat.
881    ///
882    /// This endpoint is used to check on backing services this service
883    /// depends on.
884    pub async fn heartbeat(&self) -> Result<(), Error> {
885        let method = "GET";
886        let (path, query) = Self::heartbeat_details();
887        let body = None;
888        let resp = self.client.request(method, path, query, body).await?;
889        resp.bytes().await?;
890        Ok(())
891    }
892
893    /// Generate an unsigned URL for the heartbeat endpoint
894    pub fn heartbeat_url(&self) -> Result<String, Error> {
895        let (path, query) = Self::heartbeat_details();
896        self.client.make_url(path, query)
897    }
898
899    /// Generate a signed URL for the heartbeat endpoint
900    pub fn heartbeat_signed_url(&self, ttl: Duration) -> Result<String, Error> {
901        let (path, query) = Self::heartbeat_details();
902        self.client.make_signed_url(path, query, ttl)
903    }
904
905    /// Determine the HTTP request details for heartbeat
906    fn heartbeat_details<'a>() -> (&'static str, Option<Vec<(&'static str, &'a str)>>) {
907        let path = "__heartbeat__";
908        let query = None;
909
910        (path, query)
911    }
912}