google_coordinate1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// View and manage your Google Maps Coordinate jobs
17 Full,
18
19 /// View your Google Coordinate jobs
20 Readonly,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::Full => "https://www.googleapis.com/auth/coordinate",
27 Scope::Readonly => "https://www.googleapis.com/auth/coordinate.readonly",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::Readonly
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Coordinate related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_coordinate1 as coordinate1;
53/// use coordinate1::api::Job;
54/// use coordinate1::{Result, Error};
55/// # async fn dox() {
56/// use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67/// secret,
68/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69/// ).build().await.unwrap();
70///
71/// let client = hyper_util::client::legacy::Client::builder(
72/// hyper_util::rt::TokioExecutor::new()
73/// )
74/// .build(
75/// hyper_rustls::HttpsConnectorBuilder::new()
76/// .with_native_roots()
77/// .unwrap()
78/// .https_or_http()
79/// .enable_http1()
80/// .build()
81/// );
82/// let mut hub = Coordinate::new(client, auth);
83/// // As the method needs a request, you would usually fill it with the desired information
84/// // into the respective structure. Some of the parts shown here might not be applicable !
85/// // Values shown here are possibly random and not representative !
86/// let mut req = Job::default();
87///
88/// // You can configure optional parameters by calling the respective setters at will, and
89/// // execute the final call using `doit()`.
90/// // Values shown here are possibly random and not representative !
91/// let result = hub.jobs().patch(req, "teamId", 85)
92/// .title("est")
93/// .progress("ipsum")
94/// .note("ipsum")
95/// .lng(0.8016125465746553)
96/// .lat(0.8000651323113592)
97/// .customer_phone_number("ea")
98/// .customer_name("dolor")
99/// .add_custom_field("Lorem")
100/// .assignee("eos")
101/// .address("labore")
102/// .doit().await;
103///
104/// match result {
105/// Err(e) => match e {
106/// // The Error enum provides details about what exactly happened.
107/// // You can also just use its `Debug`, `Display` or `Error` traits
108/// Error::HttpError(_)
109/// |Error::Io(_)
110/// |Error::MissingAPIKey
111/// |Error::MissingToken(_)
112/// |Error::Cancelled
113/// |Error::UploadSizeLimitExceeded(_, _)
114/// |Error::Failure(_)
115/// |Error::BadRequest(_)
116/// |Error::FieldClash(_)
117/// |Error::JsonDecodeError(_, _) => println!("{}", e),
118/// },
119/// Ok(res) => println!("Success: {:?}", res),
120/// }
121/// # }
122/// ```
123#[derive(Clone)]
124pub struct Coordinate<C> {
125 pub client: common::Client<C>,
126 pub auth: Box<dyn common::GetToken>,
127 _user_agent: String,
128 _base_url: String,
129 _root_url: String,
130}
131
132impl<C> common::Hub for Coordinate<C> {}
133
134impl<'a, C> Coordinate<C> {
135 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Coordinate<C> {
136 Coordinate {
137 client,
138 auth: Box::new(auth),
139 _user_agent: "google-api-rust-client/6.0.0".to_string(),
140 _base_url: "https://www.googleapis.com/coordinate/v1/".to_string(),
141 _root_url: "https://www.googleapis.com/".to_string(),
142 }
143 }
144
145 pub fn custom_field_def(&'a self) -> CustomFieldDefMethods<'a, C> {
146 CustomFieldDefMethods { hub: self }
147 }
148 pub fn jobs(&'a self) -> JobMethods<'a, C> {
149 JobMethods { hub: self }
150 }
151 pub fn location(&'a self) -> LocationMethods<'a, C> {
152 LocationMethods { hub: self }
153 }
154 pub fn schedule(&'a self) -> ScheduleMethods<'a, C> {
155 ScheduleMethods { hub: self }
156 }
157 pub fn team(&'a self) -> TeamMethods<'a, C> {
158 TeamMethods { hub: self }
159 }
160 pub fn worker(&'a self) -> WorkerMethods<'a, C> {
161 WorkerMethods { hub: self }
162 }
163
164 /// Set the user-agent header field to use in all requests to the server.
165 /// It defaults to `google-api-rust-client/6.0.0`.
166 ///
167 /// Returns the previously set user-agent.
168 pub fn user_agent(&mut self, agent_name: String) -> String {
169 std::mem::replace(&mut self._user_agent, agent_name)
170 }
171
172 /// Set the base url to use in all requests to the server.
173 /// It defaults to `https://www.googleapis.com/coordinate/v1/`.
174 ///
175 /// Returns the previously set base url.
176 pub fn base_url(&mut self, new_base_url: String) -> String {
177 std::mem::replace(&mut self._base_url, new_base_url)
178 }
179
180 /// Set the root url to use in all requests to the server.
181 /// It defaults to `https://www.googleapis.com/`.
182 ///
183 /// Returns the previously set root url.
184 pub fn root_url(&mut self, new_root_url: String) -> String {
185 std::mem::replace(&mut self._root_url, new_root_url)
186 }
187}
188
189// ############
190// SCHEMAS ###
191// ##########
192/// Custom field.
193///
194/// This type is not used in any activity, and only used as *part* of another schema.
195///
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct CustomField {
200 /// Custom field id.
201 #[serde(rename = "customFieldId")]
202 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
203 pub custom_field_id: Option<i64>,
204 /// Identifies this object as a custom field.
205 pub kind: Option<String>,
206 /// Custom field value.
207 pub value: Option<String>,
208}
209
210impl common::Part for CustomField {}
211
212/// Custom field definition.
213///
214/// This type is not used in any activity, and only used as *part* of another schema.
215///
216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
217#[serde_with::serde_as]
218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
219pub struct CustomFieldDef {
220 /// Whether the field is enabled.
221 pub enabled: Option<bool>,
222 /// List of enum items for this custom field. Populated only if the field type is enum. Enum fields appear as 'lists' in the Coordinate web and mobile UI.
223 pub enumitems: Option<Vec<EnumItemDef>>,
224 /// Custom field id.
225 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
226 pub id: Option<i64>,
227 /// Identifies this object as a custom field definition.
228 pub kind: Option<String>,
229 /// Custom field name.
230 pub name: Option<String>,
231 /// Whether the field is required for checkout.
232 #[serde(rename = "requiredForCheckout")]
233 pub required_for_checkout: Option<bool>,
234 /// Custom field type.
235 #[serde(rename = "type")]
236 pub type_: Option<String>,
237}
238
239impl common::Part for CustomFieldDef {}
240
241/// Collection of custom field definitions for a team.
242///
243/// # Activities
244///
245/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
246/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
247///
248/// * [list custom field def](CustomFieldDefListCall) (response)
249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
250#[serde_with::serde_as]
251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
252pub struct CustomFieldDefListResponse {
253 /// Collection of custom field definitions in a team.
254 pub items: Option<Vec<CustomFieldDef>>,
255 /// Identifies this object as a collection of custom field definitions in a team.
256 pub kind: Option<String>,
257}
258
259impl common::ResponseResult for CustomFieldDefListResponse {}
260
261/// Collection of custom fields.
262///
263/// This type is not used in any activity, and only used as *part* of another schema.
264///
265#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
266#[serde_with::serde_as]
267#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
268pub struct CustomFields {
269 /// Collection of custom fields.
270 #[serde(rename = "customField")]
271 pub custom_field: Option<Vec<CustomField>>,
272 /// Identifies this object as a collection of custom fields.
273 pub kind: Option<String>,
274}
275
276impl common::Part for CustomFields {}
277
278/// Enum Item definition.
279///
280/// This type is not used in any activity, and only used as *part* of another schema.
281///
282#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
283#[serde_with::serde_as]
284#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
285pub struct EnumItemDef {
286 /// Whether the enum item is active. Jobs may contain inactive enum values; however, setting an enum to an inactive value when creating or updating a job will result in a 500 error.
287 pub active: Option<bool>,
288 /// Identifies this object as an enum item definition.
289 pub kind: Option<String>,
290 /// Custom field value.
291 pub value: Option<String>,
292}
293
294impl common::Part for EnumItemDef {}
295
296/// A job.
297///
298/// # Activities
299///
300/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
301/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
302///
303/// * [get jobs](JobGetCall) (response)
304/// * [insert jobs](JobInsertCall) (request|response)
305/// * [list jobs](JobListCall) (none)
306/// * [patch jobs](JobPatchCall) (request|response)
307/// * [update jobs](JobUpdateCall) (request|response)
308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
309#[serde_with::serde_as]
310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
311pub struct Job {
312 /// Job id.
313 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
314 pub id: Option<u64>,
315 /// List of job changes since it was created. The first change corresponds to the state of the job when it was created.
316 #[serde(rename = "jobChange")]
317 pub job_change: Option<Vec<JobChange>>,
318 /// Identifies this object as a job.
319 pub kind: Option<String>,
320 /// Current job state.
321 pub state: Option<JobState>,
322}
323
324impl common::RequestValue for Job {}
325impl common::Resource for Job {}
326impl common::ResponseResult for Job {}
327
328/// Change to a job. For example assigning the job to a different worker.
329///
330/// This type is not used in any activity, and only used as *part* of another schema.
331///
332#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
333#[serde_with::serde_as]
334#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
335pub struct JobChange {
336 /// Identifies this object as a job change.
337 pub kind: Option<String>,
338 /// Change applied to the job. Only the fields that were changed are set.
339 pub state: Option<JobState>,
340 /// Time at which this change was applied.
341 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
342 pub timestamp: Option<u64>,
343}
344
345impl common::Part for JobChange {}
346
347/// Response from a List Jobs request.
348///
349/// # Activities
350///
351/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
352/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
353///
354/// * [list jobs](JobListCall) (response)
355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
356#[serde_with::serde_as]
357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
358pub struct JobListResponse {
359 /// Jobs in the collection.
360 pub items: Option<Vec<Job>>,
361 /// Identifies this object as a list of jobs.
362 pub kind: Option<String>,
363 /// A token to provide to get the next page of results.
364 #[serde(rename = "nextPageToken")]
365 pub next_page_token: Option<String>,
366}
367
368impl common::ResponseResult for JobListResponse {}
369
370/// Current state of a job.
371///
372/// This type is not used in any activity, and only used as *part* of another schema.
373///
374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
375#[serde_with::serde_as]
376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
377pub struct JobState {
378 /// Email address of the assignee, or the string "DELETED_USER" if the account is no longer available.
379 pub assignee: Option<String>,
380 /// Custom fields.
381 #[serde(rename = "customFields")]
382 pub custom_fields: Option<CustomFields>,
383 /// Customer name.
384 #[serde(rename = "customerName")]
385 pub customer_name: Option<String>,
386 /// Customer phone number.
387 #[serde(rename = "customerPhoneNumber")]
388 pub customer_phone_number: Option<String>,
389 /// Identifies this object as a job state.
390 pub kind: Option<String>,
391 /// Job location.
392 pub location: Option<Location>,
393 /// Note added to the job.
394 pub note: Option<Vec<String>>,
395 /// Job progress.
396 pub progress: Option<String>,
397 /// Job title.
398 pub title: Option<String>,
399}
400
401impl common::Part for JobState {}
402
403/// Location of a job.
404///
405/// This type is not used in any activity, and only used as *part* of another schema.
406///
407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
408#[serde_with::serde_as]
409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
410pub struct Location {
411 /// Address.
412 #[serde(rename = "addressLine")]
413 pub address_line: Option<Vec<String>>,
414 /// Identifies this object as a location.
415 pub kind: Option<String>,
416 /// Latitude.
417 pub lat: Option<f64>,
418 /// Longitude.
419 pub lng: Option<f64>,
420}
421
422impl common::Part for Location {}
423
424/// Response from a List Locations request.
425///
426/// # Activities
427///
428/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
429/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
430///
431/// * [list location](LocationListCall) (response)
432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
433#[serde_with::serde_as]
434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
435pub struct LocationListResponse {
436 /// Locations in the collection.
437 pub items: Option<Vec<LocationRecord>>,
438 /// Identifies this object as a list of locations.
439 pub kind: Option<String>,
440 /// A token to provide to get the next page of results.
441 #[serde(rename = "nextPageToken")]
442 pub next_page_token: Option<String>,
443 /// Pagination information for token pagination.
444 #[serde(rename = "tokenPagination")]
445 pub token_pagination: Option<TokenPagination>,
446}
447
448impl common::ResponseResult for LocationListResponse {}
449
450/// Recorded location of a worker.
451///
452/// This type is not used in any activity, and only used as *part* of another schema.
453///
454#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
455#[serde_with::serde_as]
456#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
457pub struct LocationRecord {
458 /// The collection time in milliseconds since the epoch.
459 #[serde(rename = "collectionTime")]
460 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
461 pub collection_time: Option<i64>,
462 /// The location accuracy in meters. This is the radius of a 95% confidence interval around the location measurement.
463 #[serde(rename = "confidenceRadius")]
464 pub confidence_radius: Option<f64>,
465 /// Identifies this object as a location.
466 pub kind: Option<String>,
467 /// Latitude.
468 pub latitude: Option<f64>,
469 /// Longitude.
470 pub longitude: Option<f64>,
471}
472
473impl common::Part for LocationRecord {}
474
475/// Job schedule.
476///
477/// # Activities
478///
479/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
480/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
481///
482/// * [get schedule](ScheduleGetCall) (response)
483/// * [patch schedule](SchedulePatchCall) (request|response)
484/// * [update schedule](ScheduleUpdateCall) (request|response)
485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
486#[serde_with::serde_as]
487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
488pub struct Schedule {
489 /// Whether the job is scheduled for the whole day. Time of day in start/end times is ignored if this is true.
490 #[serde(rename = "allDay")]
491 pub all_day: Option<bool>,
492 /// Job duration in milliseconds.
493 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
494 pub duration: Option<u64>,
495 /// Scheduled end time in milliseconds since epoch.
496 #[serde(rename = "endTime")]
497 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
498 pub end_time: Option<u64>,
499 /// Identifies this object as a job schedule.
500 pub kind: Option<String>,
501 /// Scheduled start time in milliseconds since epoch.
502 #[serde(rename = "startTime")]
503 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
504 pub start_time: Option<u64>,
505}
506
507impl common::RequestValue for Schedule {}
508impl common::ResponseResult for Schedule {}
509
510/// A Coordinate team.
511///
512/// This type is not used in any activity, and only used as *part* of another schema.
513///
514#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
515#[serde_with::serde_as]
516#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
517pub struct Team {
518 /// Team id, as found in a coordinate team url e.g. https://coordinate.google.com/f/xyz where "xyz" is the team id.
519 pub id: Option<String>,
520 /// Identifies this object as a team.
521 pub kind: Option<String>,
522 /// Team name
523 pub name: Option<String>,
524}
525
526impl common::Part for Team {}
527
528/// Response from a List Teams request.
529///
530/// # Activities
531///
532/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
533/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
534///
535/// * [list team](TeamListCall) (response)
536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
537#[serde_with::serde_as]
538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
539pub struct TeamListResponse {
540 /// Teams in the collection.
541 pub items: Option<Vec<Team>>,
542 /// Identifies this object as a list of teams.
543 pub kind: Option<String>,
544}
545
546impl common::ResponseResult for TeamListResponse {}
547
548/// Pagination information.
549///
550/// This type is not used in any activity, and only used as *part* of another schema.
551///
552#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
553#[serde_with::serde_as]
554#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
555pub struct TokenPagination {
556 /// Identifies this object as pagination information.
557 pub kind: Option<String>,
558 /// A token to provide to get the next page of results.
559 #[serde(rename = "nextPageToken")]
560 pub next_page_token: Option<String>,
561 /// A token to provide to get the previous page of results.
562 #[serde(rename = "previousPageToken")]
563 pub previous_page_token: Option<String>,
564}
565
566impl common::Part for TokenPagination {}
567
568/// A worker in a Coordinate team.
569///
570/// This type is not used in any activity, and only used as *part* of another schema.
571///
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct Worker {
576 /// Worker email address. If a worker has been deleted from your team, the email address will appear as DELETED_USER.
577 pub id: Option<String>,
578 /// Identifies this object as a worker.
579 pub kind: Option<String>,
580}
581
582impl common::Part for Worker {}
583
584/// Response from a List Workers request.
585///
586/// # Activities
587///
588/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
589/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
590///
591/// * [list worker](WorkerListCall) (response)
592#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
593#[serde_with::serde_as]
594#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
595pub struct WorkerListResponse {
596 /// Workers in the collection.
597 pub items: Option<Vec<Worker>>,
598 /// Identifies this object as a list of workers.
599 pub kind: Option<String>,
600}
601
602impl common::ResponseResult for WorkerListResponse {}
603
604// ###################
605// MethodBuilders ###
606// #################
607
608/// A builder providing access to all methods supported on *customFieldDef* resources.
609/// It is not used directly, but through the [`Coordinate`] hub.
610///
611/// # Example
612///
613/// Instantiate a resource builder
614///
615/// ```test_harness,no_run
616/// extern crate hyper;
617/// extern crate hyper_rustls;
618/// extern crate google_coordinate1 as coordinate1;
619///
620/// # async fn dox() {
621/// use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
622///
623/// let secret: yup_oauth2::ApplicationSecret = Default::default();
624/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
625/// secret,
626/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
627/// ).build().await.unwrap();
628///
629/// let client = hyper_util::client::legacy::Client::builder(
630/// hyper_util::rt::TokioExecutor::new()
631/// )
632/// .build(
633/// hyper_rustls::HttpsConnectorBuilder::new()
634/// .with_native_roots()
635/// .unwrap()
636/// .https_or_http()
637/// .enable_http1()
638/// .build()
639/// );
640/// let mut hub = Coordinate::new(client, auth);
641/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
642/// // like `list(...)`
643/// // to build up your call.
644/// let rb = hub.custom_field_def();
645/// # }
646/// ```
647pub struct CustomFieldDefMethods<'a, C>
648where
649 C: 'a,
650{
651 hub: &'a Coordinate<C>,
652}
653
654impl<'a, C> common::MethodsBuilder for CustomFieldDefMethods<'a, C> {}
655
656impl<'a, C> CustomFieldDefMethods<'a, C> {
657 /// Create a builder to help you perform the following task:
658 ///
659 /// Retrieves a list of custom field definitions for a team.
660 ///
661 /// # Arguments
662 ///
663 /// * `teamId` - Team ID
664 pub fn list(&self, team_id: &str) -> CustomFieldDefListCall<'a, C> {
665 CustomFieldDefListCall {
666 hub: self.hub,
667 _team_id: team_id.to_string(),
668 _delegate: Default::default(),
669 _additional_params: Default::default(),
670 _scopes: Default::default(),
671 }
672 }
673}
674
675/// A builder providing access to all methods supported on *job* resources.
676/// It is not used directly, but through the [`Coordinate`] hub.
677///
678/// # Example
679///
680/// Instantiate a resource builder
681///
682/// ```test_harness,no_run
683/// extern crate hyper;
684/// extern crate hyper_rustls;
685/// extern crate google_coordinate1 as coordinate1;
686///
687/// # async fn dox() {
688/// use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
689///
690/// let secret: yup_oauth2::ApplicationSecret = Default::default();
691/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
692/// secret,
693/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
694/// ).build().await.unwrap();
695///
696/// let client = hyper_util::client::legacy::Client::builder(
697/// hyper_util::rt::TokioExecutor::new()
698/// )
699/// .build(
700/// hyper_rustls::HttpsConnectorBuilder::new()
701/// .with_native_roots()
702/// .unwrap()
703/// .https_or_http()
704/// .enable_http1()
705/// .build()
706/// );
707/// let mut hub = Coordinate::new(client, auth);
708/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
709/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
710/// // to build up your call.
711/// let rb = hub.jobs();
712/// # }
713/// ```
714pub struct JobMethods<'a, C>
715where
716 C: 'a,
717{
718 hub: &'a Coordinate<C>,
719}
720
721impl<'a, C> common::MethodsBuilder for JobMethods<'a, C> {}
722
723impl<'a, C> JobMethods<'a, C> {
724 /// Create a builder to help you perform the following task:
725 ///
726 /// Retrieves a job, including all the changes made to the job.
727 ///
728 /// # Arguments
729 ///
730 /// * `teamId` - Team ID
731 /// * `jobId` - Job number
732 pub fn get(&self, team_id: &str, job_id: u64) -> JobGetCall<'a, C> {
733 JobGetCall {
734 hub: self.hub,
735 _team_id: team_id.to_string(),
736 _job_id: job_id,
737 _delegate: Default::default(),
738 _additional_params: Default::default(),
739 _scopes: Default::default(),
740 }
741 }
742
743 /// Create a builder to help you perform the following task:
744 ///
745 /// Inserts a new job. Only the state field of the job should be set.
746 ///
747 /// # Arguments
748 ///
749 /// * `request` - No description provided.
750 /// * `teamId` - Team ID
751 /// * `address` - Job address as newline (Unix) separated string
752 /// * `lat` - The latitude coordinate of this job's location.
753 /// * `lng` - The longitude coordinate of this job's location.
754 /// * `title` - Job title
755 pub fn insert(
756 &self,
757 request: Job,
758 team_id: &str,
759 address: &str,
760 lat: f64,
761 lng: f64,
762 title: &str,
763 ) -> JobInsertCall<'a, C> {
764 JobInsertCall {
765 hub: self.hub,
766 _request: request,
767 _team_id: team_id.to_string(),
768 _address: address.to_string(),
769 _lat: lat,
770 _lng: lng,
771 _title: title.to_string(),
772 _note: Default::default(),
773 _customer_phone_number: Default::default(),
774 _customer_name: Default::default(),
775 _custom_field: Default::default(),
776 _assignee: Default::default(),
777 _delegate: Default::default(),
778 _additional_params: Default::default(),
779 _scopes: Default::default(),
780 }
781 }
782
783 /// Create a builder to help you perform the following task:
784 ///
785 /// Retrieves jobs created or modified since the given timestamp.
786 ///
787 /// # Arguments
788 ///
789 /// * `teamId` - Team ID
790 pub fn list(&self, team_id: &str) -> JobListCall<'a, C> {
791 JobListCall {
792 hub: self.hub,
793 _team_id: team_id.to_string(),
794 _page_token: Default::default(),
795 _omit_job_changes: Default::default(),
796 _min_modified_timestamp_ms: Default::default(),
797 _max_results: Default::default(),
798 _delegate: Default::default(),
799 _additional_params: Default::default(),
800 _scopes: Default::default(),
801 }
802 }
803
804 /// Create a builder to help you perform the following task:
805 ///
806 /// Updates a job. Fields that are set in the job state will be updated. This method supports patch semantics.
807 ///
808 /// # Arguments
809 ///
810 /// * `request` - No description provided.
811 /// * `teamId` - Team ID
812 /// * `jobId` - Job number
813 pub fn patch(&self, request: Job, team_id: &str, job_id: u64) -> JobPatchCall<'a, C> {
814 JobPatchCall {
815 hub: self.hub,
816 _request: request,
817 _team_id: team_id.to_string(),
818 _job_id: job_id,
819 _title: Default::default(),
820 _progress: Default::default(),
821 _note: Default::default(),
822 _lng: Default::default(),
823 _lat: Default::default(),
824 _customer_phone_number: Default::default(),
825 _customer_name: Default::default(),
826 _custom_field: Default::default(),
827 _assignee: Default::default(),
828 _address: Default::default(),
829 _delegate: Default::default(),
830 _additional_params: Default::default(),
831 _scopes: Default::default(),
832 }
833 }
834
835 /// Create a builder to help you perform the following task:
836 ///
837 /// Updates a job. Fields that are set in the job state will be updated.
838 ///
839 /// # Arguments
840 ///
841 /// * `request` - No description provided.
842 /// * `teamId` - Team ID
843 /// * `jobId` - Job number
844 pub fn update(&self, request: Job, team_id: &str, job_id: u64) -> JobUpdateCall<'a, C> {
845 JobUpdateCall {
846 hub: self.hub,
847 _request: request,
848 _team_id: team_id.to_string(),
849 _job_id: job_id,
850 _title: Default::default(),
851 _progress: Default::default(),
852 _note: Default::default(),
853 _lng: Default::default(),
854 _lat: Default::default(),
855 _customer_phone_number: Default::default(),
856 _customer_name: Default::default(),
857 _custom_field: Default::default(),
858 _assignee: Default::default(),
859 _address: Default::default(),
860 _delegate: Default::default(),
861 _additional_params: Default::default(),
862 _scopes: Default::default(),
863 }
864 }
865}
866
867/// A builder providing access to all methods supported on *location* resources.
868/// It is not used directly, but through the [`Coordinate`] hub.
869///
870/// # Example
871///
872/// Instantiate a resource builder
873///
874/// ```test_harness,no_run
875/// extern crate hyper;
876/// extern crate hyper_rustls;
877/// extern crate google_coordinate1 as coordinate1;
878///
879/// # async fn dox() {
880/// use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
881///
882/// let secret: yup_oauth2::ApplicationSecret = Default::default();
883/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
884/// secret,
885/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
886/// ).build().await.unwrap();
887///
888/// let client = hyper_util::client::legacy::Client::builder(
889/// hyper_util::rt::TokioExecutor::new()
890/// )
891/// .build(
892/// hyper_rustls::HttpsConnectorBuilder::new()
893/// .with_native_roots()
894/// .unwrap()
895/// .https_or_http()
896/// .enable_http1()
897/// .build()
898/// );
899/// let mut hub = Coordinate::new(client, auth);
900/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
901/// // like `list(...)`
902/// // to build up your call.
903/// let rb = hub.location();
904/// # }
905/// ```
906pub struct LocationMethods<'a, C>
907where
908 C: 'a,
909{
910 hub: &'a Coordinate<C>,
911}
912
913impl<'a, C> common::MethodsBuilder for LocationMethods<'a, C> {}
914
915impl<'a, C> LocationMethods<'a, C> {
916 /// Create a builder to help you perform the following task:
917 ///
918 /// Retrieves a list of locations for a worker.
919 ///
920 /// # Arguments
921 ///
922 /// * `teamId` - Team ID
923 /// * `workerEmail` - Worker email address.
924 /// * `startTimestampMs` - Start timestamp in milliseconds since the epoch.
925 pub fn list(
926 &self,
927 team_id: &str,
928 worker_email: &str,
929 start_timestamp_ms: u64,
930 ) -> LocationListCall<'a, C> {
931 LocationListCall {
932 hub: self.hub,
933 _team_id: team_id.to_string(),
934 _worker_email: worker_email.to_string(),
935 _start_timestamp_ms: start_timestamp_ms,
936 _page_token: Default::default(),
937 _max_results: Default::default(),
938 _delegate: Default::default(),
939 _additional_params: Default::default(),
940 _scopes: Default::default(),
941 }
942 }
943}
944
945/// A builder providing access to all methods supported on *schedule* resources.
946/// It is not used directly, but through the [`Coordinate`] hub.
947///
948/// # Example
949///
950/// Instantiate a resource builder
951///
952/// ```test_harness,no_run
953/// extern crate hyper;
954/// extern crate hyper_rustls;
955/// extern crate google_coordinate1 as coordinate1;
956///
957/// # async fn dox() {
958/// use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
959///
960/// let secret: yup_oauth2::ApplicationSecret = Default::default();
961/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
962/// secret,
963/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
964/// ).build().await.unwrap();
965///
966/// let client = hyper_util::client::legacy::Client::builder(
967/// hyper_util::rt::TokioExecutor::new()
968/// )
969/// .build(
970/// hyper_rustls::HttpsConnectorBuilder::new()
971/// .with_native_roots()
972/// .unwrap()
973/// .https_or_http()
974/// .enable_http1()
975/// .build()
976/// );
977/// let mut hub = Coordinate::new(client, auth);
978/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
979/// // like `get(...)`, `patch(...)` and `update(...)`
980/// // to build up your call.
981/// let rb = hub.schedule();
982/// # }
983/// ```
984pub struct ScheduleMethods<'a, C>
985where
986 C: 'a,
987{
988 hub: &'a Coordinate<C>,
989}
990
991impl<'a, C> common::MethodsBuilder for ScheduleMethods<'a, C> {}
992
993impl<'a, C> ScheduleMethods<'a, C> {
994 /// Create a builder to help you perform the following task:
995 ///
996 /// Retrieves the schedule for a job.
997 ///
998 /// # Arguments
999 ///
1000 /// * `teamId` - Team ID
1001 /// * `jobId` - Job number
1002 pub fn get(&self, team_id: &str, job_id: u64) -> ScheduleGetCall<'a, C> {
1003 ScheduleGetCall {
1004 hub: self.hub,
1005 _team_id: team_id.to_string(),
1006 _job_id: job_id,
1007 _delegate: Default::default(),
1008 _additional_params: Default::default(),
1009 _scopes: Default::default(),
1010 }
1011 }
1012
1013 /// Create a builder to help you perform the following task:
1014 ///
1015 /// Replaces the schedule of a job with the provided schedule. This method supports patch semantics.
1016 ///
1017 /// # Arguments
1018 ///
1019 /// * `request` - No description provided.
1020 /// * `teamId` - Team ID
1021 /// * `jobId` - Job number
1022 pub fn patch(&self, request: Schedule, team_id: &str, job_id: u64) -> SchedulePatchCall<'a, C> {
1023 SchedulePatchCall {
1024 hub: self.hub,
1025 _request: request,
1026 _team_id: team_id.to_string(),
1027 _job_id: job_id,
1028 _start_time: Default::default(),
1029 _end_time: Default::default(),
1030 _duration: Default::default(),
1031 _all_day: Default::default(),
1032 _delegate: Default::default(),
1033 _additional_params: Default::default(),
1034 _scopes: Default::default(),
1035 }
1036 }
1037
1038 /// Create a builder to help you perform the following task:
1039 ///
1040 /// Replaces the schedule of a job with the provided schedule.
1041 ///
1042 /// # Arguments
1043 ///
1044 /// * `request` - No description provided.
1045 /// * `teamId` - Team ID
1046 /// * `jobId` - Job number
1047 pub fn update(
1048 &self,
1049 request: Schedule,
1050 team_id: &str,
1051 job_id: u64,
1052 ) -> ScheduleUpdateCall<'a, C> {
1053 ScheduleUpdateCall {
1054 hub: self.hub,
1055 _request: request,
1056 _team_id: team_id.to_string(),
1057 _job_id: job_id,
1058 _start_time: Default::default(),
1059 _end_time: Default::default(),
1060 _duration: Default::default(),
1061 _all_day: Default::default(),
1062 _delegate: Default::default(),
1063 _additional_params: Default::default(),
1064 _scopes: Default::default(),
1065 }
1066 }
1067}
1068
1069/// A builder providing access to all methods supported on *team* resources.
1070/// It is not used directly, but through the [`Coordinate`] hub.
1071///
1072/// # Example
1073///
1074/// Instantiate a resource builder
1075///
1076/// ```test_harness,no_run
1077/// extern crate hyper;
1078/// extern crate hyper_rustls;
1079/// extern crate google_coordinate1 as coordinate1;
1080///
1081/// # async fn dox() {
1082/// use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1083///
1084/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1085/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1086/// secret,
1087/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1088/// ).build().await.unwrap();
1089///
1090/// let client = hyper_util::client::legacy::Client::builder(
1091/// hyper_util::rt::TokioExecutor::new()
1092/// )
1093/// .build(
1094/// hyper_rustls::HttpsConnectorBuilder::new()
1095/// .with_native_roots()
1096/// .unwrap()
1097/// .https_or_http()
1098/// .enable_http1()
1099/// .build()
1100/// );
1101/// let mut hub = Coordinate::new(client, auth);
1102/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1103/// // like `list(...)`
1104/// // to build up your call.
1105/// let rb = hub.team();
1106/// # }
1107/// ```
1108pub struct TeamMethods<'a, C>
1109where
1110 C: 'a,
1111{
1112 hub: &'a Coordinate<C>,
1113}
1114
1115impl<'a, C> common::MethodsBuilder for TeamMethods<'a, C> {}
1116
1117impl<'a, C> TeamMethods<'a, C> {
1118 /// Create a builder to help you perform the following task:
1119 ///
1120 /// Retrieves a list of teams for a user.
1121 pub fn list(&self) -> TeamListCall<'a, C> {
1122 TeamListCall {
1123 hub: self.hub,
1124 _worker: Default::default(),
1125 _dispatcher: Default::default(),
1126 _admin: Default::default(),
1127 _delegate: Default::default(),
1128 _additional_params: Default::default(),
1129 _scopes: Default::default(),
1130 }
1131 }
1132}
1133
1134/// A builder providing access to all methods supported on *worker* resources.
1135/// It is not used directly, but through the [`Coordinate`] hub.
1136///
1137/// # Example
1138///
1139/// Instantiate a resource builder
1140///
1141/// ```test_harness,no_run
1142/// extern crate hyper;
1143/// extern crate hyper_rustls;
1144/// extern crate google_coordinate1 as coordinate1;
1145///
1146/// # async fn dox() {
1147/// use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1148///
1149/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1150/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1151/// secret,
1152/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1153/// ).build().await.unwrap();
1154///
1155/// let client = hyper_util::client::legacy::Client::builder(
1156/// hyper_util::rt::TokioExecutor::new()
1157/// )
1158/// .build(
1159/// hyper_rustls::HttpsConnectorBuilder::new()
1160/// .with_native_roots()
1161/// .unwrap()
1162/// .https_or_http()
1163/// .enable_http1()
1164/// .build()
1165/// );
1166/// let mut hub = Coordinate::new(client, auth);
1167/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1168/// // like `list(...)`
1169/// // to build up your call.
1170/// let rb = hub.worker();
1171/// # }
1172/// ```
1173pub struct WorkerMethods<'a, C>
1174where
1175 C: 'a,
1176{
1177 hub: &'a Coordinate<C>,
1178}
1179
1180impl<'a, C> common::MethodsBuilder for WorkerMethods<'a, C> {}
1181
1182impl<'a, C> WorkerMethods<'a, C> {
1183 /// Create a builder to help you perform the following task:
1184 ///
1185 /// Retrieves a list of workers in a team.
1186 ///
1187 /// # Arguments
1188 ///
1189 /// * `teamId` - Team ID
1190 pub fn list(&self, team_id: &str) -> WorkerListCall<'a, C> {
1191 WorkerListCall {
1192 hub: self.hub,
1193 _team_id: team_id.to_string(),
1194 _delegate: Default::default(),
1195 _additional_params: Default::default(),
1196 _scopes: Default::default(),
1197 }
1198 }
1199}
1200
1201// ###################
1202// CallBuilders ###
1203// #################
1204
1205/// Retrieves a list of custom field definitions for a team.
1206///
1207/// A builder for the *list* method supported by a *customFieldDef* resource.
1208/// It is not used directly, but through a [`CustomFieldDefMethods`] instance.
1209///
1210/// # Example
1211///
1212/// Instantiate a resource method builder
1213///
1214/// ```test_harness,no_run
1215/// # extern crate hyper;
1216/// # extern crate hyper_rustls;
1217/// # extern crate google_coordinate1 as coordinate1;
1218/// # async fn dox() {
1219/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1220///
1221/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1222/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1223/// # secret,
1224/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1225/// # ).build().await.unwrap();
1226///
1227/// # let client = hyper_util::client::legacy::Client::builder(
1228/// # hyper_util::rt::TokioExecutor::new()
1229/// # )
1230/// # .build(
1231/// # hyper_rustls::HttpsConnectorBuilder::new()
1232/// # .with_native_roots()
1233/// # .unwrap()
1234/// # .https_or_http()
1235/// # .enable_http1()
1236/// # .build()
1237/// # );
1238/// # let mut hub = Coordinate::new(client, auth);
1239/// // You can configure optional parameters by calling the respective setters at will, and
1240/// // execute the final call using `doit()`.
1241/// // Values shown here are possibly random and not representative !
1242/// let result = hub.custom_field_def().list("teamId")
1243/// .doit().await;
1244/// # }
1245/// ```
1246pub struct CustomFieldDefListCall<'a, C>
1247where
1248 C: 'a,
1249{
1250 hub: &'a Coordinate<C>,
1251 _team_id: String,
1252 _delegate: Option<&'a mut dyn common::Delegate>,
1253 _additional_params: HashMap<String, String>,
1254 _scopes: BTreeSet<String>,
1255}
1256
1257impl<'a, C> common::CallBuilder for CustomFieldDefListCall<'a, C> {}
1258
1259impl<'a, C> CustomFieldDefListCall<'a, C>
1260where
1261 C: common::Connector,
1262{
1263 /// Perform the operation you have build so far.
1264 pub async fn doit(mut self) -> common::Result<(common::Response, CustomFieldDefListResponse)> {
1265 use std::borrow::Cow;
1266 use std::io::{Read, Seek};
1267
1268 use common::{url::Params, ToParts};
1269 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1270
1271 let mut dd = common::DefaultDelegate;
1272 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1273 dlg.begin(common::MethodInfo {
1274 id: "coordinate.customFieldDef.list",
1275 http_method: hyper::Method::GET,
1276 });
1277
1278 for &field in ["alt", "teamId"].iter() {
1279 if self._additional_params.contains_key(field) {
1280 dlg.finished(false);
1281 return Err(common::Error::FieldClash(field));
1282 }
1283 }
1284
1285 let mut params = Params::with_capacity(3 + self._additional_params.len());
1286 params.push("teamId", self._team_id);
1287
1288 params.extend(self._additional_params.iter());
1289
1290 params.push("alt", "json");
1291 let mut url = self.hub._base_url.clone() + "teams/{teamId}/custom_fields";
1292 if self._scopes.is_empty() {
1293 self._scopes.insert(Scope::Readonly.as_ref().to_string());
1294 }
1295
1296 #[allow(clippy::single_element_loop)]
1297 for &(find_this, param_name) in [("{teamId}", "teamId")].iter() {
1298 url = params.uri_replacement(url, param_name, find_this, false);
1299 }
1300 {
1301 let to_remove = ["teamId"];
1302 params.remove_params(&to_remove);
1303 }
1304
1305 let url = params.parse_with_url(&url);
1306
1307 loop {
1308 let token = match self
1309 .hub
1310 .auth
1311 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1312 .await
1313 {
1314 Ok(token) => token,
1315 Err(e) => match dlg.token(e) {
1316 Ok(token) => token,
1317 Err(e) => {
1318 dlg.finished(false);
1319 return Err(common::Error::MissingToken(e));
1320 }
1321 },
1322 };
1323 let mut req_result = {
1324 let client = &self.hub.client;
1325 dlg.pre_request();
1326 let mut req_builder = hyper::Request::builder()
1327 .method(hyper::Method::GET)
1328 .uri(url.as_str())
1329 .header(USER_AGENT, self.hub._user_agent.clone());
1330
1331 if let Some(token) = token.as_ref() {
1332 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1333 }
1334
1335 let request = req_builder
1336 .header(CONTENT_LENGTH, 0_u64)
1337 .body(common::to_body::<String>(None));
1338
1339 client.request(request.unwrap()).await
1340 };
1341
1342 match req_result {
1343 Err(err) => {
1344 if let common::Retry::After(d) = dlg.http_error(&err) {
1345 sleep(d).await;
1346 continue;
1347 }
1348 dlg.finished(false);
1349 return Err(common::Error::HttpError(err));
1350 }
1351 Ok(res) => {
1352 let (mut parts, body) = res.into_parts();
1353 let mut body = common::Body::new(body);
1354 if !parts.status.is_success() {
1355 let bytes = common::to_bytes(body).await.unwrap_or_default();
1356 let error = serde_json::from_str(&common::to_string(&bytes));
1357 let response = common::to_response(parts, bytes.into());
1358
1359 if let common::Retry::After(d) =
1360 dlg.http_failure(&response, error.as_ref().ok())
1361 {
1362 sleep(d).await;
1363 continue;
1364 }
1365
1366 dlg.finished(false);
1367
1368 return Err(match error {
1369 Ok(value) => common::Error::BadRequest(value),
1370 _ => common::Error::Failure(response),
1371 });
1372 }
1373 let response = {
1374 let bytes = common::to_bytes(body).await.unwrap_or_default();
1375 let encoded = common::to_string(&bytes);
1376 match serde_json::from_str(&encoded) {
1377 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1378 Err(error) => {
1379 dlg.response_json_decode_error(&encoded, &error);
1380 return Err(common::Error::JsonDecodeError(
1381 encoded.to_string(),
1382 error,
1383 ));
1384 }
1385 }
1386 };
1387
1388 dlg.finished(true);
1389 return Ok(response);
1390 }
1391 }
1392 }
1393 }
1394
1395 /// Team ID
1396 ///
1397 /// Sets the *team id* path property to the given value.
1398 ///
1399 /// Even though the property as already been set when instantiating this call,
1400 /// we provide this method for API completeness.
1401 pub fn team_id(mut self, new_value: &str) -> CustomFieldDefListCall<'a, C> {
1402 self._team_id = new_value.to_string();
1403 self
1404 }
1405 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1406 /// while executing the actual API request.
1407 ///
1408 /// ````text
1409 /// It should be used to handle progress information, and to implement a certain level of resilience.
1410 /// ````
1411 ///
1412 /// Sets the *delegate* property to the given value.
1413 pub fn delegate(
1414 mut self,
1415 new_value: &'a mut dyn common::Delegate,
1416 ) -> CustomFieldDefListCall<'a, C> {
1417 self._delegate = Some(new_value);
1418 self
1419 }
1420
1421 /// Set any additional parameter of the query string used in the request.
1422 /// It should be used to set parameters which are not yet available through their own
1423 /// setters.
1424 ///
1425 /// Please note that this method must not be used to set any of the known parameters
1426 /// which have their own setter method. If done anyway, the request will fail.
1427 ///
1428 /// # Additional Parameters
1429 ///
1430 /// * *alt* (query-string) - Data format for the response.
1431 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1432 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1433 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1434 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1435 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1436 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1437 pub fn param<T>(mut self, name: T, value: T) -> CustomFieldDefListCall<'a, C>
1438 where
1439 T: AsRef<str>,
1440 {
1441 self._additional_params
1442 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1443 self
1444 }
1445
1446 /// Identifies the authorization scope for the method you are building.
1447 ///
1448 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1449 /// [`Scope::Readonly`].
1450 ///
1451 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1452 /// tokens for more than one scope.
1453 ///
1454 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1455 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1456 /// sufficient, a read-write scope will do as well.
1457 pub fn add_scope<St>(mut self, scope: St) -> CustomFieldDefListCall<'a, C>
1458 where
1459 St: AsRef<str>,
1460 {
1461 self._scopes.insert(String::from(scope.as_ref()));
1462 self
1463 }
1464 /// Identifies the authorization scope(s) for the method you are building.
1465 ///
1466 /// See [`Self::add_scope()`] for details.
1467 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomFieldDefListCall<'a, C>
1468 where
1469 I: IntoIterator<Item = St>,
1470 St: AsRef<str>,
1471 {
1472 self._scopes
1473 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1474 self
1475 }
1476
1477 /// Removes all scopes, and no default scope will be used either.
1478 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1479 /// for details).
1480 pub fn clear_scopes(mut self) -> CustomFieldDefListCall<'a, C> {
1481 self._scopes.clear();
1482 self
1483 }
1484}
1485
1486/// Retrieves a job, including all the changes made to the job.
1487///
1488/// A builder for the *get* method supported by a *job* resource.
1489/// It is not used directly, but through a [`JobMethods`] instance.
1490///
1491/// # Example
1492///
1493/// Instantiate a resource method builder
1494///
1495/// ```test_harness,no_run
1496/// # extern crate hyper;
1497/// # extern crate hyper_rustls;
1498/// # extern crate google_coordinate1 as coordinate1;
1499/// # async fn dox() {
1500/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1501///
1502/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1503/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1504/// # secret,
1505/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1506/// # ).build().await.unwrap();
1507///
1508/// # let client = hyper_util::client::legacy::Client::builder(
1509/// # hyper_util::rt::TokioExecutor::new()
1510/// # )
1511/// # .build(
1512/// # hyper_rustls::HttpsConnectorBuilder::new()
1513/// # .with_native_roots()
1514/// # .unwrap()
1515/// # .https_or_http()
1516/// # .enable_http1()
1517/// # .build()
1518/// # );
1519/// # let mut hub = Coordinate::new(client, auth);
1520/// // You can configure optional parameters by calling the respective setters at will, and
1521/// // execute the final call using `doit()`.
1522/// // Values shown here are possibly random and not representative !
1523/// let result = hub.jobs().get("teamId", 21)
1524/// .doit().await;
1525/// # }
1526/// ```
1527pub struct JobGetCall<'a, C>
1528where
1529 C: 'a,
1530{
1531 hub: &'a Coordinate<C>,
1532 _team_id: String,
1533 _job_id: u64,
1534 _delegate: Option<&'a mut dyn common::Delegate>,
1535 _additional_params: HashMap<String, String>,
1536 _scopes: BTreeSet<String>,
1537}
1538
1539impl<'a, C> common::CallBuilder for JobGetCall<'a, C> {}
1540
1541impl<'a, C> JobGetCall<'a, C>
1542where
1543 C: common::Connector,
1544{
1545 /// Perform the operation you have build so far.
1546 pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
1547 use std::borrow::Cow;
1548 use std::io::{Read, Seek};
1549
1550 use common::{url::Params, ToParts};
1551 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1552
1553 let mut dd = common::DefaultDelegate;
1554 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1555 dlg.begin(common::MethodInfo {
1556 id: "coordinate.jobs.get",
1557 http_method: hyper::Method::GET,
1558 });
1559
1560 for &field in ["alt", "teamId", "jobId"].iter() {
1561 if self._additional_params.contains_key(field) {
1562 dlg.finished(false);
1563 return Err(common::Error::FieldClash(field));
1564 }
1565 }
1566
1567 let mut params = Params::with_capacity(4 + self._additional_params.len());
1568 params.push("teamId", self._team_id);
1569 params.push("jobId", self._job_id.to_string());
1570
1571 params.extend(self._additional_params.iter());
1572
1573 params.push("alt", "json");
1574 let mut url = self.hub._base_url.clone() + "teams/{teamId}/jobs/{jobId}";
1575 if self._scopes.is_empty() {
1576 self._scopes.insert(Scope::Readonly.as_ref().to_string());
1577 }
1578
1579 #[allow(clippy::single_element_loop)]
1580 for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].iter() {
1581 url = params.uri_replacement(url, param_name, find_this, false);
1582 }
1583 {
1584 let to_remove = ["jobId", "teamId"];
1585 params.remove_params(&to_remove);
1586 }
1587
1588 let url = params.parse_with_url(&url);
1589
1590 loop {
1591 let token = match self
1592 .hub
1593 .auth
1594 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1595 .await
1596 {
1597 Ok(token) => token,
1598 Err(e) => match dlg.token(e) {
1599 Ok(token) => token,
1600 Err(e) => {
1601 dlg.finished(false);
1602 return Err(common::Error::MissingToken(e));
1603 }
1604 },
1605 };
1606 let mut req_result = {
1607 let client = &self.hub.client;
1608 dlg.pre_request();
1609 let mut req_builder = hyper::Request::builder()
1610 .method(hyper::Method::GET)
1611 .uri(url.as_str())
1612 .header(USER_AGENT, self.hub._user_agent.clone());
1613
1614 if let Some(token) = token.as_ref() {
1615 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1616 }
1617
1618 let request = req_builder
1619 .header(CONTENT_LENGTH, 0_u64)
1620 .body(common::to_body::<String>(None));
1621
1622 client.request(request.unwrap()).await
1623 };
1624
1625 match req_result {
1626 Err(err) => {
1627 if let common::Retry::After(d) = dlg.http_error(&err) {
1628 sleep(d).await;
1629 continue;
1630 }
1631 dlg.finished(false);
1632 return Err(common::Error::HttpError(err));
1633 }
1634 Ok(res) => {
1635 let (mut parts, body) = res.into_parts();
1636 let mut body = common::Body::new(body);
1637 if !parts.status.is_success() {
1638 let bytes = common::to_bytes(body).await.unwrap_or_default();
1639 let error = serde_json::from_str(&common::to_string(&bytes));
1640 let response = common::to_response(parts, bytes.into());
1641
1642 if let common::Retry::After(d) =
1643 dlg.http_failure(&response, error.as_ref().ok())
1644 {
1645 sleep(d).await;
1646 continue;
1647 }
1648
1649 dlg.finished(false);
1650
1651 return Err(match error {
1652 Ok(value) => common::Error::BadRequest(value),
1653 _ => common::Error::Failure(response),
1654 });
1655 }
1656 let response = {
1657 let bytes = common::to_bytes(body).await.unwrap_or_default();
1658 let encoded = common::to_string(&bytes);
1659 match serde_json::from_str(&encoded) {
1660 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1661 Err(error) => {
1662 dlg.response_json_decode_error(&encoded, &error);
1663 return Err(common::Error::JsonDecodeError(
1664 encoded.to_string(),
1665 error,
1666 ));
1667 }
1668 }
1669 };
1670
1671 dlg.finished(true);
1672 return Ok(response);
1673 }
1674 }
1675 }
1676 }
1677
1678 /// Team ID
1679 ///
1680 /// Sets the *team id* path property to the given value.
1681 ///
1682 /// Even though the property as already been set when instantiating this call,
1683 /// we provide this method for API completeness.
1684 pub fn team_id(mut self, new_value: &str) -> JobGetCall<'a, C> {
1685 self._team_id = new_value.to_string();
1686 self
1687 }
1688 /// Job number
1689 ///
1690 /// Sets the *job id* path property to the given value.
1691 ///
1692 /// Even though the property as already been set when instantiating this call,
1693 /// we provide this method for API completeness.
1694 pub fn job_id(mut self, new_value: u64) -> JobGetCall<'a, C> {
1695 self._job_id = new_value;
1696 self
1697 }
1698 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1699 /// while executing the actual API request.
1700 ///
1701 /// ````text
1702 /// It should be used to handle progress information, and to implement a certain level of resilience.
1703 /// ````
1704 ///
1705 /// Sets the *delegate* property to the given value.
1706 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> JobGetCall<'a, C> {
1707 self._delegate = Some(new_value);
1708 self
1709 }
1710
1711 /// Set any additional parameter of the query string used in the request.
1712 /// It should be used to set parameters which are not yet available through their own
1713 /// setters.
1714 ///
1715 /// Please note that this method must not be used to set any of the known parameters
1716 /// which have their own setter method. If done anyway, the request will fail.
1717 ///
1718 /// # Additional Parameters
1719 ///
1720 /// * *alt* (query-string) - Data format for the response.
1721 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1722 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1723 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1724 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1725 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1726 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1727 pub fn param<T>(mut self, name: T, value: T) -> JobGetCall<'a, C>
1728 where
1729 T: AsRef<str>,
1730 {
1731 self._additional_params
1732 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1733 self
1734 }
1735
1736 /// Identifies the authorization scope for the method you are building.
1737 ///
1738 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1739 /// [`Scope::Readonly`].
1740 ///
1741 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1742 /// tokens for more than one scope.
1743 ///
1744 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1745 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1746 /// sufficient, a read-write scope will do as well.
1747 pub fn add_scope<St>(mut self, scope: St) -> JobGetCall<'a, C>
1748 where
1749 St: AsRef<str>,
1750 {
1751 self._scopes.insert(String::from(scope.as_ref()));
1752 self
1753 }
1754 /// Identifies the authorization scope(s) for the method you are building.
1755 ///
1756 /// See [`Self::add_scope()`] for details.
1757 pub fn add_scopes<I, St>(mut self, scopes: I) -> JobGetCall<'a, C>
1758 where
1759 I: IntoIterator<Item = St>,
1760 St: AsRef<str>,
1761 {
1762 self._scopes
1763 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1764 self
1765 }
1766
1767 /// Removes all scopes, and no default scope will be used either.
1768 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1769 /// for details).
1770 pub fn clear_scopes(mut self) -> JobGetCall<'a, C> {
1771 self._scopes.clear();
1772 self
1773 }
1774}
1775
1776/// Inserts a new job. Only the state field of the job should be set.
1777///
1778/// A builder for the *insert* method supported by a *job* resource.
1779/// It is not used directly, but through a [`JobMethods`] instance.
1780///
1781/// # Example
1782///
1783/// Instantiate a resource method builder
1784///
1785/// ```test_harness,no_run
1786/// # extern crate hyper;
1787/// # extern crate hyper_rustls;
1788/// # extern crate google_coordinate1 as coordinate1;
1789/// use coordinate1::api::Job;
1790/// # async fn dox() {
1791/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1792///
1793/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1794/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1795/// # secret,
1796/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1797/// # ).build().await.unwrap();
1798///
1799/// # let client = hyper_util::client::legacy::Client::builder(
1800/// # hyper_util::rt::TokioExecutor::new()
1801/// # )
1802/// # .build(
1803/// # hyper_rustls::HttpsConnectorBuilder::new()
1804/// # .with_native_roots()
1805/// # .unwrap()
1806/// # .https_or_http()
1807/// # .enable_http1()
1808/// # .build()
1809/// # );
1810/// # let mut hub = Coordinate::new(client, auth);
1811/// // As the method needs a request, you would usually fill it with the desired information
1812/// // into the respective structure. Some of the parts shown here might not be applicable !
1813/// // Values shown here are possibly random and not representative !
1814/// let mut req = Job::default();
1815///
1816/// // You can configure optional parameters by calling the respective setters at will, and
1817/// // execute the final call using `doit()`.
1818/// // Values shown here are possibly random and not representative !
1819/// let result = hub.jobs().insert(req, "teamId", "address", 0.6905413711203235, 0.9150999978526841, "title")
1820/// .note("et")
1821/// .customer_phone_number("et")
1822/// .customer_name("vero")
1823/// .add_custom_field("erat")
1824/// .assignee("sed")
1825/// .doit().await;
1826/// # }
1827/// ```
1828pub struct JobInsertCall<'a, C>
1829where
1830 C: 'a,
1831{
1832 hub: &'a Coordinate<C>,
1833 _request: Job,
1834 _team_id: String,
1835 _address: String,
1836 _lat: f64,
1837 _lng: f64,
1838 _title: String,
1839 _note: Option<String>,
1840 _customer_phone_number: Option<String>,
1841 _customer_name: Option<String>,
1842 _custom_field: Vec<String>,
1843 _assignee: Option<String>,
1844 _delegate: Option<&'a mut dyn common::Delegate>,
1845 _additional_params: HashMap<String, String>,
1846 _scopes: BTreeSet<String>,
1847}
1848
1849impl<'a, C> common::CallBuilder for JobInsertCall<'a, C> {}
1850
1851impl<'a, C> JobInsertCall<'a, C>
1852where
1853 C: common::Connector,
1854{
1855 /// Perform the operation you have build so far.
1856 pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
1857 use std::borrow::Cow;
1858 use std::io::{Read, Seek};
1859
1860 use common::{url::Params, ToParts};
1861 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1862
1863 let mut dd = common::DefaultDelegate;
1864 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1865 dlg.begin(common::MethodInfo {
1866 id: "coordinate.jobs.insert",
1867 http_method: hyper::Method::POST,
1868 });
1869
1870 for &field in [
1871 "alt",
1872 "teamId",
1873 "address",
1874 "lat",
1875 "lng",
1876 "title",
1877 "note",
1878 "customerPhoneNumber",
1879 "customerName",
1880 "customField",
1881 "assignee",
1882 ]
1883 .iter()
1884 {
1885 if self._additional_params.contains_key(field) {
1886 dlg.finished(false);
1887 return Err(common::Error::FieldClash(field));
1888 }
1889 }
1890
1891 let mut params = Params::with_capacity(13 + self._additional_params.len());
1892 params.push("teamId", self._team_id);
1893 params.push("address", self._address);
1894 params.push("lat", self._lat.to_string());
1895 params.push("lng", self._lng.to_string());
1896 params.push("title", self._title);
1897 if let Some(value) = self._note.as_ref() {
1898 params.push("note", value);
1899 }
1900 if let Some(value) = self._customer_phone_number.as_ref() {
1901 params.push("customerPhoneNumber", value);
1902 }
1903 if let Some(value) = self._customer_name.as_ref() {
1904 params.push("customerName", value);
1905 }
1906 if !self._custom_field.is_empty() {
1907 for f in self._custom_field.iter() {
1908 params.push("customField", f);
1909 }
1910 }
1911 if let Some(value) = self._assignee.as_ref() {
1912 params.push("assignee", value);
1913 }
1914
1915 params.extend(self._additional_params.iter());
1916
1917 params.push("alt", "json");
1918 let mut url = self.hub._base_url.clone() + "teams/{teamId}/jobs";
1919 if self._scopes.is_empty() {
1920 self._scopes.insert(Scope::Full.as_ref().to_string());
1921 }
1922
1923 #[allow(clippy::single_element_loop)]
1924 for &(find_this, param_name) in [("{teamId}", "teamId")].iter() {
1925 url = params.uri_replacement(url, param_name, find_this, false);
1926 }
1927 {
1928 let to_remove = ["teamId"];
1929 params.remove_params(&to_remove);
1930 }
1931
1932 let url = params.parse_with_url(&url);
1933
1934 let mut json_mime_type = mime::APPLICATION_JSON;
1935 let mut request_value_reader = {
1936 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1937 common::remove_json_null_values(&mut value);
1938 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1939 serde_json::to_writer(&mut dst, &value).unwrap();
1940 dst
1941 };
1942 let request_size = request_value_reader
1943 .seek(std::io::SeekFrom::End(0))
1944 .unwrap();
1945 request_value_reader
1946 .seek(std::io::SeekFrom::Start(0))
1947 .unwrap();
1948
1949 loop {
1950 let token = match self
1951 .hub
1952 .auth
1953 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1954 .await
1955 {
1956 Ok(token) => token,
1957 Err(e) => match dlg.token(e) {
1958 Ok(token) => token,
1959 Err(e) => {
1960 dlg.finished(false);
1961 return Err(common::Error::MissingToken(e));
1962 }
1963 },
1964 };
1965 request_value_reader
1966 .seek(std::io::SeekFrom::Start(0))
1967 .unwrap();
1968 let mut req_result = {
1969 let client = &self.hub.client;
1970 dlg.pre_request();
1971 let mut req_builder = hyper::Request::builder()
1972 .method(hyper::Method::POST)
1973 .uri(url.as_str())
1974 .header(USER_AGENT, self.hub._user_agent.clone());
1975
1976 if let Some(token) = token.as_ref() {
1977 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1978 }
1979
1980 let request = req_builder
1981 .header(CONTENT_TYPE, json_mime_type.to_string())
1982 .header(CONTENT_LENGTH, request_size as u64)
1983 .body(common::to_body(
1984 request_value_reader.get_ref().clone().into(),
1985 ));
1986
1987 client.request(request.unwrap()).await
1988 };
1989
1990 match req_result {
1991 Err(err) => {
1992 if let common::Retry::After(d) = dlg.http_error(&err) {
1993 sleep(d).await;
1994 continue;
1995 }
1996 dlg.finished(false);
1997 return Err(common::Error::HttpError(err));
1998 }
1999 Ok(res) => {
2000 let (mut parts, body) = res.into_parts();
2001 let mut body = common::Body::new(body);
2002 if !parts.status.is_success() {
2003 let bytes = common::to_bytes(body).await.unwrap_or_default();
2004 let error = serde_json::from_str(&common::to_string(&bytes));
2005 let response = common::to_response(parts, bytes.into());
2006
2007 if let common::Retry::After(d) =
2008 dlg.http_failure(&response, error.as_ref().ok())
2009 {
2010 sleep(d).await;
2011 continue;
2012 }
2013
2014 dlg.finished(false);
2015
2016 return Err(match error {
2017 Ok(value) => common::Error::BadRequest(value),
2018 _ => common::Error::Failure(response),
2019 });
2020 }
2021 let response = {
2022 let bytes = common::to_bytes(body).await.unwrap_or_default();
2023 let encoded = common::to_string(&bytes);
2024 match serde_json::from_str(&encoded) {
2025 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2026 Err(error) => {
2027 dlg.response_json_decode_error(&encoded, &error);
2028 return Err(common::Error::JsonDecodeError(
2029 encoded.to_string(),
2030 error,
2031 ));
2032 }
2033 }
2034 };
2035
2036 dlg.finished(true);
2037 return Ok(response);
2038 }
2039 }
2040 }
2041 }
2042
2043 ///
2044 /// Sets the *request* property to the given value.
2045 ///
2046 /// Even though the property as already been set when instantiating this call,
2047 /// we provide this method for API completeness.
2048 pub fn request(mut self, new_value: Job) -> JobInsertCall<'a, C> {
2049 self._request = new_value;
2050 self
2051 }
2052 /// Team ID
2053 ///
2054 /// Sets the *team id* path property to the given value.
2055 ///
2056 /// Even though the property as already been set when instantiating this call,
2057 /// we provide this method for API completeness.
2058 pub fn team_id(mut self, new_value: &str) -> JobInsertCall<'a, C> {
2059 self._team_id = new_value.to_string();
2060 self
2061 }
2062 /// Job address as newline (Unix) separated string
2063 ///
2064 /// Sets the *address* query property to the given value.
2065 ///
2066 /// Even though the property as already been set when instantiating this call,
2067 /// we provide this method for API completeness.
2068 pub fn address(mut self, new_value: &str) -> JobInsertCall<'a, C> {
2069 self._address = new_value.to_string();
2070 self
2071 }
2072 /// The latitude coordinate of this job's location.
2073 ///
2074 /// Sets the *lat* query property to the given value.
2075 ///
2076 /// Even though the property as already been set when instantiating this call,
2077 /// we provide this method for API completeness.
2078 pub fn lat(mut self, new_value: f64) -> JobInsertCall<'a, C> {
2079 self._lat = new_value;
2080 self
2081 }
2082 /// The longitude coordinate of this job's location.
2083 ///
2084 /// Sets the *lng* query property to the given value.
2085 ///
2086 /// Even though the property as already been set when instantiating this call,
2087 /// we provide this method for API completeness.
2088 pub fn lng(mut self, new_value: f64) -> JobInsertCall<'a, C> {
2089 self._lng = new_value;
2090 self
2091 }
2092 /// Job title
2093 ///
2094 /// Sets the *title* query property to the given value.
2095 ///
2096 /// Even though the property as already been set when instantiating this call,
2097 /// we provide this method for API completeness.
2098 pub fn title(mut self, new_value: &str) -> JobInsertCall<'a, C> {
2099 self._title = new_value.to_string();
2100 self
2101 }
2102 /// Job note as newline (Unix) separated string
2103 ///
2104 /// Sets the *note* query property to the given value.
2105 pub fn note(mut self, new_value: &str) -> JobInsertCall<'a, C> {
2106 self._note = Some(new_value.to_string());
2107 self
2108 }
2109 /// Customer phone number
2110 ///
2111 /// Sets the *customer phone number* query property to the given value.
2112 pub fn customer_phone_number(mut self, new_value: &str) -> JobInsertCall<'a, C> {
2113 self._customer_phone_number = Some(new_value.to_string());
2114 self
2115 }
2116 /// Customer name
2117 ///
2118 /// Sets the *customer name* query property to the given value.
2119 pub fn customer_name(mut self, new_value: &str) -> JobInsertCall<'a, C> {
2120 self._customer_name = Some(new_value.to_string());
2121 self
2122 }
2123 /// Sets the value of custom fields. To set a custom field, pass the field id (from /team/teamId/custom_fields), a URL escaped '=' character, and the desired value as a parameter. For example, customField=12%3DAlice. Repeat the parameter for each custom field. Note that '=' cannot appear in the parameter value. Specifying an invalid, or inactive enum field will result in an error 500.
2124 ///
2125 /// Append the given value to the *custom field* query property.
2126 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
2127 pub fn add_custom_field(mut self, new_value: &str) -> JobInsertCall<'a, C> {
2128 self._custom_field.push(new_value.to_string());
2129 self
2130 }
2131 /// Assignee email address, or empty string to unassign.
2132 ///
2133 /// Sets the *assignee* query property to the given value.
2134 pub fn assignee(mut self, new_value: &str) -> JobInsertCall<'a, C> {
2135 self._assignee = Some(new_value.to_string());
2136 self
2137 }
2138 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2139 /// while executing the actual API request.
2140 ///
2141 /// ````text
2142 /// It should be used to handle progress information, and to implement a certain level of resilience.
2143 /// ````
2144 ///
2145 /// Sets the *delegate* property to the given value.
2146 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> JobInsertCall<'a, C> {
2147 self._delegate = Some(new_value);
2148 self
2149 }
2150
2151 /// Set any additional parameter of the query string used in the request.
2152 /// It should be used to set parameters which are not yet available through their own
2153 /// setters.
2154 ///
2155 /// Please note that this method must not be used to set any of the known parameters
2156 /// which have their own setter method. If done anyway, the request will fail.
2157 ///
2158 /// # Additional Parameters
2159 ///
2160 /// * *alt* (query-string) - Data format for the response.
2161 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2162 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2163 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2164 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2165 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2166 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2167 pub fn param<T>(mut self, name: T, value: T) -> JobInsertCall<'a, C>
2168 where
2169 T: AsRef<str>,
2170 {
2171 self._additional_params
2172 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2173 self
2174 }
2175
2176 /// Identifies the authorization scope for the method you are building.
2177 ///
2178 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2179 /// [`Scope::Full`].
2180 ///
2181 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2182 /// tokens for more than one scope.
2183 ///
2184 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2185 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2186 /// sufficient, a read-write scope will do as well.
2187 pub fn add_scope<St>(mut self, scope: St) -> JobInsertCall<'a, C>
2188 where
2189 St: AsRef<str>,
2190 {
2191 self._scopes.insert(String::from(scope.as_ref()));
2192 self
2193 }
2194 /// Identifies the authorization scope(s) for the method you are building.
2195 ///
2196 /// See [`Self::add_scope()`] for details.
2197 pub fn add_scopes<I, St>(mut self, scopes: I) -> JobInsertCall<'a, C>
2198 where
2199 I: IntoIterator<Item = St>,
2200 St: AsRef<str>,
2201 {
2202 self._scopes
2203 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2204 self
2205 }
2206
2207 /// Removes all scopes, and no default scope will be used either.
2208 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2209 /// for details).
2210 pub fn clear_scopes(mut self) -> JobInsertCall<'a, C> {
2211 self._scopes.clear();
2212 self
2213 }
2214}
2215
2216/// Retrieves jobs created or modified since the given timestamp.
2217///
2218/// A builder for the *list* method supported by a *job* resource.
2219/// It is not used directly, but through a [`JobMethods`] instance.
2220///
2221/// # Example
2222///
2223/// Instantiate a resource method builder
2224///
2225/// ```test_harness,no_run
2226/// # extern crate hyper;
2227/// # extern crate hyper_rustls;
2228/// # extern crate google_coordinate1 as coordinate1;
2229/// # async fn dox() {
2230/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2231///
2232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2234/// # secret,
2235/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2236/// # ).build().await.unwrap();
2237///
2238/// # let client = hyper_util::client::legacy::Client::builder(
2239/// # hyper_util::rt::TokioExecutor::new()
2240/// # )
2241/// # .build(
2242/// # hyper_rustls::HttpsConnectorBuilder::new()
2243/// # .with_native_roots()
2244/// # .unwrap()
2245/// # .https_or_http()
2246/// # .enable_http1()
2247/// # .build()
2248/// # );
2249/// # let mut hub = Coordinate::new(client, auth);
2250/// // You can configure optional parameters by calling the respective setters at will, and
2251/// // execute the final call using `doit()`.
2252/// // Values shown here are possibly random and not representative !
2253/// let result = hub.jobs().list("teamId")
2254/// .page_token("dolore")
2255/// .omit_job_changes(false)
2256/// .min_modified_timestamp_ms(9)
2257/// .max_results(52)
2258/// .doit().await;
2259/// # }
2260/// ```
2261pub struct JobListCall<'a, C>
2262where
2263 C: 'a,
2264{
2265 hub: &'a Coordinate<C>,
2266 _team_id: String,
2267 _page_token: Option<String>,
2268 _omit_job_changes: Option<bool>,
2269 _min_modified_timestamp_ms: Option<u64>,
2270 _max_results: Option<u32>,
2271 _delegate: Option<&'a mut dyn common::Delegate>,
2272 _additional_params: HashMap<String, String>,
2273 _scopes: BTreeSet<String>,
2274}
2275
2276impl<'a, C> common::CallBuilder for JobListCall<'a, C> {}
2277
2278impl<'a, C> JobListCall<'a, C>
2279where
2280 C: common::Connector,
2281{
2282 /// Perform the operation you have build so far.
2283 pub async fn doit(mut self) -> common::Result<(common::Response, JobListResponse)> {
2284 use std::borrow::Cow;
2285 use std::io::{Read, Seek};
2286
2287 use common::{url::Params, ToParts};
2288 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2289
2290 let mut dd = common::DefaultDelegate;
2291 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2292 dlg.begin(common::MethodInfo {
2293 id: "coordinate.jobs.list",
2294 http_method: hyper::Method::GET,
2295 });
2296
2297 for &field in [
2298 "alt",
2299 "teamId",
2300 "pageToken",
2301 "omitJobChanges",
2302 "minModifiedTimestampMs",
2303 "maxResults",
2304 ]
2305 .iter()
2306 {
2307 if self._additional_params.contains_key(field) {
2308 dlg.finished(false);
2309 return Err(common::Error::FieldClash(field));
2310 }
2311 }
2312
2313 let mut params = Params::with_capacity(7 + self._additional_params.len());
2314 params.push("teamId", self._team_id);
2315 if let Some(value) = self._page_token.as_ref() {
2316 params.push("pageToken", value);
2317 }
2318 if let Some(value) = self._omit_job_changes.as_ref() {
2319 params.push("omitJobChanges", value.to_string());
2320 }
2321 if let Some(value) = self._min_modified_timestamp_ms.as_ref() {
2322 params.push("minModifiedTimestampMs", value.to_string());
2323 }
2324 if let Some(value) = self._max_results.as_ref() {
2325 params.push("maxResults", value.to_string());
2326 }
2327
2328 params.extend(self._additional_params.iter());
2329
2330 params.push("alt", "json");
2331 let mut url = self.hub._base_url.clone() + "teams/{teamId}/jobs";
2332 if self._scopes.is_empty() {
2333 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2334 }
2335
2336 #[allow(clippy::single_element_loop)]
2337 for &(find_this, param_name) in [("{teamId}", "teamId")].iter() {
2338 url = params.uri_replacement(url, param_name, find_this, false);
2339 }
2340 {
2341 let to_remove = ["teamId"];
2342 params.remove_params(&to_remove);
2343 }
2344
2345 let url = params.parse_with_url(&url);
2346
2347 loop {
2348 let token = match self
2349 .hub
2350 .auth
2351 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2352 .await
2353 {
2354 Ok(token) => token,
2355 Err(e) => match dlg.token(e) {
2356 Ok(token) => token,
2357 Err(e) => {
2358 dlg.finished(false);
2359 return Err(common::Error::MissingToken(e));
2360 }
2361 },
2362 };
2363 let mut req_result = {
2364 let client = &self.hub.client;
2365 dlg.pre_request();
2366 let mut req_builder = hyper::Request::builder()
2367 .method(hyper::Method::GET)
2368 .uri(url.as_str())
2369 .header(USER_AGENT, self.hub._user_agent.clone());
2370
2371 if let Some(token) = token.as_ref() {
2372 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2373 }
2374
2375 let request = req_builder
2376 .header(CONTENT_LENGTH, 0_u64)
2377 .body(common::to_body::<String>(None));
2378
2379 client.request(request.unwrap()).await
2380 };
2381
2382 match req_result {
2383 Err(err) => {
2384 if let common::Retry::After(d) = dlg.http_error(&err) {
2385 sleep(d).await;
2386 continue;
2387 }
2388 dlg.finished(false);
2389 return Err(common::Error::HttpError(err));
2390 }
2391 Ok(res) => {
2392 let (mut parts, body) = res.into_parts();
2393 let mut body = common::Body::new(body);
2394 if !parts.status.is_success() {
2395 let bytes = common::to_bytes(body).await.unwrap_or_default();
2396 let error = serde_json::from_str(&common::to_string(&bytes));
2397 let response = common::to_response(parts, bytes.into());
2398
2399 if let common::Retry::After(d) =
2400 dlg.http_failure(&response, error.as_ref().ok())
2401 {
2402 sleep(d).await;
2403 continue;
2404 }
2405
2406 dlg.finished(false);
2407
2408 return Err(match error {
2409 Ok(value) => common::Error::BadRequest(value),
2410 _ => common::Error::Failure(response),
2411 });
2412 }
2413 let response = {
2414 let bytes = common::to_bytes(body).await.unwrap_or_default();
2415 let encoded = common::to_string(&bytes);
2416 match serde_json::from_str(&encoded) {
2417 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2418 Err(error) => {
2419 dlg.response_json_decode_error(&encoded, &error);
2420 return Err(common::Error::JsonDecodeError(
2421 encoded.to_string(),
2422 error,
2423 ));
2424 }
2425 }
2426 };
2427
2428 dlg.finished(true);
2429 return Ok(response);
2430 }
2431 }
2432 }
2433 }
2434
2435 /// Team ID
2436 ///
2437 /// Sets the *team id* path property to the given value.
2438 ///
2439 /// Even though the property as already been set when instantiating this call,
2440 /// we provide this method for API completeness.
2441 pub fn team_id(mut self, new_value: &str) -> JobListCall<'a, C> {
2442 self._team_id = new_value.to_string();
2443 self
2444 }
2445 /// Continuation token
2446 ///
2447 /// Sets the *page token* query property to the given value.
2448 pub fn page_token(mut self, new_value: &str) -> JobListCall<'a, C> {
2449 self._page_token = Some(new_value.to_string());
2450 self
2451 }
2452 /// Whether to omit detail job history information.
2453 ///
2454 /// Sets the *omit job changes* query property to the given value.
2455 pub fn omit_job_changes(mut self, new_value: bool) -> JobListCall<'a, C> {
2456 self._omit_job_changes = Some(new_value);
2457 self
2458 }
2459 /// Minimum time a job was modified in milliseconds since epoch.
2460 ///
2461 /// Sets the *min modified timestamp ms* query property to the given value.
2462 pub fn min_modified_timestamp_ms(mut self, new_value: u64) -> JobListCall<'a, C> {
2463 self._min_modified_timestamp_ms = Some(new_value);
2464 self
2465 }
2466 /// Maximum number of results to return in one page.
2467 ///
2468 /// Sets the *max results* query property to the given value.
2469 pub fn max_results(mut self, new_value: u32) -> JobListCall<'a, C> {
2470 self._max_results = Some(new_value);
2471 self
2472 }
2473 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2474 /// while executing the actual API request.
2475 ///
2476 /// ````text
2477 /// It should be used to handle progress information, and to implement a certain level of resilience.
2478 /// ````
2479 ///
2480 /// Sets the *delegate* property to the given value.
2481 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> JobListCall<'a, C> {
2482 self._delegate = Some(new_value);
2483 self
2484 }
2485
2486 /// Set any additional parameter of the query string used in the request.
2487 /// It should be used to set parameters which are not yet available through their own
2488 /// setters.
2489 ///
2490 /// Please note that this method must not be used to set any of the known parameters
2491 /// which have their own setter method. If done anyway, the request will fail.
2492 ///
2493 /// # Additional Parameters
2494 ///
2495 /// * *alt* (query-string) - Data format for the response.
2496 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2497 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2498 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2499 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2500 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2501 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2502 pub fn param<T>(mut self, name: T, value: T) -> JobListCall<'a, C>
2503 where
2504 T: AsRef<str>,
2505 {
2506 self._additional_params
2507 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2508 self
2509 }
2510
2511 /// Identifies the authorization scope for the method you are building.
2512 ///
2513 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2514 /// [`Scope::Readonly`].
2515 ///
2516 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2517 /// tokens for more than one scope.
2518 ///
2519 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2520 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2521 /// sufficient, a read-write scope will do as well.
2522 pub fn add_scope<St>(mut self, scope: St) -> JobListCall<'a, C>
2523 where
2524 St: AsRef<str>,
2525 {
2526 self._scopes.insert(String::from(scope.as_ref()));
2527 self
2528 }
2529 /// Identifies the authorization scope(s) for the method you are building.
2530 ///
2531 /// See [`Self::add_scope()`] for details.
2532 pub fn add_scopes<I, St>(mut self, scopes: I) -> JobListCall<'a, C>
2533 where
2534 I: IntoIterator<Item = St>,
2535 St: AsRef<str>,
2536 {
2537 self._scopes
2538 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2539 self
2540 }
2541
2542 /// Removes all scopes, and no default scope will be used either.
2543 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2544 /// for details).
2545 pub fn clear_scopes(mut self) -> JobListCall<'a, C> {
2546 self._scopes.clear();
2547 self
2548 }
2549}
2550
2551/// Updates a job. Fields that are set in the job state will be updated. This method supports patch semantics.
2552///
2553/// A builder for the *patch* method supported by a *job* resource.
2554/// It is not used directly, but through a [`JobMethods`] instance.
2555///
2556/// # Example
2557///
2558/// Instantiate a resource method builder
2559///
2560/// ```test_harness,no_run
2561/// # extern crate hyper;
2562/// # extern crate hyper_rustls;
2563/// # extern crate google_coordinate1 as coordinate1;
2564/// use coordinate1::api::Job;
2565/// # async fn dox() {
2566/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2567///
2568/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2569/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2570/// # secret,
2571/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2572/// # ).build().await.unwrap();
2573///
2574/// # let client = hyper_util::client::legacy::Client::builder(
2575/// # hyper_util::rt::TokioExecutor::new()
2576/// # )
2577/// # .build(
2578/// # hyper_rustls::HttpsConnectorBuilder::new()
2579/// # .with_native_roots()
2580/// # .unwrap()
2581/// # .https_or_http()
2582/// # .enable_http1()
2583/// # .build()
2584/// # );
2585/// # let mut hub = Coordinate::new(client, auth);
2586/// // As the method needs a request, you would usually fill it with the desired information
2587/// // into the respective structure. Some of the parts shown here might not be applicable !
2588/// // Values shown here are possibly random and not representative !
2589/// let mut req = Job::default();
2590///
2591/// // You can configure optional parameters by calling the respective setters at will, and
2592/// // execute the final call using `doit()`.
2593/// // Values shown here are possibly random and not representative !
2594/// let result = hub.jobs().patch(req, "teamId", 79)
2595/// .title("sadipscing")
2596/// .progress("Stet")
2597/// .note("dolor")
2598/// .lng(0.6349978834153693)
2599/// .lat(0.1970220513983837)
2600/// .customer_phone_number("Stet")
2601/// .customer_name("vero")
2602/// .add_custom_field("elitr")
2603/// .assignee("Lorem")
2604/// .address("diam")
2605/// .doit().await;
2606/// # }
2607/// ```
2608pub struct JobPatchCall<'a, C>
2609where
2610 C: 'a,
2611{
2612 hub: &'a Coordinate<C>,
2613 _request: Job,
2614 _team_id: String,
2615 _job_id: u64,
2616 _title: Option<String>,
2617 _progress: Option<String>,
2618 _note: Option<String>,
2619 _lng: Option<f64>,
2620 _lat: Option<f64>,
2621 _customer_phone_number: Option<String>,
2622 _customer_name: Option<String>,
2623 _custom_field: Vec<String>,
2624 _assignee: Option<String>,
2625 _address: Option<String>,
2626 _delegate: Option<&'a mut dyn common::Delegate>,
2627 _additional_params: HashMap<String, String>,
2628 _scopes: BTreeSet<String>,
2629}
2630
2631impl<'a, C> common::CallBuilder for JobPatchCall<'a, C> {}
2632
2633impl<'a, C> JobPatchCall<'a, C>
2634where
2635 C: common::Connector,
2636{
2637 /// Perform the operation you have build so far.
2638 pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
2639 use std::borrow::Cow;
2640 use std::io::{Read, Seek};
2641
2642 use common::{url::Params, ToParts};
2643 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2644
2645 let mut dd = common::DefaultDelegate;
2646 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2647 dlg.begin(common::MethodInfo {
2648 id: "coordinate.jobs.patch",
2649 http_method: hyper::Method::PATCH,
2650 });
2651
2652 for &field in [
2653 "alt",
2654 "teamId",
2655 "jobId",
2656 "title",
2657 "progress",
2658 "note",
2659 "lng",
2660 "lat",
2661 "customerPhoneNumber",
2662 "customerName",
2663 "customField",
2664 "assignee",
2665 "address",
2666 ]
2667 .iter()
2668 {
2669 if self._additional_params.contains_key(field) {
2670 dlg.finished(false);
2671 return Err(common::Error::FieldClash(field));
2672 }
2673 }
2674
2675 let mut params = Params::with_capacity(15 + self._additional_params.len());
2676 params.push("teamId", self._team_id);
2677 params.push("jobId", self._job_id.to_string());
2678 if let Some(value) = self._title.as_ref() {
2679 params.push("title", value);
2680 }
2681 if let Some(value) = self._progress.as_ref() {
2682 params.push("progress", value);
2683 }
2684 if let Some(value) = self._note.as_ref() {
2685 params.push("note", value);
2686 }
2687 if let Some(value) = self._lng.as_ref() {
2688 params.push("lng", value.to_string());
2689 }
2690 if let Some(value) = self._lat.as_ref() {
2691 params.push("lat", value.to_string());
2692 }
2693 if let Some(value) = self._customer_phone_number.as_ref() {
2694 params.push("customerPhoneNumber", value);
2695 }
2696 if let Some(value) = self._customer_name.as_ref() {
2697 params.push("customerName", value);
2698 }
2699 if !self._custom_field.is_empty() {
2700 for f in self._custom_field.iter() {
2701 params.push("customField", f);
2702 }
2703 }
2704 if let Some(value) = self._assignee.as_ref() {
2705 params.push("assignee", value);
2706 }
2707 if let Some(value) = self._address.as_ref() {
2708 params.push("address", value);
2709 }
2710
2711 params.extend(self._additional_params.iter());
2712
2713 params.push("alt", "json");
2714 let mut url = self.hub._base_url.clone() + "teams/{teamId}/jobs/{jobId}";
2715 if self._scopes.is_empty() {
2716 self._scopes.insert(Scope::Full.as_ref().to_string());
2717 }
2718
2719 #[allow(clippy::single_element_loop)]
2720 for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].iter() {
2721 url = params.uri_replacement(url, param_name, find_this, false);
2722 }
2723 {
2724 let to_remove = ["jobId", "teamId"];
2725 params.remove_params(&to_remove);
2726 }
2727
2728 let url = params.parse_with_url(&url);
2729
2730 let mut json_mime_type = mime::APPLICATION_JSON;
2731 let mut request_value_reader = {
2732 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2733 common::remove_json_null_values(&mut value);
2734 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2735 serde_json::to_writer(&mut dst, &value).unwrap();
2736 dst
2737 };
2738 let request_size = request_value_reader
2739 .seek(std::io::SeekFrom::End(0))
2740 .unwrap();
2741 request_value_reader
2742 .seek(std::io::SeekFrom::Start(0))
2743 .unwrap();
2744
2745 loop {
2746 let token = match self
2747 .hub
2748 .auth
2749 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2750 .await
2751 {
2752 Ok(token) => token,
2753 Err(e) => match dlg.token(e) {
2754 Ok(token) => token,
2755 Err(e) => {
2756 dlg.finished(false);
2757 return Err(common::Error::MissingToken(e));
2758 }
2759 },
2760 };
2761 request_value_reader
2762 .seek(std::io::SeekFrom::Start(0))
2763 .unwrap();
2764 let mut req_result = {
2765 let client = &self.hub.client;
2766 dlg.pre_request();
2767 let mut req_builder = hyper::Request::builder()
2768 .method(hyper::Method::PATCH)
2769 .uri(url.as_str())
2770 .header(USER_AGENT, self.hub._user_agent.clone());
2771
2772 if let Some(token) = token.as_ref() {
2773 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2774 }
2775
2776 let request = req_builder
2777 .header(CONTENT_TYPE, json_mime_type.to_string())
2778 .header(CONTENT_LENGTH, request_size as u64)
2779 .body(common::to_body(
2780 request_value_reader.get_ref().clone().into(),
2781 ));
2782
2783 client.request(request.unwrap()).await
2784 };
2785
2786 match req_result {
2787 Err(err) => {
2788 if let common::Retry::After(d) = dlg.http_error(&err) {
2789 sleep(d).await;
2790 continue;
2791 }
2792 dlg.finished(false);
2793 return Err(common::Error::HttpError(err));
2794 }
2795 Ok(res) => {
2796 let (mut parts, body) = res.into_parts();
2797 let mut body = common::Body::new(body);
2798 if !parts.status.is_success() {
2799 let bytes = common::to_bytes(body).await.unwrap_or_default();
2800 let error = serde_json::from_str(&common::to_string(&bytes));
2801 let response = common::to_response(parts, bytes.into());
2802
2803 if let common::Retry::After(d) =
2804 dlg.http_failure(&response, error.as_ref().ok())
2805 {
2806 sleep(d).await;
2807 continue;
2808 }
2809
2810 dlg.finished(false);
2811
2812 return Err(match error {
2813 Ok(value) => common::Error::BadRequest(value),
2814 _ => common::Error::Failure(response),
2815 });
2816 }
2817 let response = {
2818 let bytes = common::to_bytes(body).await.unwrap_or_default();
2819 let encoded = common::to_string(&bytes);
2820 match serde_json::from_str(&encoded) {
2821 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2822 Err(error) => {
2823 dlg.response_json_decode_error(&encoded, &error);
2824 return Err(common::Error::JsonDecodeError(
2825 encoded.to_string(),
2826 error,
2827 ));
2828 }
2829 }
2830 };
2831
2832 dlg.finished(true);
2833 return Ok(response);
2834 }
2835 }
2836 }
2837 }
2838
2839 ///
2840 /// Sets the *request* property to the given value.
2841 ///
2842 /// Even though the property as already been set when instantiating this call,
2843 /// we provide this method for API completeness.
2844 pub fn request(mut self, new_value: Job) -> JobPatchCall<'a, C> {
2845 self._request = new_value;
2846 self
2847 }
2848 /// Team ID
2849 ///
2850 /// Sets the *team id* path property to the given value.
2851 ///
2852 /// Even though the property as already been set when instantiating this call,
2853 /// we provide this method for API completeness.
2854 pub fn team_id(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2855 self._team_id = new_value.to_string();
2856 self
2857 }
2858 /// Job number
2859 ///
2860 /// Sets the *job id* path property to the given value.
2861 ///
2862 /// Even though the property as already been set when instantiating this call,
2863 /// we provide this method for API completeness.
2864 pub fn job_id(mut self, new_value: u64) -> JobPatchCall<'a, C> {
2865 self._job_id = new_value;
2866 self
2867 }
2868 /// Job title
2869 ///
2870 /// Sets the *title* query property to the given value.
2871 pub fn title(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2872 self._title = Some(new_value.to_string());
2873 self
2874 }
2875 /// Job progress
2876 ///
2877 /// Sets the *progress* query property to the given value.
2878 pub fn progress(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2879 self._progress = Some(new_value.to_string());
2880 self
2881 }
2882 /// Job note as newline (Unix) separated string
2883 ///
2884 /// Sets the *note* query property to the given value.
2885 pub fn note(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2886 self._note = Some(new_value.to_string());
2887 self
2888 }
2889 /// The longitude coordinate of this job's location.
2890 ///
2891 /// Sets the *lng* query property to the given value.
2892 pub fn lng(mut self, new_value: f64) -> JobPatchCall<'a, C> {
2893 self._lng = Some(new_value);
2894 self
2895 }
2896 /// The latitude coordinate of this job's location.
2897 ///
2898 /// Sets the *lat* query property to the given value.
2899 pub fn lat(mut self, new_value: f64) -> JobPatchCall<'a, C> {
2900 self._lat = Some(new_value);
2901 self
2902 }
2903 /// Customer phone number
2904 ///
2905 /// Sets the *customer phone number* query property to the given value.
2906 pub fn customer_phone_number(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2907 self._customer_phone_number = Some(new_value.to_string());
2908 self
2909 }
2910 /// Customer name
2911 ///
2912 /// Sets the *customer name* query property to the given value.
2913 pub fn customer_name(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2914 self._customer_name = Some(new_value.to_string());
2915 self
2916 }
2917 /// Sets the value of custom fields. To set a custom field, pass the field id (from /team/teamId/custom_fields), a URL escaped '=' character, and the desired value as a parameter. For example, customField=12%3DAlice. Repeat the parameter for each custom field. Note that '=' cannot appear in the parameter value. Specifying an invalid, or inactive enum field will result in an error 500.
2918 ///
2919 /// Append the given value to the *custom field* query property.
2920 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
2921 pub fn add_custom_field(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2922 self._custom_field.push(new_value.to_string());
2923 self
2924 }
2925 /// Assignee email address, or empty string to unassign.
2926 ///
2927 /// Sets the *assignee* query property to the given value.
2928 pub fn assignee(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2929 self._assignee = Some(new_value.to_string());
2930 self
2931 }
2932 /// Job address as newline (Unix) separated string
2933 ///
2934 /// Sets the *address* query property to the given value.
2935 pub fn address(mut self, new_value: &str) -> JobPatchCall<'a, C> {
2936 self._address = Some(new_value.to_string());
2937 self
2938 }
2939 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2940 /// while executing the actual API request.
2941 ///
2942 /// ````text
2943 /// It should be used to handle progress information, and to implement a certain level of resilience.
2944 /// ````
2945 ///
2946 /// Sets the *delegate* property to the given value.
2947 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> JobPatchCall<'a, C> {
2948 self._delegate = Some(new_value);
2949 self
2950 }
2951
2952 /// Set any additional parameter of the query string used in the request.
2953 /// It should be used to set parameters which are not yet available through their own
2954 /// setters.
2955 ///
2956 /// Please note that this method must not be used to set any of the known parameters
2957 /// which have their own setter method. If done anyway, the request will fail.
2958 ///
2959 /// # Additional Parameters
2960 ///
2961 /// * *alt* (query-string) - Data format for the response.
2962 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2963 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2964 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2965 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2966 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2967 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2968 pub fn param<T>(mut self, name: T, value: T) -> JobPatchCall<'a, C>
2969 where
2970 T: AsRef<str>,
2971 {
2972 self._additional_params
2973 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2974 self
2975 }
2976
2977 /// Identifies the authorization scope for the method you are building.
2978 ///
2979 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2980 /// [`Scope::Full`].
2981 ///
2982 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2983 /// tokens for more than one scope.
2984 ///
2985 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2986 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2987 /// sufficient, a read-write scope will do as well.
2988 pub fn add_scope<St>(mut self, scope: St) -> JobPatchCall<'a, C>
2989 where
2990 St: AsRef<str>,
2991 {
2992 self._scopes.insert(String::from(scope.as_ref()));
2993 self
2994 }
2995 /// Identifies the authorization scope(s) for the method you are building.
2996 ///
2997 /// See [`Self::add_scope()`] for details.
2998 pub fn add_scopes<I, St>(mut self, scopes: I) -> JobPatchCall<'a, C>
2999 where
3000 I: IntoIterator<Item = St>,
3001 St: AsRef<str>,
3002 {
3003 self._scopes
3004 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3005 self
3006 }
3007
3008 /// Removes all scopes, and no default scope will be used either.
3009 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3010 /// for details).
3011 pub fn clear_scopes(mut self) -> JobPatchCall<'a, C> {
3012 self._scopes.clear();
3013 self
3014 }
3015}
3016
3017/// Updates a job. Fields that are set in the job state will be updated.
3018///
3019/// A builder for the *update* method supported by a *job* resource.
3020/// It is not used directly, but through a [`JobMethods`] instance.
3021///
3022/// # Example
3023///
3024/// Instantiate a resource method builder
3025///
3026/// ```test_harness,no_run
3027/// # extern crate hyper;
3028/// # extern crate hyper_rustls;
3029/// # extern crate google_coordinate1 as coordinate1;
3030/// use coordinate1::api::Job;
3031/// # async fn dox() {
3032/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3033///
3034/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3035/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3036/// # secret,
3037/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3038/// # ).build().await.unwrap();
3039///
3040/// # let client = hyper_util::client::legacy::Client::builder(
3041/// # hyper_util::rt::TokioExecutor::new()
3042/// # )
3043/// # .build(
3044/// # hyper_rustls::HttpsConnectorBuilder::new()
3045/// # .with_native_roots()
3046/// # .unwrap()
3047/// # .https_or_http()
3048/// # .enable_http1()
3049/// # .build()
3050/// # );
3051/// # let mut hub = Coordinate::new(client, auth);
3052/// // As the method needs a request, you would usually fill it with the desired information
3053/// // into the respective structure. Some of the parts shown here might not be applicable !
3054/// // Values shown here are possibly random and not representative !
3055/// let mut req = Job::default();
3056///
3057/// // You can configure optional parameters by calling the respective setters at will, and
3058/// // execute the final call using `doit()`.
3059/// // Values shown here are possibly random and not representative !
3060/// let result = hub.jobs().update(req, "teamId", 1)
3061/// .title("accusam")
3062/// .progress("takimata")
3063/// .note("consetetur")
3064/// .lng(0.5721089079262882)
3065/// .lat(0.22880530766851637)
3066/// .customer_phone_number("consetetur")
3067/// .customer_name("amet.")
3068/// .add_custom_field("sed")
3069/// .assignee("takimata")
3070/// .address("dolores")
3071/// .doit().await;
3072/// # }
3073/// ```
3074pub struct JobUpdateCall<'a, C>
3075where
3076 C: 'a,
3077{
3078 hub: &'a Coordinate<C>,
3079 _request: Job,
3080 _team_id: String,
3081 _job_id: u64,
3082 _title: Option<String>,
3083 _progress: Option<String>,
3084 _note: Option<String>,
3085 _lng: Option<f64>,
3086 _lat: Option<f64>,
3087 _customer_phone_number: Option<String>,
3088 _customer_name: Option<String>,
3089 _custom_field: Vec<String>,
3090 _assignee: Option<String>,
3091 _address: Option<String>,
3092 _delegate: Option<&'a mut dyn common::Delegate>,
3093 _additional_params: HashMap<String, String>,
3094 _scopes: BTreeSet<String>,
3095}
3096
3097impl<'a, C> common::CallBuilder for JobUpdateCall<'a, C> {}
3098
3099impl<'a, C> JobUpdateCall<'a, C>
3100where
3101 C: common::Connector,
3102{
3103 /// Perform the operation you have build so far.
3104 pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
3105 use std::borrow::Cow;
3106 use std::io::{Read, Seek};
3107
3108 use common::{url::Params, ToParts};
3109 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3110
3111 let mut dd = common::DefaultDelegate;
3112 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3113 dlg.begin(common::MethodInfo {
3114 id: "coordinate.jobs.update",
3115 http_method: hyper::Method::PUT,
3116 });
3117
3118 for &field in [
3119 "alt",
3120 "teamId",
3121 "jobId",
3122 "title",
3123 "progress",
3124 "note",
3125 "lng",
3126 "lat",
3127 "customerPhoneNumber",
3128 "customerName",
3129 "customField",
3130 "assignee",
3131 "address",
3132 ]
3133 .iter()
3134 {
3135 if self._additional_params.contains_key(field) {
3136 dlg.finished(false);
3137 return Err(common::Error::FieldClash(field));
3138 }
3139 }
3140
3141 let mut params = Params::with_capacity(15 + self._additional_params.len());
3142 params.push("teamId", self._team_id);
3143 params.push("jobId", self._job_id.to_string());
3144 if let Some(value) = self._title.as_ref() {
3145 params.push("title", value);
3146 }
3147 if let Some(value) = self._progress.as_ref() {
3148 params.push("progress", value);
3149 }
3150 if let Some(value) = self._note.as_ref() {
3151 params.push("note", value);
3152 }
3153 if let Some(value) = self._lng.as_ref() {
3154 params.push("lng", value.to_string());
3155 }
3156 if let Some(value) = self._lat.as_ref() {
3157 params.push("lat", value.to_string());
3158 }
3159 if let Some(value) = self._customer_phone_number.as_ref() {
3160 params.push("customerPhoneNumber", value);
3161 }
3162 if let Some(value) = self._customer_name.as_ref() {
3163 params.push("customerName", value);
3164 }
3165 if !self._custom_field.is_empty() {
3166 for f in self._custom_field.iter() {
3167 params.push("customField", f);
3168 }
3169 }
3170 if let Some(value) = self._assignee.as_ref() {
3171 params.push("assignee", value);
3172 }
3173 if let Some(value) = self._address.as_ref() {
3174 params.push("address", value);
3175 }
3176
3177 params.extend(self._additional_params.iter());
3178
3179 params.push("alt", "json");
3180 let mut url = self.hub._base_url.clone() + "teams/{teamId}/jobs/{jobId}";
3181 if self._scopes.is_empty() {
3182 self._scopes.insert(Scope::Full.as_ref().to_string());
3183 }
3184
3185 #[allow(clippy::single_element_loop)]
3186 for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].iter() {
3187 url = params.uri_replacement(url, param_name, find_this, false);
3188 }
3189 {
3190 let to_remove = ["jobId", "teamId"];
3191 params.remove_params(&to_remove);
3192 }
3193
3194 let url = params.parse_with_url(&url);
3195
3196 let mut json_mime_type = mime::APPLICATION_JSON;
3197 let mut request_value_reader = {
3198 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3199 common::remove_json_null_values(&mut value);
3200 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3201 serde_json::to_writer(&mut dst, &value).unwrap();
3202 dst
3203 };
3204 let request_size = request_value_reader
3205 .seek(std::io::SeekFrom::End(0))
3206 .unwrap();
3207 request_value_reader
3208 .seek(std::io::SeekFrom::Start(0))
3209 .unwrap();
3210
3211 loop {
3212 let token = match self
3213 .hub
3214 .auth
3215 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3216 .await
3217 {
3218 Ok(token) => token,
3219 Err(e) => match dlg.token(e) {
3220 Ok(token) => token,
3221 Err(e) => {
3222 dlg.finished(false);
3223 return Err(common::Error::MissingToken(e));
3224 }
3225 },
3226 };
3227 request_value_reader
3228 .seek(std::io::SeekFrom::Start(0))
3229 .unwrap();
3230 let mut req_result = {
3231 let client = &self.hub.client;
3232 dlg.pre_request();
3233 let mut req_builder = hyper::Request::builder()
3234 .method(hyper::Method::PUT)
3235 .uri(url.as_str())
3236 .header(USER_AGENT, self.hub._user_agent.clone());
3237
3238 if let Some(token) = token.as_ref() {
3239 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3240 }
3241
3242 let request = req_builder
3243 .header(CONTENT_TYPE, json_mime_type.to_string())
3244 .header(CONTENT_LENGTH, request_size as u64)
3245 .body(common::to_body(
3246 request_value_reader.get_ref().clone().into(),
3247 ));
3248
3249 client.request(request.unwrap()).await
3250 };
3251
3252 match req_result {
3253 Err(err) => {
3254 if let common::Retry::After(d) = dlg.http_error(&err) {
3255 sleep(d).await;
3256 continue;
3257 }
3258 dlg.finished(false);
3259 return Err(common::Error::HttpError(err));
3260 }
3261 Ok(res) => {
3262 let (mut parts, body) = res.into_parts();
3263 let mut body = common::Body::new(body);
3264 if !parts.status.is_success() {
3265 let bytes = common::to_bytes(body).await.unwrap_or_default();
3266 let error = serde_json::from_str(&common::to_string(&bytes));
3267 let response = common::to_response(parts, bytes.into());
3268
3269 if let common::Retry::After(d) =
3270 dlg.http_failure(&response, error.as_ref().ok())
3271 {
3272 sleep(d).await;
3273 continue;
3274 }
3275
3276 dlg.finished(false);
3277
3278 return Err(match error {
3279 Ok(value) => common::Error::BadRequest(value),
3280 _ => common::Error::Failure(response),
3281 });
3282 }
3283 let response = {
3284 let bytes = common::to_bytes(body).await.unwrap_or_default();
3285 let encoded = common::to_string(&bytes);
3286 match serde_json::from_str(&encoded) {
3287 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3288 Err(error) => {
3289 dlg.response_json_decode_error(&encoded, &error);
3290 return Err(common::Error::JsonDecodeError(
3291 encoded.to_string(),
3292 error,
3293 ));
3294 }
3295 }
3296 };
3297
3298 dlg.finished(true);
3299 return Ok(response);
3300 }
3301 }
3302 }
3303 }
3304
3305 ///
3306 /// Sets the *request* property to the given value.
3307 ///
3308 /// Even though the property as already been set when instantiating this call,
3309 /// we provide this method for API completeness.
3310 pub fn request(mut self, new_value: Job) -> JobUpdateCall<'a, C> {
3311 self._request = new_value;
3312 self
3313 }
3314 /// Team ID
3315 ///
3316 /// Sets the *team id* path property to the given value.
3317 ///
3318 /// Even though the property as already been set when instantiating this call,
3319 /// we provide this method for API completeness.
3320 pub fn team_id(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3321 self._team_id = new_value.to_string();
3322 self
3323 }
3324 /// Job number
3325 ///
3326 /// Sets the *job id* path property to the given value.
3327 ///
3328 /// Even though the property as already been set when instantiating this call,
3329 /// we provide this method for API completeness.
3330 pub fn job_id(mut self, new_value: u64) -> JobUpdateCall<'a, C> {
3331 self._job_id = new_value;
3332 self
3333 }
3334 /// Job title
3335 ///
3336 /// Sets the *title* query property to the given value.
3337 pub fn title(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3338 self._title = Some(new_value.to_string());
3339 self
3340 }
3341 /// Job progress
3342 ///
3343 /// Sets the *progress* query property to the given value.
3344 pub fn progress(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3345 self._progress = Some(new_value.to_string());
3346 self
3347 }
3348 /// Job note as newline (Unix) separated string
3349 ///
3350 /// Sets the *note* query property to the given value.
3351 pub fn note(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3352 self._note = Some(new_value.to_string());
3353 self
3354 }
3355 /// The longitude coordinate of this job's location.
3356 ///
3357 /// Sets the *lng* query property to the given value.
3358 pub fn lng(mut self, new_value: f64) -> JobUpdateCall<'a, C> {
3359 self._lng = Some(new_value);
3360 self
3361 }
3362 /// The latitude coordinate of this job's location.
3363 ///
3364 /// Sets the *lat* query property to the given value.
3365 pub fn lat(mut self, new_value: f64) -> JobUpdateCall<'a, C> {
3366 self._lat = Some(new_value);
3367 self
3368 }
3369 /// Customer phone number
3370 ///
3371 /// Sets the *customer phone number* query property to the given value.
3372 pub fn customer_phone_number(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3373 self._customer_phone_number = Some(new_value.to_string());
3374 self
3375 }
3376 /// Customer name
3377 ///
3378 /// Sets the *customer name* query property to the given value.
3379 pub fn customer_name(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3380 self._customer_name = Some(new_value.to_string());
3381 self
3382 }
3383 /// Sets the value of custom fields. To set a custom field, pass the field id (from /team/teamId/custom_fields), a URL escaped '=' character, and the desired value as a parameter. For example, customField=12%3DAlice. Repeat the parameter for each custom field. Note that '=' cannot appear in the parameter value. Specifying an invalid, or inactive enum field will result in an error 500.
3384 ///
3385 /// Append the given value to the *custom field* query property.
3386 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3387 pub fn add_custom_field(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3388 self._custom_field.push(new_value.to_string());
3389 self
3390 }
3391 /// Assignee email address, or empty string to unassign.
3392 ///
3393 /// Sets the *assignee* query property to the given value.
3394 pub fn assignee(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3395 self._assignee = Some(new_value.to_string());
3396 self
3397 }
3398 /// Job address as newline (Unix) separated string
3399 ///
3400 /// Sets the *address* query property to the given value.
3401 pub fn address(mut self, new_value: &str) -> JobUpdateCall<'a, C> {
3402 self._address = Some(new_value.to_string());
3403 self
3404 }
3405 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3406 /// while executing the actual API request.
3407 ///
3408 /// ````text
3409 /// It should be used to handle progress information, and to implement a certain level of resilience.
3410 /// ````
3411 ///
3412 /// Sets the *delegate* property to the given value.
3413 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> JobUpdateCall<'a, C> {
3414 self._delegate = Some(new_value);
3415 self
3416 }
3417
3418 /// Set any additional parameter of the query string used in the request.
3419 /// It should be used to set parameters which are not yet available through their own
3420 /// setters.
3421 ///
3422 /// Please note that this method must not be used to set any of the known parameters
3423 /// which have their own setter method. If done anyway, the request will fail.
3424 ///
3425 /// # Additional Parameters
3426 ///
3427 /// * *alt* (query-string) - Data format for the response.
3428 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3429 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3430 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3431 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3432 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
3433 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3434 pub fn param<T>(mut self, name: T, value: T) -> JobUpdateCall<'a, C>
3435 where
3436 T: AsRef<str>,
3437 {
3438 self._additional_params
3439 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3440 self
3441 }
3442
3443 /// Identifies the authorization scope for the method you are building.
3444 ///
3445 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3446 /// [`Scope::Full`].
3447 ///
3448 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3449 /// tokens for more than one scope.
3450 ///
3451 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3452 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3453 /// sufficient, a read-write scope will do as well.
3454 pub fn add_scope<St>(mut self, scope: St) -> JobUpdateCall<'a, C>
3455 where
3456 St: AsRef<str>,
3457 {
3458 self._scopes.insert(String::from(scope.as_ref()));
3459 self
3460 }
3461 /// Identifies the authorization scope(s) for the method you are building.
3462 ///
3463 /// See [`Self::add_scope()`] for details.
3464 pub fn add_scopes<I, St>(mut self, scopes: I) -> JobUpdateCall<'a, C>
3465 where
3466 I: IntoIterator<Item = St>,
3467 St: AsRef<str>,
3468 {
3469 self._scopes
3470 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3471 self
3472 }
3473
3474 /// Removes all scopes, and no default scope will be used either.
3475 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3476 /// for details).
3477 pub fn clear_scopes(mut self) -> JobUpdateCall<'a, C> {
3478 self._scopes.clear();
3479 self
3480 }
3481}
3482
3483/// Retrieves a list of locations for a worker.
3484///
3485/// A builder for the *list* method supported by a *location* resource.
3486/// It is not used directly, but through a [`LocationMethods`] instance.
3487///
3488/// # Example
3489///
3490/// Instantiate a resource method builder
3491///
3492/// ```test_harness,no_run
3493/// # extern crate hyper;
3494/// # extern crate hyper_rustls;
3495/// # extern crate google_coordinate1 as coordinate1;
3496/// # async fn dox() {
3497/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3498///
3499/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3500/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3501/// # secret,
3502/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3503/// # ).build().await.unwrap();
3504///
3505/// # let client = hyper_util::client::legacy::Client::builder(
3506/// # hyper_util::rt::TokioExecutor::new()
3507/// # )
3508/// # .build(
3509/// # hyper_rustls::HttpsConnectorBuilder::new()
3510/// # .with_native_roots()
3511/// # .unwrap()
3512/// # .https_or_http()
3513/// # .enable_http1()
3514/// # .build()
3515/// # );
3516/// # let mut hub = Coordinate::new(client, auth);
3517/// // You can configure optional parameters by calling the respective setters at will, and
3518/// // execute the final call using `doit()`.
3519/// // Values shown here are possibly random and not representative !
3520/// let result = hub.location().list("teamId", "workerEmail", 78)
3521/// .page_token("voluptua.")
3522/// .max_results(67)
3523/// .doit().await;
3524/// # }
3525/// ```
3526pub struct LocationListCall<'a, C>
3527where
3528 C: 'a,
3529{
3530 hub: &'a Coordinate<C>,
3531 _team_id: String,
3532 _worker_email: String,
3533 _start_timestamp_ms: u64,
3534 _page_token: Option<String>,
3535 _max_results: Option<u32>,
3536 _delegate: Option<&'a mut dyn common::Delegate>,
3537 _additional_params: HashMap<String, String>,
3538 _scopes: BTreeSet<String>,
3539}
3540
3541impl<'a, C> common::CallBuilder for LocationListCall<'a, C> {}
3542
3543impl<'a, C> LocationListCall<'a, C>
3544where
3545 C: common::Connector,
3546{
3547 /// Perform the operation you have build so far.
3548 pub async fn doit(mut self) -> common::Result<(common::Response, LocationListResponse)> {
3549 use std::borrow::Cow;
3550 use std::io::{Read, Seek};
3551
3552 use common::{url::Params, ToParts};
3553 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3554
3555 let mut dd = common::DefaultDelegate;
3556 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3557 dlg.begin(common::MethodInfo {
3558 id: "coordinate.location.list",
3559 http_method: hyper::Method::GET,
3560 });
3561
3562 for &field in [
3563 "alt",
3564 "teamId",
3565 "workerEmail",
3566 "startTimestampMs",
3567 "pageToken",
3568 "maxResults",
3569 ]
3570 .iter()
3571 {
3572 if self._additional_params.contains_key(field) {
3573 dlg.finished(false);
3574 return Err(common::Error::FieldClash(field));
3575 }
3576 }
3577
3578 let mut params = Params::with_capacity(7 + self._additional_params.len());
3579 params.push("teamId", self._team_id);
3580 params.push("workerEmail", self._worker_email);
3581 params.push("startTimestampMs", self._start_timestamp_ms.to_string());
3582 if let Some(value) = self._page_token.as_ref() {
3583 params.push("pageToken", value);
3584 }
3585 if let Some(value) = self._max_results.as_ref() {
3586 params.push("maxResults", value.to_string());
3587 }
3588
3589 params.extend(self._additional_params.iter());
3590
3591 params.push("alt", "json");
3592 let mut url = self.hub._base_url.clone() + "teams/{teamId}/workers/{workerEmail}/locations";
3593 if self._scopes.is_empty() {
3594 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3595 }
3596
3597 #[allow(clippy::single_element_loop)]
3598 for &(find_this, param_name) in
3599 [("{teamId}", "teamId"), ("{workerEmail}", "workerEmail")].iter()
3600 {
3601 url = params.uri_replacement(url, param_name, find_this, false);
3602 }
3603 {
3604 let to_remove = ["workerEmail", "teamId"];
3605 params.remove_params(&to_remove);
3606 }
3607
3608 let url = params.parse_with_url(&url);
3609
3610 loop {
3611 let token = match self
3612 .hub
3613 .auth
3614 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3615 .await
3616 {
3617 Ok(token) => token,
3618 Err(e) => match dlg.token(e) {
3619 Ok(token) => token,
3620 Err(e) => {
3621 dlg.finished(false);
3622 return Err(common::Error::MissingToken(e));
3623 }
3624 },
3625 };
3626 let mut req_result = {
3627 let client = &self.hub.client;
3628 dlg.pre_request();
3629 let mut req_builder = hyper::Request::builder()
3630 .method(hyper::Method::GET)
3631 .uri(url.as_str())
3632 .header(USER_AGENT, self.hub._user_agent.clone());
3633
3634 if let Some(token) = token.as_ref() {
3635 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3636 }
3637
3638 let request = req_builder
3639 .header(CONTENT_LENGTH, 0_u64)
3640 .body(common::to_body::<String>(None));
3641
3642 client.request(request.unwrap()).await
3643 };
3644
3645 match req_result {
3646 Err(err) => {
3647 if let common::Retry::After(d) = dlg.http_error(&err) {
3648 sleep(d).await;
3649 continue;
3650 }
3651 dlg.finished(false);
3652 return Err(common::Error::HttpError(err));
3653 }
3654 Ok(res) => {
3655 let (mut parts, body) = res.into_parts();
3656 let mut body = common::Body::new(body);
3657 if !parts.status.is_success() {
3658 let bytes = common::to_bytes(body).await.unwrap_or_default();
3659 let error = serde_json::from_str(&common::to_string(&bytes));
3660 let response = common::to_response(parts, bytes.into());
3661
3662 if let common::Retry::After(d) =
3663 dlg.http_failure(&response, error.as_ref().ok())
3664 {
3665 sleep(d).await;
3666 continue;
3667 }
3668
3669 dlg.finished(false);
3670
3671 return Err(match error {
3672 Ok(value) => common::Error::BadRequest(value),
3673 _ => common::Error::Failure(response),
3674 });
3675 }
3676 let response = {
3677 let bytes = common::to_bytes(body).await.unwrap_or_default();
3678 let encoded = common::to_string(&bytes);
3679 match serde_json::from_str(&encoded) {
3680 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3681 Err(error) => {
3682 dlg.response_json_decode_error(&encoded, &error);
3683 return Err(common::Error::JsonDecodeError(
3684 encoded.to_string(),
3685 error,
3686 ));
3687 }
3688 }
3689 };
3690
3691 dlg.finished(true);
3692 return Ok(response);
3693 }
3694 }
3695 }
3696 }
3697
3698 /// Team ID
3699 ///
3700 /// Sets the *team id* path property to the given value.
3701 ///
3702 /// Even though the property as already been set when instantiating this call,
3703 /// we provide this method for API completeness.
3704 pub fn team_id(mut self, new_value: &str) -> LocationListCall<'a, C> {
3705 self._team_id = new_value.to_string();
3706 self
3707 }
3708 /// Worker email address.
3709 ///
3710 /// Sets the *worker email* path property to the given value.
3711 ///
3712 /// Even though the property as already been set when instantiating this call,
3713 /// we provide this method for API completeness.
3714 pub fn worker_email(mut self, new_value: &str) -> LocationListCall<'a, C> {
3715 self._worker_email = new_value.to_string();
3716 self
3717 }
3718 /// Start timestamp in milliseconds since the epoch.
3719 ///
3720 /// Sets the *start timestamp ms* query property to the given value.
3721 ///
3722 /// Even though the property as already been set when instantiating this call,
3723 /// we provide this method for API completeness.
3724 pub fn start_timestamp_ms(mut self, new_value: u64) -> LocationListCall<'a, C> {
3725 self._start_timestamp_ms = new_value;
3726 self
3727 }
3728 /// Continuation token
3729 ///
3730 /// Sets the *page token* query property to the given value.
3731 pub fn page_token(mut self, new_value: &str) -> LocationListCall<'a, C> {
3732 self._page_token = Some(new_value.to_string());
3733 self
3734 }
3735 /// Maximum number of results to return in one page.
3736 ///
3737 /// Sets the *max results* query property to the given value.
3738 pub fn max_results(mut self, new_value: u32) -> LocationListCall<'a, C> {
3739 self._max_results = Some(new_value);
3740 self
3741 }
3742 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3743 /// while executing the actual API request.
3744 ///
3745 /// ````text
3746 /// It should be used to handle progress information, and to implement a certain level of resilience.
3747 /// ````
3748 ///
3749 /// Sets the *delegate* property to the given value.
3750 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LocationListCall<'a, C> {
3751 self._delegate = Some(new_value);
3752 self
3753 }
3754
3755 /// Set any additional parameter of the query string used in the request.
3756 /// It should be used to set parameters which are not yet available through their own
3757 /// setters.
3758 ///
3759 /// Please note that this method must not be used to set any of the known parameters
3760 /// which have their own setter method. If done anyway, the request will fail.
3761 ///
3762 /// # Additional Parameters
3763 ///
3764 /// * *alt* (query-string) - Data format for the response.
3765 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3766 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3767 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3768 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3769 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
3770 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3771 pub fn param<T>(mut self, name: T, value: T) -> LocationListCall<'a, C>
3772 where
3773 T: AsRef<str>,
3774 {
3775 self._additional_params
3776 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3777 self
3778 }
3779
3780 /// Identifies the authorization scope for the method you are building.
3781 ///
3782 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3783 /// [`Scope::Readonly`].
3784 ///
3785 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3786 /// tokens for more than one scope.
3787 ///
3788 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3789 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3790 /// sufficient, a read-write scope will do as well.
3791 pub fn add_scope<St>(mut self, scope: St) -> LocationListCall<'a, C>
3792 where
3793 St: AsRef<str>,
3794 {
3795 self._scopes.insert(String::from(scope.as_ref()));
3796 self
3797 }
3798 /// Identifies the authorization scope(s) for the method you are building.
3799 ///
3800 /// See [`Self::add_scope()`] for details.
3801 pub fn add_scopes<I, St>(mut self, scopes: I) -> LocationListCall<'a, C>
3802 where
3803 I: IntoIterator<Item = St>,
3804 St: AsRef<str>,
3805 {
3806 self._scopes
3807 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3808 self
3809 }
3810
3811 /// Removes all scopes, and no default scope will be used either.
3812 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3813 /// for details).
3814 pub fn clear_scopes(mut self) -> LocationListCall<'a, C> {
3815 self._scopes.clear();
3816 self
3817 }
3818}
3819
3820/// Retrieves the schedule for a job.
3821///
3822/// A builder for the *get* method supported by a *schedule* resource.
3823/// It is not used directly, but through a [`ScheduleMethods`] instance.
3824///
3825/// # Example
3826///
3827/// Instantiate a resource method builder
3828///
3829/// ```test_harness,no_run
3830/// # extern crate hyper;
3831/// # extern crate hyper_rustls;
3832/// # extern crate google_coordinate1 as coordinate1;
3833/// # async fn dox() {
3834/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3835///
3836/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3837/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3838/// # secret,
3839/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3840/// # ).build().await.unwrap();
3841///
3842/// # let client = hyper_util::client::legacy::Client::builder(
3843/// # hyper_util::rt::TokioExecutor::new()
3844/// # )
3845/// # .build(
3846/// # hyper_rustls::HttpsConnectorBuilder::new()
3847/// # .with_native_roots()
3848/// # .unwrap()
3849/// # .https_or_http()
3850/// # .enable_http1()
3851/// # .build()
3852/// # );
3853/// # let mut hub = Coordinate::new(client, auth);
3854/// // You can configure optional parameters by calling the respective setters at will, and
3855/// // execute the final call using `doit()`.
3856/// // Values shown here are possibly random and not representative !
3857/// let result = hub.schedule().get("teamId", 67)
3858/// .doit().await;
3859/// # }
3860/// ```
3861pub struct ScheduleGetCall<'a, C>
3862where
3863 C: 'a,
3864{
3865 hub: &'a Coordinate<C>,
3866 _team_id: String,
3867 _job_id: u64,
3868 _delegate: Option<&'a mut dyn common::Delegate>,
3869 _additional_params: HashMap<String, String>,
3870 _scopes: BTreeSet<String>,
3871}
3872
3873impl<'a, C> common::CallBuilder for ScheduleGetCall<'a, C> {}
3874
3875impl<'a, C> ScheduleGetCall<'a, C>
3876where
3877 C: common::Connector,
3878{
3879 /// Perform the operation you have build so far.
3880 pub async fn doit(mut self) -> common::Result<(common::Response, Schedule)> {
3881 use std::borrow::Cow;
3882 use std::io::{Read, Seek};
3883
3884 use common::{url::Params, ToParts};
3885 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3886
3887 let mut dd = common::DefaultDelegate;
3888 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3889 dlg.begin(common::MethodInfo {
3890 id: "coordinate.schedule.get",
3891 http_method: hyper::Method::GET,
3892 });
3893
3894 for &field in ["alt", "teamId", "jobId"].iter() {
3895 if self._additional_params.contains_key(field) {
3896 dlg.finished(false);
3897 return Err(common::Error::FieldClash(field));
3898 }
3899 }
3900
3901 let mut params = Params::with_capacity(4 + self._additional_params.len());
3902 params.push("teamId", self._team_id);
3903 params.push("jobId", self._job_id.to_string());
3904
3905 params.extend(self._additional_params.iter());
3906
3907 params.push("alt", "json");
3908 let mut url = self.hub._base_url.clone() + "teams/{teamId}/jobs/{jobId}/schedule";
3909 if self._scopes.is_empty() {
3910 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3911 }
3912
3913 #[allow(clippy::single_element_loop)]
3914 for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].iter() {
3915 url = params.uri_replacement(url, param_name, find_this, false);
3916 }
3917 {
3918 let to_remove = ["jobId", "teamId"];
3919 params.remove_params(&to_remove);
3920 }
3921
3922 let url = params.parse_with_url(&url);
3923
3924 loop {
3925 let token = match self
3926 .hub
3927 .auth
3928 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3929 .await
3930 {
3931 Ok(token) => token,
3932 Err(e) => match dlg.token(e) {
3933 Ok(token) => token,
3934 Err(e) => {
3935 dlg.finished(false);
3936 return Err(common::Error::MissingToken(e));
3937 }
3938 },
3939 };
3940 let mut req_result = {
3941 let client = &self.hub.client;
3942 dlg.pre_request();
3943 let mut req_builder = hyper::Request::builder()
3944 .method(hyper::Method::GET)
3945 .uri(url.as_str())
3946 .header(USER_AGENT, self.hub._user_agent.clone());
3947
3948 if let Some(token) = token.as_ref() {
3949 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3950 }
3951
3952 let request = req_builder
3953 .header(CONTENT_LENGTH, 0_u64)
3954 .body(common::to_body::<String>(None));
3955
3956 client.request(request.unwrap()).await
3957 };
3958
3959 match req_result {
3960 Err(err) => {
3961 if let common::Retry::After(d) = dlg.http_error(&err) {
3962 sleep(d).await;
3963 continue;
3964 }
3965 dlg.finished(false);
3966 return Err(common::Error::HttpError(err));
3967 }
3968 Ok(res) => {
3969 let (mut parts, body) = res.into_parts();
3970 let mut body = common::Body::new(body);
3971 if !parts.status.is_success() {
3972 let bytes = common::to_bytes(body).await.unwrap_or_default();
3973 let error = serde_json::from_str(&common::to_string(&bytes));
3974 let response = common::to_response(parts, bytes.into());
3975
3976 if let common::Retry::After(d) =
3977 dlg.http_failure(&response, error.as_ref().ok())
3978 {
3979 sleep(d).await;
3980 continue;
3981 }
3982
3983 dlg.finished(false);
3984
3985 return Err(match error {
3986 Ok(value) => common::Error::BadRequest(value),
3987 _ => common::Error::Failure(response),
3988 });
3989 }
3990 let response = {
3991 let bytes = common::to_bytes(body).await.unwrap_or_default();
3992 let encoded = common::to_string(&bytes);
3993 match serde_json::from_str(&encoded) {
3994 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3995 Err(error) => {
3996 dlg.response_json_decode_error(&encoded, &error);
3997 return Err(common::Error::JsonDecodeError(
3998 encoded.to_string(),
3999 error,
4000 ));
4001 }
4002 }
4003 };
4004
4005 dlg.finished(true);
4006 return Ok(response);
4007 }
4008 }
4009 }
4010 }
4011
4012 /// Team ID
4013 ///
4014 /// Sets the *team id* path property to the given value.
4015 ///
4016 /// Even though the property as already been set when instantiating this call,
4017 /// we provide this method for API completeness.
4018 pub fn team_id(mut self, new_value: &str) -> ScheduleGetCall<'a, C> {
4019 self._team_id = new_value.to_string();
4020 self
4021 }
4022 /// Job number
4023 ///
4024 /// Sets the *job id* path property to the given value.
4025 ///
4026 /// Even though the property as already been set when instantiating this call,
4027 /// we provide this method for API completeness.
4028 pub fn job_id(mut self, new_value: u64) -> ScheduleGetCall<'a, C> {
4029 self._job_id = new_value;
4030 self
4031 }
4032 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4033 /// while executing the actual API request.
4034 ///
4035 /// ````text
4036 /// It should be used to handle progress information, and to implement a certain level of resilience.
4037 /// ````
4038 ///
4039 /// Sets the *delegate* property to the given value.
4040 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ScheduleGetCall<'a, C> {
4041 self._delegate = Some(new_value);
4042 self
4043 }
4044
4045 /// Set any additional parameter of the query string used in the request.
4046 /// It should be used to set parameters which are not yet available through their own
4047 /// setters.
4048 ///
4049 /// Please note that this method must not be used to set any of the known parameters
4050 /// which have their own setter method. If done anyway, the request will fail.
4051 ///
4052 /// # Additional Parameters
4053 ///
4054 /// * *alt* (query-string) - Data format for the response.
4055 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4056 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4057 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4058 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4059 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
4060 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4061 pub fn param<T>(mut self, name: T, value: T) -> ScheduleGetCall<'a, C>
4062 where
4063 T: AsRef<str>,
4064 {
4065 self._additional_params
4066 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4067 self
4068 }
4069
4070 /// Identifies the authorization scope for the method you are building.
4071 ///
4072 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4073 /// [`Scope::Readonly`].
4074 ///
4075 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4076 /// tokens for more than one scope.
4077 ///
4078 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4079 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4080 /// sufficient, a read-write scope will do as well.
4081 pub fn add_scope<St>(mut self, scope: St) -> ScheduleGetCall<'a, C>
4082 where
4083 St: AsRef<str>,
4084 {
4085 self._scopes.insert(String::from(scope.as_ref()));
4086 self
4087 }
4088 /// Identifies the authorization scope(s) for the method you are building.
4089 ///
4090 /// See [`Self::add_scope()`] for details.
4091 pub fn add_scopes<I, St>(mut self, scopes: I) -> ScheduleGetCall<'a, C>
4092 where
4093 I: IntoIterator<Item = St>,
4094 St: AsRef<str>,
4095 {
4096 self._scopes
4097 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4098 self
4099 }
4100
4101 /// Removes all scopes, and no default scope will be used either.
4102 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4103 /// for details).
4104 pub fn clear_scopes(mut self) -> ScheduleGetCall<'a, C> {
4105 self._scopes.clear();
4106 self
4107 }
4108}
4109
4110/// Replaces the schedule of a job with the provided schedule. This method supports patch semantics.
4111///
4112/// A builder for the *patch* method supported by a *schedule* resource.
4113/// It is not used directly, but through a [`ScheduleMethods`] instance.
4114///
4115/// # Example
4116///
4117/// Instantiate a resource method builder
4118///
4119/// ```test_harness,no_run
4120/// # extern crate hyper;
4121/// # extern crate hyper_rustls;
4122/// # extern crate google_coordinate1 as coordinate1;
4123/// use coordinate1::api::Schedule;
4124/// # async fn dox() {
4125/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4126///
4127/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4129/// # secret,
4130/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4131/// # ).build().await.unwrap();
4132///
4133/// # let client = hyper_util::client::legacy::Client::builder(
4134/// # hyper_util::rt::TokioExecutor::new()
4135/// # )
4136/// # .build(
4137/// # hyper_rustls::HttpsConnectorBuilder::new()
4138/// # .with_native_roots()
4139/// # .unwrap()
4140/// # .https_or_http()
4141/// # .enable_http1()
4142/// # .build()
4143/// # );
4144/// # let mut hub = Coordinate::new(client, auth);
4145/// // As the method needs a request, you would usually fill it with the desired information
4146/// // into the respective structure. Some of the parts shown here might not be applicable !
4147/// // Values shown here are possibly random and not representative !
4148/// let mut req = Schedule::default();
4149///
4150/// // You can configure optional parameters by calling the respective setters at will, and
4151/// // execute the final call using `doit()`.
4152/// // Values shown here are possibly random and not representative !
4153/// let result = hub.schedule().patch(req, "teamId", 99)
4154/// .start_time(84)
4155/// .end_time(6)
4156/// .duration(95)
4157/// .all_day(true)
4158/// .doit().await;
4159/// # }
4160/// ```
4161pub struct SchedulePatchCall<'a, C>
4162where
4163 C: 'a,
4164{
4165 hub: &'a Coordinate<C>,
4166 _request: Schedule,
4167 _team_id: String,
4168 _job_id: u64,
4169 _start_time: Option<u64>,
4170 _end_time: Option<u64>,
4171 _duration: Option<u64>,
4172 _all_day: Option<bool>,
4173 _delegate: Option<&'a mut dyn common::Delegate>,
4174 _additional_params: HashMap<String, String>,
4175 _scopes: BTreeSet<String>,
4176}
4177
4178impl<'a, C> common::CallBuilder for SchedulePatchCall<'a, C> {}
4179
4180impl<'a, C> SchedulePatchCall<'a, C>
4181where
4182 C: common::Connector,
4183{
4184 /// Perform the operation you have build so far.
4185 pub async fn doit(mut self) -> common::Result<(common::Response, Schedule)> {
4186 use std::borrow::Cow;
4187 use std::io::{Read, Seek};
4188
4189 use common::{url::Params, ToParts};
4190 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4191
4192 let mut dd = common::DefaultDelegate;
4193 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4194 dlg.begin(common::MethodInfo {
4195 id: "coordinate.schedule.patch",
4196 http_method: hyper::Method::PATCH,
4197 });
4198
4199 for &field in [
4200 "alt",
4201 "teamId",
4202 "jobId",
4203 "startTime",
4204 "endTime",
4205 "duration",
4206 "allDay",
4207 ]
4208 .iter()
4209 {
4210 if self._additional_params.contains_key(field) {
4211 dlg.finished(false);
4212 return Err(common::Error::FieldClash(field));
4213 }
4214 }
4215
4216 let mut params = Params::with_capacity(9 + self._additional_params.len());
4217 params.push("teamId", self._team_id);
4218 params.push("jobId", self._job_id.to_string());
4219 if let Some(value) = self._start_time.as_ref() {
4220 params.push("startTime", value.to_string());
4221 }
4222 if let Some(value) = self._end_time.as_ref() {
4223 params.push("endTime", value.to_string());
4224 }
4225 if let Some(value) = self._duration.as_ref() {
4226 params.push("duration", value.to_string());
4227 }
4228 if let Some(value) = self._all_day.as_ref() {
4229 params.push("allDay", value.to_string());
4230 }
4231
4232 params.extend(self._additional_params.iter());
4233
4234 params.push("alt", "json");
4235 let mut url = self.hub._base_url.clone() + "teams/{teamId}/jobs/{jobId}/schedule";
4236 if self._scopes.is_empty() {
4237 self._scopes.insert(Scope::Full.as_ref().to_string());
4238 }
4239
4240 #[allow(clippy::single_element_loop)]
4241 for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].iter() {
4242 url = params.uri_replacement(url, param_name, find_this, false);
4243 }
4244 {
4245 let to_remove = ["jobId", "teamId"];
4246 params.remove_params(&to_remove);
4247 }
4248
4249 let url = params.parse_with_url(&url);
4250
4251 let mut json_mime_type = mime::APPLICATION_JSON;
4252 let mut request_value_reader = {
4253 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4254 common::remove_json_null_values(&mut value);
4255 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4256 serde_json::to_writer(&mut dst, &value).unwrap();
4257 dst
4258 };
4259 let request_size = request_value_reader
4260 .seek(std::io::SeekFrom::End(0))
4261 .unwrap();
4262 request_value_reader
4263 .seek(std::io::SeekFrom::Start(0))
4264 .unwrap();
4265
4266 loop {
4267 let token = match self
4268 .hub
4269 .auth
4270 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4271 .await
4272 {
4273 Ok(token) => token,
4274 Err(e) => match dlg.token(e) {
4275 Ok(token) => token,
4276 Err(e) => {
4277 dlg.finished(false);
4278 return Err(common::Error::MissingToken(e));
4279 }
4280 },
4281 };
4282 request_value_reader
4283 .seek(std::io::SeekFrom::Start(0))
4284 .unwrap();
4285 let mut req_result = {
4286 let client = &self.hub.client;
4287 dlg.pre_request();
4288 let mut req_builder = hyper::Request::builder()
4289 .method(hyper::Method::PATCH)
4290 .uri(url.as_str())
4291 .header(USER_AGENT, self.hub._user_agent.clone());
4292
4293 if let Some(token) = token.as_ref() {
4294 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4295 }
4296
4297 let request = req_builder
4298 .header(CONTENT_TYPE, json_mime_type.to_string())
4299 .header(CONTENT_LENGTH, request_size as u64)
4300 .body(common::to_body(
4301 request_value_reader.get_ref().clone().into(),
4302 ));
4303
4304 client.request(request.unwrap()).await
4305 };
4306
4307 match req_result {
4308 Err(err) => {
4309 if let common::Retry::After(d) = dlg.http_error(&err) {
4310 sleep(d).await;
4311 continue;
4312 }
4313 dlg.finished(false);
4314 return Err(common::Error::HttpError(err));
4315 }
4316 Ok(res) => {
4317 let (mut parts, body) = res.into_parts();
4318 let mut body = common::Body::new(body);
4319 if !parts.status.is_success() {
4320 let bytes = common::to_bytes(body).await.unwrap_or_default();
4321 let error = serde_json::from_str(&common::to_string(&bytes));
4322 let response = common::to_response(parts, bytes.into());
4323
4324 if let common::Retry::After(d) =
4325 dlg.http_failure(&response, error.as_ref().ok())
4326 {
4327 sleep(d).await;
4328 continue;
4329 }
4330
4331 dlg.finished(false);
4332
4333 return Err(match error {
4334 Ok(value) => common::Error::BadRequest(value),
4335 _ => common::Error::Failure(response),
4336 });
4337 }
4338 let response = {
4339 let bytes = common::to_bytes(body).await.unwrap_or_default();
4340 let encoded = common::to_string(&bytes);
4341 match serde_json::from_str(&encoded) {
4342 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4343 Err(error) => {
4344 dlg.response_json_decode_error(&encoded, &error);
4345 return Err(common::Error::JsonDecodeError(
4346 encoded.to_string(),
4347 error,
4348 ));
4349 }
4350 }
4351 };
4352
4353 dlg.finished(true);
4354 return Ok(response);
4355 }
4356 }
4357 }
4358 }
4359
4360 ///
4361 /// Sets the *request* property to the given value.
4362 ///
4363 /// Even though the property as already been set when instantiating this call,
4364 /// we provide this method for API completeness.
4365 pub fn request(mut self, new_value: Schedule) -> SchedulePatchCall<'a, C> {
4366 self._request = new_value;
4367 self
4368 }
4369 /// Team ID
4370 ///
4371 /// Sets the *team id* path property to the given value.
4372 ///
4373 /// Even though the property as already been set when instantiating this call,
4374 /// we provide this method for API completeness.
4375 pub fn team_id(mut self, new_value: &str) -> SchedulePatchCall<'a, C> {
4376 self._team_id = new_value.to_string();
4377 self
4378 }
4379 /// Job number
4380 ///
4381 /// Sets the *job id* path property to the given value.
4382 ///
4383 /// Even though the property as already been set when instantiating this call,
4384 /// we provide this method for API completeness.
4385 pub fn job_id(mut self, new_value: u64) -> SchedulePatchCall<'a, C> {
4386 self._job_id = new_value;
4387 self
4388 }
4389 /// Scheduled start time in milliseconds since epoch.
4390 ///
4391 /// Sets the *start time* query property to the given value.
4392 pub fn start_time(mut self, new_value: u64) -> SchedulePatchCall<'a, C> {
4393 self._start_time = Some(new_value);
4394 self
4395 }
4396 /// Scheduled end time in milliseconds since epoch.
4397 ///
4398 /// Sets the *end time* query property to the given value.
4399 pub fn end_time(mut self, new_value: u64) -> SchedulePatchCall<'a, C> {
4400 self._end_time = Some(new_value);
4401 self
4402 }
4403 /// Job duration in milliseconds.
4404 ///
4405 /// Sets the *duration* query property to the given value.
4406 pub fn duration(mut self, new_value: u64) -> SchedulePatchCall<'a, C> {
4407 self._duration = Some(new_value);
4408 self
4409 }
4410 /// Whether the job is scheduled for the whole day. Time of day in start/end times is ignored if this is true.
4411 ///
4412 /// Sets the *all day* query property to the given value.
4413 pub fn all_day(mut self, new_value: bool) -> SchedulePatchCall<'a, C> {
4414 self._all_day = Some(new_value);
4415 self
4416 }
4417 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4418 /// while executing the actual API request.
4419 ///
4420 /// ````text
4421 /// It should be used to handle progress information, and to implement a certain level of resilience.
4422 /// ````
4423 ///
4424 /// Sets the *delegate* property to the given value.
4425 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SchedulePatchCall<'a, C> {
4426 self._delegate = Some(new_value);
4427 self
4428 }
4429
4430 /// Set any additional parameter of the query string used in the request.
4431 /// It should be used to set parameters which are not yet available through their own
4432 /// setters.
4433 ///
4434 /// Please note that this method must not be used to set any of the known parameters
4435 /// which have their own setter method. If done anyway, the request will fail.
4436 ///
4437 /// # Additional Parameters
4438 ///
4439 /// * *alt* (query-string) - Data format for the response.
4440 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4441 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4442 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4443 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4444 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
4445 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4446 pub fn param<T>(mut self, name: T, value: T) -> SchedulePatchCall<'a, C>
4447 where
4448 T: AsRef<str>,
4449 {
4450 self._additional_params
4451 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4452 self
4453 }
4454
4455 /// Identifies the authorization scope for the method you are building.
4456 ///
4457 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4458 /// [`Scope::Full`].
4459 ///
4460 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4461 /// tokens for more than one scope.
4462 ///
4463 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4464 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4465 /// sufficient, a read-write scope will do as well.
4466 pub fn add_scope<St>(mut self, scope: St) -> SchedulePatchCall<'a, C>
4467 where
4468 St: AsRef<str>,
4469 {
4470 self._scopes.insert(String::from(scope.as_ref()));
4471 self
4472 }
4473 /// Identifies the authorization scope(s) for the method you are building.
4474 ///
4475 /// See [`Self::add_scope()`] for details.
4476 pub fn add_scopes<I, St>(mut self, scopes: I) -> SchedulePatchCall<'a, C>
4477 where
4478 I: IntoIterator<Item = St>,
4479 St: AsRef<str>,
4480 {
4481 self._scopes
4482 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4483 self
4484 }
4485
4486 /// Removes all scopes, and no default scope will be used either.
4487 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4488 /// for details).
4489 pub fn clear_scopes(mut self) -> SchedulePatchCall<'a, C> {
4490 self._scopes.clear();
4491 self
4492 }
4493}
4494
4495/// Replaces the schedule of a job with the provided schedule.
4496///
4497/// A builder for the *update* method supported by a *schedule* resource.
4498/// It is not used directly, but through a [`ScheduleMethods`] instance.
4499///
4500/// # Example
4501///
4502/// Instantiate a resource method builder
4503///
4504/// ```test_harness,no_run
4505/// # extern crate hyper;
4506/// # extern crate hyper_rustls;
4507/// # extern crate google_coordinate1 as coordinate1;
4508/// use coordinate1::api::Schedule;
4509/// # async fn dox() {
4510/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4511///
4512/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4513/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4514/// # secret,
4515/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4516/// # ).build().await.unwrap();
4517///
4518/// # let client = hyper_util::client::legacy::Client::builder(
4519/// # hyper_util::rt::TokioExecutor::new()
4520/// # )
4521/// # .build(
4522/// # hyper_rustls::HttpsConnectorBuilder::new()
4523/// # .with_native_roots()
4524/// # .unwrap()
4525/// # .https_or_http()
4526/// # .enable_http1()
4527/// # .build()
4528/// # );
4529/// # let mut hub = Coordinate::new(client, auth);
4530/// // As the method needs a request, you would usually fill it with the desired information
4531/// // into the respective structure. Some of the parts shown here might not be applicable !
4532/// // Values shown here are possibly random and not representative !
4533/// let mut req = Schedule::default();
4534///
4535/// // You can configure optional parameters by calling the respective setters at will, and
4536/// // execute the final call using `doit()`.
4537/// // Values shown here are possibly random and not representative !
4538/// let result = hub.schedule().update(req, "teamId", 94)
4539/// .start_time(74)
4540/// .end_time(58)
4541/// .duration(3)
4542/// .all_day(true)
4543/// .doit().await;
4544/// # }
4545/// ```
4546pub struct ScheduleUpdateCall<'a, C>
4547where
4548 C: 'a,
4549{
4550 hub: &'a Coordinate<C>,
4551 _request: Schedule,
4552 _team_id: String,
4553 _job_id: u64,
4554 _start_time: Option<u64>,
4555 _end_time: Option<u64>,
4556 _duration: Option<u64>,
4557 _all_day: Option<bool>,
4558 _delegate: Option<&'a mut dyn common::Delegate>,
4559 _additional_params: HashMap<String, String>,
4560 _scopes: BTreeSet<String>,
4561}
4562
4563impl<'a, C> common::CallBuilder for ScheduleUpdateCall<'a, C> {}
4564
4565impl<'a, C> ScheduleUpdateCall<'a, C>
4566where
4567 C: common::Connector,
4568{
4569 /// Perform the operation you have build so far.
4570 pub async fn doit(mut self) -> common::Result<(common::Response, Schedule)> {
4571 use std::borrow::Cow;
4572 use std::io::{Read, Seek};
4573
4574 use common::{url::Params, ToParts};
4575 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4576
4577 let mut dd = common::DefaultDelegate;
4578 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4579 dlg.begin(common::MethodInfo {
4580 id: "coordinate.schedule.update",
4581 http_method: hyper::Method::PUT,
4582 });
4583
4584 for &field in [
4585 "alt",
4586 "teamId",
4587 "jobId",
4588 "startTime",
4589 "endTime",
4590 "duration",
4591 "allDay",
4592 ]
4593 .iter()
4594 {
4595 if self._additional_params.contains_key(field) {
4596 dlg.finished(false);
4597 return Err(common::Error::FieldClash(field));
4598 }
4599 }
4600
4601 let mut params = Params::with_capacity(9 + self._additional_params.len());
4602 params.push("teamId", self._team_id);
4603 params.push("jobId", self._job_id.to_string());
4604 if let Some(value) = self._start_time.as_ref() {
4605 params.push("startTime", value.to_string());
4606 }
4607 if let Some(value) = self._end_time.as_ref() {
4608 params.push("endTime", value.to_string());
4609 }
4610 if let Some(value) = self._duration.as_ref() {
4611 params.push("duration", value.to_string());
4612 }
4613 if let Some(value) = self._all_day.as_ref() {
4614 params.push("allDay", value.to_string());
4615 }
4616
4617 params.extend(self._additional_params.iter());
4618
4619 params.push("alt", "json");
4620 let mut url = self.hub._base_url.clone() + "teams/{teamId}/jobs/{jobId}/schedule";
4621 if self._scopes.is_empty() {
4622 self._scopes.insert(Scope::Full.as_ref().to_string());
4623 }
4624
4625 #[allow(clippy::single_element_loop)]
4626 for &(find_this, param_name) in [("{teamId}", "teamId"), ("{jobId}", "jobId")].iter() {
4627 url = params.uri_replacement(url, param_name, find_this, false);
4628 }
4629 {
4630 let to_remove = ["jobId", "teamId"];
4631 params.remove_params(&to_remove);
4632 }
4633
4634 let url = params.parse_with_url(&url);
4635
4636 let mut json_mime_type = mime::APPLICATION_JSON;
4637 let mut request_value_reader = {
4638 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4639 common::remove_json_null_values(&mut value);
4640 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4641 serde_json::to_writer(&mut dst, &value).unwrap();
4642 dst
4643 };
4644 let request_size = request_value_reader
4645 .seek(std::io::SeekFrom::End(0))
4646 .unwrap();
4647 request_value_reader
4648 .seek(std::io::SeekFrom::Start(0))
4649 .unwrap();
4650
4651 loop {
4652 let token = match self
4653 .hub
4654 .auth
4655 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4656 .await
4657 {
4658 Ok(token) => token,
4659 Err(e) => match dlg.token(e) {
4660 Ok(token) => token,
4661 Err(e) => {
4662 dlg.finished(false);
4663 return Err(common::Error::MissingToken(e));
4664 }
4665 },
4666 };
4667 request_value_reader
4668 .seek(std::io::SeekFrom::Start(0))
4669 .unwrap();
4670 let mut req_result = {
4671 let client = &self.hub.client;
4672 dlg.pre_request();
4673 let mut req_builder = hyper::Request::builder()
4674 .method(hyper::Method::PUT)
4675 .uri(url.as_str())
4676 .header(USER_AGENT, self.hub._user_agent.clone());
4677
4678 if let Some(token) = token.as_ref() {
4679 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4680 }
4681
4682 let request = req_builder
4683 .header(CONTENT_TYPE, json_mime_type.to_string())
4684 .header(CONTENT_LENGTH, request_size as u64)
4685 .body(common::to_body(
4686 request_value_reader.get_ref().clone().into(),
4687 ));
4688
4689 client.request(request.unwrap()).await
4690 };
4691
4692 match req_result {
4693 Err(err) => {
4694 if let common::Retry::After(d) = dlg.http_error(&err) {
4695 sleep(d).await;
4696 continue;
4697 }
4698 dlg.finished(false);
4699 return Err(common::Error::HttpError(err));
4700 }
4701 Ok(res) => {
4702 let (mut parts, body) = res.into_parts();
4703 let mut body = common::Body::new(body);
4704 if !parts.status.is_success() {
4705 let bytes = common::to_bytes(body).await.unwrap_or_default();
4706 let error = serde_json::from_str(&common::to_string(&bytes));
4707 let response = common::to_response(parts, bytes.into());
4708
4709 if let common::Retry::After(d) =
4710 dlg.http_failure(&response, error.as_ref().ok())
4711 {
4712 sleep(d).await;
4713 continue;
4714 }
4715
4716 dlg.finished(false);
4717
4718 return Err(match error {
4719 Ok(value) => common::Error::BadRequest(value),
4720 _ => common::Error::Failure(response),
4721 });
4722 }
4723 let response = {
4724 let bytes = common::to_bytes(body).await.unwrap_or_default();
4725 let encoded = common::to_string(&bytes);
4726 match serde_json::from_str(&encoded) {
4727 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4728 Err(error) => {
4729 dlg.response_json_decode_error(&encoded, &error);
4730 return Err(common::Error::JsonDecodeError(
4731 encoded.to_string(),
4732 error,
4733 ));
4734 }
4735 }
4736 };
4737
4738 dlg.finished(true);
4739 return Ok(response);
4740 }
4741 }
4742 }
4743 }
4744
4745 ///
4746 /// Sets the *request* property to the given value.
4747 ///
4748 /// Even though the property as already been set when instantiating this call,
4749 /// we provide this method for API completeness.
4750 pub fn request(mut self, new_value: Schedule) -> ScheduleUpdateCall<'a, C> {
4751 self._request = new_value;
4752 self
4753 }
4754 /// Team ID
4755 ///
4756 /// Sets the *team id* path property to the given value.
4757 ///
4758 /// Even though the property as already been set when instantiating this call,
4759 /// we provide this method for API completeness.
4760 pub fn team_id(mut self, new_value: &str) -> ScheduleUpdateCall<'a, C> {
4761 self._team_id = new_value.to_string();
4762 self
4763 }
4764 /// Job number
4765 ///
4766 /// Sets the *job id* path property to the given value.
4767 ///
4768 /// Even though the property as already been set when instantiating this call,
4769 /// we provide this method for API completeness.
4770 pub fn job_id(mut self, new_value: u64) -> ScheduleUpdateCall<'a, C> {
4771 self._job_id = new_value;
4772 self
4773 }
4774 /// Scheduled start time in milliseconds since epoch.
4775 ///
4776 /// Sets the *start time* query property to the given value.
4777 pub fn start_time(mut self, new_value: u64) -> ScheduleUpdateCall<'a, C> {
4778 self._start_time = Some(new_value);
4779 self
4780 }
4781 /// Scheduled end time in milliseconds since epoch.
4782 ///
4783 /// Sets the *end time* query property to the given value.
4784 pub fn end_time(mut self, new_value: u64) -> ScheduleUpdateCall<'a, C> {
4785 self._end_time = Some(new_value);
4786 self
4787 }
4788 /// Job duration in milliseconds.
4789 ///
4790 /// Sets the *duration* query property to the given value.
4791 pub fn duration(mut self, new_value: u64) -> ScheduleUpdateCall<'a, C> {
4792 self._duration = Some(new_value);
4793 self
4794 }
4795 /// Whether the job is scheduled for the whole day. Time of day in start/end times is ignored if this is true.
4796 ///
4797 /// Sets the *all day* query property to the given value.
4798 pub fn all_day(mut self, new_value: bool) -> ScheduleUpdateCall<'a, C> {
4799 self._all_day = Some(new_value);
4800 self
4801 }
4802 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4803 /// while executing the actual API request.
4804 ///
4805 /// ````text
4806 /// It should be used to handle progress information, and to implement a certain level of resilience.
4807 /// ````
4808 ///
4809 /// Sets the *delegate* property to the given value.
4810 pub fn delegate(
4811 mut self,
4812 new_value: &'a mut dyn common::Delegate,
4813 ) -> ScheduleUpdateCall<'a, C> {
4814 self._delegate = Some(new_value);
4815 self
4816 }
4817
4818 /// Set any additional parameter of the query string used in the request.
4819 /// It should be used to set parameters which are not yet available through their own
4820 /// setters.
4821 ///
4822 /// Please note that this method must not be used to set any of the known parameters
4823 /// which have their own setter method. If done anyway, the request will fail.
4824 ///
4825 /// # Additional Parameters
4826 ///
4827 /// * *alt* (query-string) - Data format for the response.
4828 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4829 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4830 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4831 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4832 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
4833 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4834 pub fn param<T>(mut self, name: T, value: T) -> ScheduleUpdateCall<'a, C>
4835 where
4836 T: AsRef<str>,
4837 {
4838 self._additional_params
4839 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4840 self
4841 }
4842
4843 /// Identifies the authorization scope for the method you are building.
4844 ///
4845 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4846 /// [`Scope::Full`].
4847 ///
4848 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4849 /// tokens for more than one scope.
4850 ///
4851 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4852 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4853 /// sufficient, a read-write scope will do as well.
4854 pub fn add_scope<St>(mut self, scope: St) -> ScheduleUpdateCall<'a, C>
4855 where
4856 St: AsRef<str>,
4857 {
4858 self._scopes.insert(String::from(scope.as_ref()));
4859 self
4860 }
4861 /// Identifies the authorization scope(s) for the method you are building.
4862 ///
4863 /// See [`Self::add_scope()`] for details.
4864 pub fn add_scopes<I, St>(mut self, scopes: I) -> ScheduleUpdateCall<'a, C>
4865 where
4866 I: IntoIterator<Item = St>,
4867 St: AsRef<str>,
4868 {
4869 self._scopes
4870 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4871 self
4872 }
4873
4874 /// Removes all scopes, and no default scope will be used either.
4875 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4876 /// for details).
4877 pub fn clear_scopes(mut self) -> ScheduleUpdateCall<'a, C> {
4878 self._scopes.clear();
4879 self
4880 }
4881}
4882
4883/// Retrieves a list of teams for a user.
4884///
4885/// A builder for the *list* method supported by a *team* resource.
4886/// It is not used directly, but through a [`TeamMethods`] instance.
4887///
4888/// # Example
4889///
4890/// Instantiate a resource method builder
4891///
4892/// ```test_harness,no_run
4893/// # extern crate hyper;
4894/// # extern crate hyper_rustls;
4895/// # extern crate google_coordinate1 as coordinate1;
4896/// # async fn dox() {
4897/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4898///
4899/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4900/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4901/// # secret,
4902/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4903/// # ).build().await.unwrap();
4904///
4905/// # let client = hyper_util::client::legacy::Client::builder(
4906/// # hyper_util::rt::TokioExecutor::new()
4907/// # )
4908/// # .build(
4909/// # hyper_rustls::HttpsConnectorBuilder::new()
4910/// # .with_native_roots()
4911/// # .unwrap()
4912/// # .https_or_http()
4913/// # .enable_http1()
4914/// # .build()
4915/// # );
4916/// # let mut hub = Coordinate::new(client, auth);
4917/// // You can configure optional parameters by calling the respective setters at will, and
4918/// // execute the final call using `doit()`.
4919/// // Values shown here are possibly random and not representative !
4920/// let result = hub.team().list()
4921/// .worker(true)
4922/// .dispatcher(true)
4923/// .admin(true)
4924/// .doit().await;
4925/// # }
4926/// ```
4927pub struct TeamListCall<'a, C>
4928where
4929 C: 'a,
4930{
4931 hub: &'a Coordinate<C>,
4932 _worker: Option<bool>,
4933 _dispatcher: Option<bool>,
4934 _admin: Option<bool>,
4935 _delegate: Option<&'a mut dyn common::Delegate>,
4936 _additional_params: HashMap<String, String>,
4937 _scopes: BTreeSet<String>,
4938}
4939
4940impl<'a, C> common::CallBuilder for TeamListCall<'a, C> {}
4941
4942impl<'a, C> TeamListCall<'a, C>
4943where
4944 C: common::Connector,
4945{
4946 /// Perform the operation you have build so far.
4947 pub async fn doit(mut self) -> common::Result<(common::Response, TeamListResponse)> {
4948 use std::borrow::Cow;
4949 use std::io::{Read, Seek};
4950
4951 use common::{url::Params, ToParts};
4952 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4953
4954 let mut dd = common::DefaultDelegate;
4955 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4956 dlg.begin(common::MethodInfo {
4957 id: "coordinate.team.list",
4958 http_method: hyper::Method::GET,
4959 });
4960
4961 for &field in ["alt", "worker", "dispatcher", "admin"].iter() {
4962 if self._additional_params.contains_key(field) {
4963 dlg.finished(false);
4964 return Err(common::Error::FieldClash(field));
4965 }
4966 }
4967
4968 let mut params = Params::with_capacity(5 + self._additional_params.len());
4969 if let Some(value) = self._worker.as_ref() {
4970 params.push("worker", value.to_string());
4971 }
4972 if let Some(value) = self._dispatcher.as_ref() {
4973 params.push("dispatcher", value.to_string());
4974 }
4975 if let Some(value) = self._admin.as_ref() {
4976 params.push("admin", value.to_string());
4977 }
4978
4979 params.extend(self._additional_params.iter());
4980
4981 params.push("alt", "json");
4982 let mut url = self.hub._base_url.clone() + "teams";
4983 if self._scopes.is_empty() {
4984 self._scopes.insert(Scope::Readonly.as_ref().to_string());
4985 }
4986
4987 let url = params.parse_with_url(&url);
4988
4989 loop {
4990 let token = match self
4991 .hub
4992 .auth
4993 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4994 .await
4995 {
4996 Ok(token) => token,
4997 Err(e) => match dlg.token(e) {
4998 Ok(token) => token,
4999 Err(e) => {
5000 dlg.finished(false);
5001 return Err(common::Error::MissingToken(e));
5002 }
5003 },
5004 };
5005 let mut req_result = {
5006 let client = &self.hub.client;
5007 dlg.pre_request();
5008 let mut req_builder = hyper::Request::builder()
5009 .method(hyper::Method::GET)
5010 .uri(url.as_str())
5011 .header(USER_AGENT, self.hub._user_agent.clone());
5012
5013 if let Some(token) = token.as_ref() {
5014 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5015 }
5016
5017 let request = req_builder
5018 .header(CONTENT_LENGTH, 0_u64)
5019 .body(common::to_body::<String>(None));
5020
5021 client.request(request.unwrap()).await
5022 };
5023
5024 match req_result {
5025 Err(err) => {
5026 if let common::Retry::After(d) = dlg.http_error(&err) {
5027 sleep(d).await;
5028 continue;
5029 }
5030 dlg.finished(false);
5031 return Err(common::Error::HttpError(err));
5032 }
5033 Ok(res) => {
5034 let (mut parts, body) = res.into_parts();
5035 let mut body = common::Body::new(body);
5036 if !parts.status.is_success() {
5037 let bytes = common::to_bytes(body).await.unwrap_or_default();
5038 let error = serde_json::from_str(&common::to_string(&bytes));
5039 let response = common::to_response(parts, bytes.into());
5040
5041 if let common::Retry::After(d) =
5042 dlg.http_failure(&response, error.as_ref().ok())
5043 {
5044 sleep(d).await;
5045 continue;
5046 }
5047
5048 dlg.finished(false);
5049
5050 return Err(match error {
5051 Ok(value) => common::Error::BadRequest(value),
5052 _ => common::Error::Failure(response),
5053 });
5054 }
5055 let response = {
5056 let bytes = common::to_bytes(body).await.unwrap_or_default();
5057 let encoded = common::to_string(&bytes);
5058 match serde_json::from_str(&encoded) {
5059 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5060 Err(error) => {
5061 dlg.response_json_decode_error(&encoded, &error);
5062 return Err(common::Error::JsonDecodeError(
5063 encoded.to_string(),
5064 error,
5065 ));
5066 }
5067 }
5068 };
5069
5070 dlg.finished(true);
5071 return Ok(response);
5072 }
5073 }
5074 }
5075 }
5076
5077 /// Whether to include teams for which the user has the Worker role.
5078 ///
5079 /// Sets the *worker* query property to the given value.
5080 pub fn worker(mut self, new_value: bool) -> TeamListCall<'a, C> {
5081 self._worker = Some(new_value);
5082 self
5083 }
5084 /// Whether to include teams for which the user has the Dispatcher role.
5085 ///
5086 /// Sets the *dispatcher* query property to the given value.
5087 pub fn dispatcher(mut self, new_value: bool) -> TeamListCall<'a, C> {
5088 self._dispatcher = Some(new_value);
5089 self
5090 }
5091 /// Whether to include teams for which the user has the Admin role.
5092 ///
5093 /// Sets the *admin* query property to the given value.
5094 pub fn admin(mut self, new_value: bool) -> TeamListCall<'a, C> {
5095 self._admin = Some(new_value);
5096 self
5097 }
5098 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5099 /// while executing the actual API request.
5100 ///
5101 /// ````text
5102 /// It should be used to handle progress information, and to implement a certain level of resilience.
5103 /// ````
5104 ///
5105 /// Sets the *delegate* property to the given value.
5106 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TeamListCall<'a, C> {
5107 self._delegate = Some(new_value);
5108 self
5109 }
5110
5111 /// Set any additional parameter of the query string used in the request.
5112 /// It should be used to set parameters which are not yet available through their own
5113 /// setters.
5114 ///
5115 /// Please note that this method must not be used to set any of the known parameters
5116 /// which have their own setter method. If done anyway, the request will fail.
5117 ///
5118 /// # Additional Parameters
5119 ///
5120 /// * *alt* (query-string) - Data format for the response.
5121 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5122 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5123 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5124 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5125 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
5126 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
5127 pub fn param<T>(mut self, name: T, value: T) -> TeamListCall<'a, C>
5128 where
5129 T: AsRef<str>,
5130 {
5131 self._additional_params
5132 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5133 self
5134 }
5135
5136 /// Identifies the authorization scope for the method you are building.
5137 ///
5138 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5139 /// [`Scope::Readonly`].
5140 ///
5141 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5142 /// tokens for more than one scope.
5143 ///
5144 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5145 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5146 /// sufficient, a read-write scope will do as well.
5147 pub fn add_scope<St>(mut self, scope: St) -> TeamListCall<'a, C>
5148 where
5149 St: AsRef<str>,
5150 {
5151 self._scopes.insert(String::from(scope.as_ref()));
5152 self
5153 }
5154 /// Identifies the authorization scope(s) for the method you are building.
5155 ///
5156 /// See [`Self::add_scope()`] for details.
5157 pub fn add_scopes<I, St>(mut self, scopes: I) -> TeamListCall<'a, C>
5158 where
5159 I: IntoIterator<Item = St>,
5160 St: AsRef<str>,
5161 {
5162 self._scopes
5163 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5164 self
5165 }
5166
5167 /// Removes all scopes, and no default scope will be used either.
5168 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5169 /// for details).
5170 pub fn clear_scopes(mut self) -> TeamListCall<'a, C> {
5171 self._scopes.clear();
5172 self
5173 }
5174}
5175
5176/// Retrieves a list of workers in a team.
5177///
5178/// A builder for the *list* method supported by a *worker* resource.
5179/// It is not used directly, but through a [`WorkerMethods`] instance.
5180///
5181/// # Example
5182///
5183/// Instantiate a resource method builder
5184///
5185/// ```test_harness,no_run
5186/// # extern crate hyper;
5187/// # extern crate hyper_rustls;
5188/// # extern crate google_coordinate1 as coordinate1;
5189/// # async fn dox() {
5190/// # use coordinate1::{Coordinate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5191///
5192/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5193/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5194/// # secret,
5195/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5196/// # ).build().await.unwrap();
5197///
5198/// # let client = hyper_util::client::legacy::Client::builder(
5199/// # hyper_util::rt::TokioExecutor::new()
5200/// # )
5201/// # .build(
5202/// # hyper_rustls::HttpsConnectorBuilder::new()
5203/// # .with_native_roots()
5204/// # .unwrap()
5205/// # .https_or_http()
5206/// # .enable_http1()
5207/// # .build()
5208/// # );
5209/// # let mut hub = Coordinate::new(client, auth);
5210/// // You can configure optional parameters by calling the respective setters at will, and
5211/// // execute the final call using `doit()`.
5212/// // Values shown here are possibly random and not representative !
5213/// let result = hub.worker().list("teamId")
5214/// .doit().await;
5215/// # }
5216/// ```
5217pub struct WorkerListCall<'a, C>
5218where
5219 C: 'a,
5220{
5221 hub: &'a Coordinate<C>,
5222 _team_id: String,
5223 _delegate: Option<&'a mut dyn common::Delegate>,
5224 _additional_params: HashMap<String, String>,
5225 _scopes: BTreeSet<String>,
5226}
5227
5228impl<'a, C> common::CallBuilder for WorkerListCall<'a, C> {}
5229
5230impl<'a, C> WorkerListCall<'a, C>
5231where
5232 C: common::Connector,
5233{
5234 /// Perform the operation you have build so far.
5235 pub async fn doit(mut self) -> common::Result<(common::Response, WorkerListResponse)> {
5236 use std::borrow::Cow;
5237 use std::io::{Read, Seek};
5238
5239 use common::{url::Params, ToParts};
5240 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5241
5242 let mut dd = common::DefaultDelegate;
5243 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5244 dlg.begin(common::MethodInfo {
5245 id: "coordinate.worker.list",
5246 http_method: hyper::Method::GET,
5247 });
5248
5249 for &field in ["alt", "teamId"].iter() {
5250 if self._additional_params.contains_key(field) {
5251 dlg.finished(false);
5252 return Err(common::Error::FieldClash(field));
5253 }
5254 }
5255
5256 let mut params = Params::with_capacity(3 + self._additional_params.len());
5257 params.push("teamId", self._team_id);
5258
5259 params.extend(self._additional_params.iter());
5260
5261 params.push("alt", "json");
5262 let mut url = self.hub._base_url.clone() + "teams/{teamId}/workers";
5263 if self._scopes.is_empty() {
5264 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5265 }
5266
5267 #[allow(clippy::single_element_loop)]
5268 for &(find_this, param_name) in [("{teamId}", "teamId")].iter() {
5269 url = params.uri_replacement(url, param_name, find_this, false);
5270 }
5271 {
5272 let to_remove = ["teamId"];
5273 params.remove_params(&to_remove);
5274 }
5275
5276 let url = params.parse_with_url(&url);
5277
5278 loop {
5279 let token = match self
5280 .hub
5281 .auth
5282 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5283 .await
5284 {
5285 Ok(token) => token,
5286 Err(e) => match dlg.token(e) {
5287 Ok(token) => token,
5288 Err(e) => {
5289 dlg.finished(false);
5290 return Err(common::Error::MissingToken(e));
5291 }
5292 },
5293 };
5294 let mut req_result = {
5295 let client = &self.hub.client;
5296 dlg.pre_request();
5297 let mut req_builder = hyper::Request::builder()
5298 .method(hyper::Method::GET)
5299 .uri(url.as_str())
5300 .header(USER_AGENT, self.hub._user_agent.clone());
5301
5302 if let Some(token) = token.as_ref() {
5303 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5304 }
5305
5306 let request = req_builder
5307 .header(CONTENT_LENGTH, 0_u64)
5308 .body(common::to_body::<String>(None));
5309
5310 client.request(request.unwrap()).await
5311 };
5312
5313 match req_result {
5314 Err(err) => {
5315 if let common::Retry::After(d) = dlg.http_error(&err) {
5316 sleep(d).await;
5317 continue;
5318 }
5319 dlg.finished(false);
5320 return Err(common::Error::HttpError(err));
5321 }
5322 Ok(res) => {
5323 let (mut parts, body) = res.into_parts();
5324 let mut body = common::Body::new(body);
5325 if !parts.status.is_success() {
5326 let bytes = common::to_bytes(body).await.unwrap_or_default();
5327 let error = serde_json::from_str(&common::to_string(&bytes));
5328 let response = common::to_response(parts, bytes.into());
5329
5330 if let common::Retry::After(d) =
5331 dlg.http_failure(&response, error.as_ref().ok())
5332 {
5333 sleep(d).await;
5334 continue;
5335 }
5336
5337 dlg.finished(false);
5338
5339 return Err(match error {
5340 Ok(value) => common::Error::BadRequest(value),
5341 _ => common::Error::Failure(response),
5342 });
5343 }
5344 let response = {
5345 let bytes = common::to_bytes(body).await.unwrap_or_default();
5346 let encoded = common::to_string(&bytes);
5347 match serde_json::from_str(&encoded) {
5348 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5349 Err(error) => {
5350 dlg.response_json_decode_error(&encoded, &error);
5351 return Err(common::Error::JsonDecodeError(
5352 encoded.to_string(),
5353 error,
5354 ));
5355 }
5356 }
5357 };
5358
5359 dlg.finished(true);
5360 return Ok(response);
5361 }
5362 }
5363 }
5364 }
5365
5366 /// Team ID
5367 ///
5368 /// Sets the *team id* path property to the given value.
5369 ///
5370 /// Even though the property as already been set when instantiating this call,
5371 /// we provide this method for API completeness.
5372 pub fn team_id(mut self, new_value: &str) -> WorkerListCall<'a, C> {
5373 self._team_id = new_value.to_string();
5374 self
5375 }
5376 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5377 /// while executing the actual API request.
5378 ///
5379 /// ````text
5380 /// It should be used to handle progress information, and to implement a certain level of resilience.
5381 /// ````
5382 ///
5383 /// Sets the *delegate* property to the given value.
5384 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> WorkerListCall<'a, C> {
5385 self._delegate = Some(new_value);
5386 self
5387 }
5388
5389 /// Set any additional parameter of the query string used in the request.
5390 /// It should be used to set parameters which are not yet available through their own
5391 /// setters.
5392 ///
5393 /// Please note that this method must not be used to set any of the known parameters
5394 /// which have their own setter method. If done anyway, the request will fail.
5395 ///
5396 /// # Additional Parameters
5397 ///
5398 /// * *alt* (query-string) - Data format for the response.
5399 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5400 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5401 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5402 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5403 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
5404 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
5405 pub fn param<T>(mut self, name: T, value: T) -> WorkerListCall<'a, C>
5406 where
5407 T: AsRef<str>,
5408 {
5409 self._additional_params
5410 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5411 self
5412 }
5413
5414 /// Identifies the authorization scope for the method you are building.
5415 ///
5416 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5417 /// [`Scope::Readonly`].
5418 ///
5419 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5420 /// tokens for more than one scope.
5421 ///
5422 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5423 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5424 /// sufficient, a read-write scope will do as well.
5425 pub fn add_scope<St>(mut self, scope: St) -> WorkerListCall<'a, C>
5426 where
5427 St: AsRef<str>,
5428 {
5429 self._scopes.insert(String::from(scope.as_ref()));
5430 self
5431 }
5432 /// Identifies the authorization scope(s) for the method you are building.
5433 ///
5434 /// See [`Self::add_scope()`] for details.
5435 pub fn add_scopes<I, St>(mut self, scopes: I) -> WorkerListCall<'a, C>
5436 where
5437 I: IntoIterator<Item = St>,
5438 St: AsRef<str>,
5439 {
5440 self._scopes
5441 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5442 self
5443 }
5444
5445 /// Removes all scopes, and no default scope will be used either.
5446 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5447 /// for details).
5448 pub fn clear_scopes(mut self) -> WorkerListCall<'a, C> {
5449 self._scopes.clear();
5450 self
5451 }
5452}