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