google_people1/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 /// See, edit, download, and permanently delete your contacts
17 Contact,
18
19 /// See and download contact info automatically saved in your "Other contacts"
20 ContactOtherReadonly,
21
22 /// See and download your contacts
23 ContactReadonly,
24
25 /// See and download your organization's GSuite directory
26 DirectoryReadonly,
27
28 /// View your street addresses
29 UserAddressRead,
30
31 /// See and download your exact date of birth
32 UserBirthdayRead,
33
34 /// See and download all of your Google Account email addresses
35 UserEmailRead,
36
37 /// See your gender
38 UserGenderRead,
39
40 /// See your education, work history and org info
41 UserOrganizationRead,
42
43 /// See and download your personal phone numbers
44 UserPhonenumberRead,
45
46 /// See your primary Google Account email address
47 UserinfoEmail,
48
49 /// See your personal info, including any personal info you've made publicly available
50 UserinfoProfile,
51}
52
53impl AsRef<str> for Scope {
54 fn as_ref(&self) -> &str {
55 match *self {
56 Scope::Contact => "https://www.googleapis.com/auth/contacts",
57 Scope::ContactOtherReadonly => {
58 "https://www.googleapis.com/auth/contacts.other.readonly"
59 }
60 Scope::ContactReadonly => "https://www.googleapis.com/auth/contacts.readonly",
61 Scope::DirectoryReadonly => "https://www.googleapis.com/auth/directory.readonly",
62 Scope::UserAddressRead => "https://www.googleapis.com/auth/user.addresses.read",
63 Scope::UserBirthdayRead => "https://www.googleapis.com/auth/user.birthday.read",
64 Scope::UserEmailRead => "https://www.googleapis.com/auth/user.emails.read",
65 Scope::UserGenderRead => "https://www.googleapis.com/auth/user.gender.read",
66 Scope::UserOrganizationRead => "https://www.googleapis.com/auth/user.organization.read",
67 Scope::UserPhonenumberRead => "https://www.googleapis.com/auth/user.phonenumbers.read",
68 Scope::UserinfoEmail => "https://www.googleapis.com/auth/userinfo.email",
69 Scope::UserinfoProfile => "https://www.googleapis.com/auth/userinfo.profile",
70 }
71 }
72}
73
74#[allow(clippy::derivable_impls)]
75impl Default for Scope {
76 fn default() -> Scope {
77 Scope::ContactOtherReadonly
78 }
79}
80
81// ########
82// HUB ###
83// ######
84
85/// Central instance to access all PeopleService related resource activities
86///
87/// # Examples
88///
89/// Instantiate a new hub
90///
91/// ```test_harness,no_run
92/// extern crate hyper;
93/// extern crate hyper_rustls;
94/// extern crate google_people1 as people1;
95/// use people1::{Result, Error};
96/// # async fn dox() {
97/// use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
98///
99/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
100/// // `client_secret`, among other things.
101/// let secret: yup_oauth2::ApplicationSecret = Default::default();
102/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
103/// // unless you replace `None` with the desired Flow.
104/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
105/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
106/// // retrieve them from storage.
107/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
108/// secret,
109/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
110/// ).build().await.unwrap();
111///
112/// let client = hyper_util::client::legacy::Client::builder(
113/// hyper_util::rt::TokioExecutor::new()
114/// )
115/// .build(
116/// hyper_rustls::HttpsConnectorBuilder::new()
117/// .with_native_roots()
118/// .unwrap()
119/// .https_or_http()
120/// .enable_http1()
121/// .build()
122/// );
123/// let mut hub = PeopleService::new(client, auth);
124/// // You can configure optional parameters by calling the respective setters at will, and
125/// // execute the final call using `doit()`.
126/// // Values shown here are possibly random and not representative !
127/// let result = hub.contact_groups().list()
128/// .sync_token("sanctus")
129/// .page_token("sed")
130/// .page_size(-2)
131/// .group_fields(FieldMask::new::<&str>(&[]))
132/// .doit().await;
133///
134/// match result {
135/// Err(e) => match e {
136/// // The Error enum provides details about what exactly happened.
137/// // You can also just use its `Debug`, `Display` or `Error` traits
138/// Error::HttpError(_)
139/// |Error::Io(_)
140/// |Error::MissingAPIKey
141/// |Error::MissingToken(_)
142/// |Error::Cancelled
143/// |Error::UploadSizeLimitExceeded(_, _)
144/// |Error::Failure(_)
145/// |Error::BadRequest(_)
146/// |Error::FieldClash(_)
147/// |Error::JsonDecodeError(_, _) => println!("{}", e),
148/// },
149/// Ok(res) => println!("Success: {:?}", res),
150/// }
151/// # }
152/// ```
153#[derive(Clone)]
154pub struct PeopleService<C> {
155 pub client: common::Client<C>,
156 pub auth: Box<dyn common::GetToken>,
157 _user_agent: String,
158 _base_url: String,
159 _root_url: String,
160}
161
162impl<C> common::Hub for PeopleService<C> {}
163
164impl<'a, C> PeopleService<C> {
165 pub fn new<A: 'static + common::GetToken>(
166 client: common::Client<C>,
167 auth: A,
168 ) -> PeopleService<C> {
169 PeopleService {
170 client,
171 auth: Box::new(auth),
172 _user_agent: "google-api-rust-client/6.0.0".to_string(),
173 _base_url: "https://people.googleapis.com/".to_string(),
174 _root_url: "https://people.googleapis.com/".to_string(),
175 }
176 }
177
178 pub fn contact_groups(&'a self) -> ContactGroupMethods<'a, C> {
179 ContactGroupMethods { hub: self }
180 }
181 pub fn other_contacts(&'a self) -> OtherContactMethods<'a, C> {
182 OtherContactMethods { hub: self }
183 }
184 pub fn people(&'a self) -> PersonMethods<'a, C> {
185 PersonMethods { hub: self }
186 }
187
188 /// Set the user-agent header field to use in all requests to the server.
189 /// It defaults to `google-api-rust-client/6.0.0`.
190 ///
191 /// Returns the previously set user-agent.
192 pub fn user_agent(&mut self, agent_name: String) -> String {
193 std::mem::replace(&mut self._user_agent, agent_name)
194 }
195
196 /// Set the base url to use in all requests to the server.
197 /// It defaults to `https://people.googleapis.com/`.
198 ///
199 /// Returns the previously set base url.
200 pub fn base_url(&mut self, new_base_url: String) -> String {
201 std::mem::replace(&mut self._base_url, new_base_url)
202 }
203
204 /// Set the root url to use in all requests to the server.
205 /// It defaults to `https://people.googleapis.com/`.
206 ///
207 /// Returns the previously set root url.
208 pub fn root_url(&mut self, new_root_url: String) -> String {
209 std::mem::replace(&mut self._root_url, new_root_url)
210 }
211}
212
213// ############
214// SCHEMAS ###
215// ##########
216/// A person's physical address. May be a P.O. box or street address. All fields are optional.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct Address {
224 /// The city of the address.
225 pub city: Option<String>,
226 /// The country of the address.
227 pub country: Option<String>,
228 /// The [ISO 3166-1 alpha-2](http://www.iso.org/iso/country_codes.htm) country code of the address.
229 #[serde(rename = "countryCode")]
230 pub country_code: Option<String>,
231 /// The extended address of the address; for example, the apartment number.
232 #[serde(rename = "extendedAddress")]
233 pub extended_address: Option<String>,
234 /// Output only. The type of the address translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
235 #[serde(rename = "formattedType")]
236 pub formatted_type: Option<String>,
237 /// The unstructured value of the address. If this is not set by the user it will be automatically constructed from structured values.
238 #[serde(rename = "formattedValue")]
239 pub formatted_value: Option<String>,
240 /// Metadata about the address.
241 pub metadata: Option<FieldMetadata>,
242 /// The P.O. box of the address.
243 #[serde(rename = "poBox")]
244 pub po_box: Option<String>,
245 /// The postal code of the address.
246 #[serde(rename = "postalCode")]
247 pub postal_code: Option<String>,
248 /// The region of the address; for example, the state or province.
249 pub region: Option<String>,
250 /// The street address.
251 #[serde(rename = "streetAddress")]
252 pub street_address: Option<String>,
253 /// The type of the address. The type can be custom or one of these predefined values: * `home` * `work` * `other`
254 #[serde(rename = "type")]
255 pub type_: Option<String>,
256}
257
258impl common::Part for Address {}
259
260/// A person's age range.
261///
262/// This type is not used in any activity, and only used as *part* of another schema.
263///
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct AgeRangeType {
268 /// The age range.
269 #[serde(rename = "ageRange")]
270 pub age_range: Option<String>,
271 /// Metadata about the age range.
272 pub metadata: Option<FieldMetadata>,
273}
274
275impl common::Part for AgeRangeType {}
276
277/// A request to create a batch of contacts.
278///
279/// # Activities
280///
281/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
282/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
283///
284/// * [batch create contacts people](PersonBatchCreateContactCall) (request)
285#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
286#[serde_with::serde_as]
287#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
288pub struct BatchCreateContactsRequest {
289 /// Required. The contact to create. Allows up to 200 contacts in a single request.
290 pub contacts: Option<Vec<ContactToCreate>>,
291 /// Required. A field mask to restrict which fields on each person are returned in the response. Multiple fields can be specified by separating them with commas. If read mask is left empty, the post-mutate-get is skipped and no data will be returned in the response. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
292 #[serde(rename = "readMask")]
293 pub read_mask: Option<common::FieldMask>,
294 /// Optional. A mask of what source types to return in the post mutate read. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
295 pub sources: Option<Vec<String>>,
296}
297
298impl common::RequestValue for BatchCreateContactsRequest {}
299
300/// If not successful, returns BatchCreateContactsErrorDetails which contains a list of errors for each invalid contact. The response to a request to create a batch of contacts.
301///
302/// # Activities
303///
304/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
305/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
306///
307/// * [batch create contacts people](PersonBatchCreateContactCall) (response)
308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
309#[serde_with::serde_as]
310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
311pub struct BatchCreateContactsResponse {
312 /// The contacts that were created, unless the request `read_mask` is empty.
313 #[serde(rename = "createdPeople")]
314 pub created_people: Option<Vec<PersonResponse>>,
315}
316
317impl common::ResponseResult for BatchCreateContactsResponse {}
318
319/// A request to delete a batch of existing contacts.
320///
321/// # Activities
322///
323/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
324/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
325///
326/// * [batch delete contacts people](PersonBatchDeleteContactCall) (request)
327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
328#[serde_with::serde_as]
329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
330pub struct BatchDeleteContactsRequest {
331 /// Required. The resource names of the contact to delete. It's repeatable. Allows up to 500 resource names in a single request.
332 #[serde(rename = "resourceNames")]
333 pub resource_names: Option<Vec<String>>,
334}
335
336impl common::RequestValue for BatchDeleteContactsRequest {}
337
338/// The response to a batch get contact groups request.
339///
340/// # Activities
341///
342/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
343/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
344///
345/// * [batch get contact groups](ContactGroupBatchGetCall) (response)
346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
347#[serde_with::serde_as]
348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
349pub struct BatchGetContactGroupsResponse {
350 /// The list of responses for each requested contact group resource.
351 pub responses: Option<Vec<ContactGroupResponse>>,
352}
353
354impl common::ResponseResult for BatchGetContactGroupsResponse {}
355
356/// A request to update a batch of contacts.
357///
358/// # Activities
359///
360/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
361/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
362///
363/// * [batch update contacts people](PersonBatchUpdateContactCall) (request)
364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
365#[serde_with::serde_as]
366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
367pub struct BatchUpdateContactsRequest {
368 /// Required. A map of resource names to the person data to be updated. Allows up to 200 contacts in a single request.
369 pub contacts: Option<HashMap<String, Person>>,
370 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. If read mask is left empty, the post-mutate-get is skipped and no data will be returned in the response. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
371 #[serde(rename = "readMask")]
372 pub read_mask: Option<common::FieldMask>,
373 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
374 pub sources: Option<Vec<String>>,
375 /// Required. A field mask to restrict which fields on the person are updated. Multiple fields can be specified by separating them with commas. All specified fields will be replaced, or cleared if left empty for each person. Valid values are: * addresses * biographies * birthdays * calendarUrls * clientData * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * relations * sipAddresses * urls * userDefined
376 #[serde(rename = "updateMask")]
377 pub update_mask: Option<common::FieldMask>,
378}
379
380impl common::RequestValue for BatchUpdateContactsRequest {}
381
382/// If not successful, returns BatchUpdateContactsErrorDetails, a list of errors corresponding to each contact. The response to a request to update a batch of contacts.
383///
384/// # Activities
385///
386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
388///
389/// * [batch update contacts people](PersonBatchUpdateContactCall) (response)
390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
391#[serde_with::serde_as]
392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
393pub struct BatchUpdateContactsResponse {
394 /// A map of resource names to the contacts that were updated, unless the request `read_mask` is empty.
395 #[serde(rename = "updateResult")]
396 pub update_result: Option<HashMap<String, PersonResponse>>,
397}
398
399impl common::ResponseResult for BatchUpdateContactsResponse {}
400
401/// A person's short biography.
402///
403/// This type is not used in any activity, and only used as *part* of another schema.
404///
405#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
406#[serde_with::serde_as]
407#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
408pub struct Biography {
409 /// The content type of the biography.
410 #[serde(rename = "contentType")]
411 pub content_type: Option<String>,
412 /// Metadata about the biography.
413 pub metadata: Option<FieldMetadata>,
414 /// The short biography.
415 pub value: Option<String>,
416}
417
418impl common::Part for Biography {}
419
420/// A person's birthday. At least one of the `date` and `text` fields are specified. The `date` and `text` fields typically represent the same date, but are not guaranteed to. Clients should always set the `date` field when mutating birthdays.
421///
422/// This type is not used in any activity, and only used as *part* of another schema.
423///
424#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
425#[serde_with::serde_as]
426#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
427pub struct Birthday {
428 /// The structured date of the birthday.
429 pub date: Option<Date>,
430 /// Metadata about the birthday.
431 pub metadata: Option<FieldMetadata>,
432 /// Prefer to use the `date` field if set. A free-form string representing the user's birthday. This value is not validated.
433 pub text: Option<String>,
434}
435
436impl common::Part for Birthday {}
437
438/// **DEPRECATED**: No data will be returned A person's bragging rights.
439///
440/// This type is not used in any activity, and only used as *part* of another schema.
441///
442#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
443#[serde_with::serde_as]
444#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
445pub struct BraggingRights {
446 /// Metadata about the bragging rights.
447 pub metadata: Option<FieldMetadata>,
448 /// The bragging rights; for example, `climbed mount everest`.
449 pub value: Option<String>,
450}
451
452impl common::Part for BraggingRights {}
453
454/// A person's calendar URL.
455///
456/// This type is not used in any activity, and only used as *part* of another schema.
457///
458#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
459#[serde_with::serde_as]
460#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
461pub struct CalendarUrl {
462 /// Output only. The type of the calendar URL translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
463 #[serde(rename = "formattedType")]
464 pub formatted_type: Option<String>,
465 /// Metadata about the calendar URL.
466 pub metadata: Option<FieldMetadata>,
467 /// The type of the calendar URL. The type can be custom or one of these predefined values: * `home` * `freeBusy` * `work`
468 #[serde(rename = "type")]
469 pub type_: Option<String>,
470 /// The calendar URL.
471 pub url: Option<String>,
472}
473
474impl common::Part for CalendarUrl {}
475
476/// Arbitrary client data that is populated by clients. Duplicate keys and values are allowed.
477///
478/// This type is not used in any activity, and only used as *part* of another schema.
479///
480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
481#[serde_with::serde_as]
482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
483pub struct ClientData {
484 /// The client specified key of the client data.
485 pub key: Option<String>,
486 /// Metadata about the client data.
487 pub metadata: Option<FieldMetadata>,
488 /// The client specified value of the client data.
489 pub value: Option<String>,
490}
491
492impl common::Part for ClientData {}
493
494/// A contact group.
495///
496/// # Activities
497///
498/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
499/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
500///
501/// * [members modify contact groups](ContactGroupMemberModifyCall) (none)
502/// * [batch get contact groups](ContactGroupBatchGetCall) (none)
503/// * [create contact groups](ContactGroupCreateCall) (response)
504/// * [delete contact groups](ContactGroupDeleteCall) (none)
505/// * [get contact groups](ContactGroupGetCall) (response)
506/// * [list contact groups](ContactGroupListCall) (none)
507/// * [update contact groups](ContactGroupUpdateCall) (response)
508#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
509#[serde_with::serde_as]
510#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
511pub struct ContactGroup {
512 /// The group's client data.
513 #[serde(rename = "clientData")]
514 pub client_data: Option<Vec<GroupClientData>>,
515 /// The [HTTP entity tag](https://en.wikipedia.org/wiki/HTTP_ETag) of the resource. Used for web cache validation.
516 pub etag: Option<String>,
517 /// Output only. The name translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale for system groups names. Group names set by the owner are the same as name.
518 #[serde(rename = "formattedName")]
519 pub formatted_name: Option<String>,
520 /// Output only. The contact group type.
521 #[serde(rename = "groupType")]
522 pub group_type: Option<String>,
523 /// Output only. The total number of contacts in the group irrespective of max members in specified in the request.
524 #[serde(rename = "memberCount")]
525 pub member_count: Option<i32>,
526 /// Output only. The list of contact person resource names that are members of the contact group. The field is only populated for GET requests and will only return as many members as `maxMembers` in the get request.
527 #[serde(rename = "memberResourceNames")]
528 pub member_resource_names: Option<Vec<String>>,
529 /// Output only. Metadata about the contact group.
530 pub metadata: Option<ContactGroupMetadata>,
531 /// The contact group name set by the group owner or a system provided name for system groups. For [`contactGroups.create`](https://developers.google.com/people/api/rest/v1/contactGroups/create) or [`contactGroups.update`](https://developers.google.com/people/api/rest/v1/contactGroups/update) the name must be unique to the users contact groups. Attempting to create a group with a duplicate name will return a HTTP 409 error.
532 pub name: Option<String>,
533 /// The resource name for the contact group, assigned by the server. An ASCII string, in the form of `contactGroups/{contact_group_id}`.
534 #[serde(rename = "resourceName")]
535 pub resource_name: Option<String>,
536}
537
538impl common::Resource for ContactGroup {}
539impl common::ResponseResult for ContactGroup {}
540
541/// A Google contact group membership.
542///
543/// This type is not used in any activity, and only used as *part* of another schema.
544///
545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
546#[serde_with::serde_as]
547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
548pub struct ContactGroupMembership {
549 /// Output only. The contact group ID for the contact group membership.
550 #[serde(rename = "contactGroupId")]
551 pub contact_group_id: Option<String>,
552 /// The resource name for the contact group, assigned by the server. An ASCII string, in the form of `contactGroups/{contact_group_id}`. Only contact_group_resource_name can be used for modifying memberships. Any contact group membership can be removed, but only user group or "myContacts" or "starred" system groups memberships can be added. A contact must always have at least one contact group membership.
553 #[serde(rename = "contactGroupResourceName")]
554 pub contact_group_resource_name: Option<String>,
555}
556
557impl common::Part for ContactGroupMembership {}
558
559/// The metadata about a contact group.
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 ContactGroupMetadata {
567 /// Output only. True if the contact group resource has been deleted. Populated only for [`ListContactGroups`](https://developers.google.com/people/api/rest/v1/contactgroups/list) requests that include a sync token.
568 pub deleted: Option<bool>,
569 /// Output only. The time the group was last updated.
570 #[serde(rename = "updateTime")]
571 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
572}
573
574impl common::Part for ContactGroupMetadata {}
575
576/// The response for a specific contact group.
577///
578/// This type is not used in any activity, and only used as *part* of another schema.
579///
580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
581#[serde_with::serde_as]
582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
583pub struct ContactGroupResponse {
584 /// The contact group.
585 #[serde(rename = "contactGroup")]
586 pub contact_group: Option<ContactGroup>,
587 /// The original requested resource name.
588 #[serde(rename = "requestedResourceName")]
589 pub requested_resource_name: Option<String>,
590 /// The status of the response.
591 pub status: Option<Status>,
592}
593
594impl common::Part for ContactGroupResponse {}
595
596/// A wrapper that contains the person data to populate a newly created source.
597///
598/// This type is not used in any activity, and only used as *part* of another schema.
599///
600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
601#[serde_with::serde_as]
602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
603pub struct ContactToCreate {
604 /// Required. The person data to populate a newly created source.
605 #[serde(rename = "contactPerson")]
606 pub contact_person: Option<Person>,
607}
608
609impl common::Part for ContactToCreate {}
610
611/// A request to copy an “Other contact” to my contacts group.
612///
613/// # Activities
614///
615/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
616/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
617///
618/// * [copy other contact to my contacts group other contacts](OtherContactCopyOtherContactToMyContactsGroupCall) (request)
619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
620#[serde_with::serde_as]
621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
622pub struct CopyOtherContactToMyContactsGroupRequest {
623 /// Required. A field mask to restrict which fields are copied into the new contact. Valid values are: * emailAddresses * names * phoneNumbers
624 #[serde(rename = "copyMask")]
625 pub copy_mask: Option<common::FieldMask>,
626 /// Optional. A field mask to restrict which fields on the person are returned. Multiple fields can be specified by separating them with commas. Defaults to the copy mask with metadata and membership fields if not set. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
627 #[serde(rename = "readMask")]
628 pub read_mask: Option<common::FieldMask>,
629 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
630 pub sources: Option<Vec<String>>,
631}
632
633impl common::RequestValue for CopyOtherContactToMyContactsGroupRequest {}
634
635/// A person's cover photo. A large image shown on the person's profile page that represents who they are or what they care about.
636///
637/// This type is not used in any activity, and only used as *part* of another schema.
638///
639#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
640#[serde_with::serde_as]
641#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
642pub struct CoverPhoto {
643 /// True if the cover photo is the default cover photo; false if the cover photo is a user-provided cover photo.
644 pub default: Option<bool>,
645 /// Metadata about the cover photo.
646 pub metadata: Option<FieldMetadata>,
647 /// The URL of the cover photo.
648 pub url: Option<String>,
649}
650
651impl common::Part for CoverPhoto {}
652
653/// A request to create a new contact group.
654///
655/// # Activities
656///
657/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
658/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
659///
660/// * [create contact groups](ContactGroupCreateCall) (request)
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct CreateContactGroupRequest {
665 /// Required. The contact group to create.
666 #[serde(rename = "contactGroup")]
667 pub contact_group: Option<ContactGroup>,
668 /// Optional. A field mask to restrict which fields on the group are returned. Defaults to `metadata`, `groupType`, and `name` if not set or set to empty. Valid fields are: * clientData * groupType * metadata * name
669 #[serde(rename = "readGroupFields")]
670 pub read_group_fields: Option<common::FieldMask>,
671}
672
673impl common::RequestValue for CreateContactGroupRequest {}
674
675/// Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
676///
677/// This type is not used in any activity, and only used as *part* of another schema.
678///
679#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
680#[serde_with::serde_as]
681#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
682pub struct Date {
683 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
684 pub day: Option<i32>,
685 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
686 pub month: Option<i32>,
687 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
688 pub year: Option<i32>,
689}
690
691impl common::Part for Date {}
692
693/// The response for deleting a contact’s photo.
694///
695/// # Activities
696///
697/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
698/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
699///
700/// * [delete contact photo people](PersonDeleteContactPhotoCall) (response)
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct DeleteContactPhotoResponse {
705 /// The updated person, if person_fields is set in the DeleteContactPhotoRequest; otherwise this will be unset.
706 pub person: Option<Person>,
707}
708
709impl common::ResponseResult for DeleteContactPhotoResponse {}
710
711/// A Google Workspace Domain membership.
712///
713/// This type is not used in any activity, and only used as *part* of another schema.
714///
715#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
716#[serde_with::serde_as]
717#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
718pub struct DomainMembership {
719 /// True if the person is in the viewer's Google Workspace domain.
720 #[serde(rename = "inViewerDomain")]
721 pub in_viewer_domain: Option<bool>,
722}
723
724impl common::Part for DomainMembership {}
725
726/// A person's email address.
727///
728/// This type is not used in any activity, and only used as *part* of another schema.
729///
730#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
731#[serde_with::serde_as]
732#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
733pub struct EmailAddress {
734 /// The display name of the email.
735 #[serde(rename = "displayName")]
736 pub display_name: Option<String>,
737 /// Output only. The type of the email address translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
738 #[serde(rename = "formattedType")]
739 pub formatted_type: Option<String>,
740 /// Metadata about the email address.
741 pub metadata: Option<FieldMetadata>,
742 /// The type of the email address. The type can be custom or one of these predefined values: * `home` * `work` * `other`
743 #[serde(rename = "type")]
744 pub type_: Option<String>,
745 /// The email address.
746 pub value: Option<String>,
747}
748
749impl common::Part for EmailAddress {}
750
751/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
752///
753/// # Activities
754///
755/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
756/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
757///
758/// * [delete contact groups](ContactGroupDeleteCall) (response)
759/// * [batch delete contacts people](PersonBatchDeleteContactCall) (response)
760/// * [delete contact people](PersonDeleteContactCall) (response)
761#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
762#[serde_with::serde_as]
763#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
764pub struct Empty {
765 _never_set: Option<bool>,
766}
767
768impl common::ResponseResult for Empty {}
769
770/// An event related to the person.
771///
772/// This type is not used in any activity, and only used as *part* of another schema.
773///
774#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
775#[serde_with::serde_as]
776#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
777pub struct Event {
778 /// The date of the event.
779 pub date: Option<Date>,
780 /// Output only. The type of the event translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
781 #[serde(rename = "formattedType")]
782 pub formatted_type: Option<String>,
783 /// Metadata about the event.
784 pub metadata: Option<FieldMetadata>,
785 /// The type of the event. The type can be custom or one of these predefined values: * `anniversary` * `other`
786 #[serde(rename = "type")]
787 pub type_: Option<String>,
788}
789
790impl common::Part for Event {}
791
792/// An identifier from an external entity related to the person.
793///
794/// This type is not used in any activity, and only used as *part* of another schema.
795///
796#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
797#[serde_with::serde_as]
798#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
799pub struct ExternalId {
800 /// Output only. The type of the event translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
801 #[serde(rename = "formattedType")]
802 pub formatted_type: Option<String>,
803 /// Metadata about the external ID.
804 pub metadata: Option<FieldMetadata>,
805 /// The type of the external ID. The type can be custom or one of these predefined values: * `account` * `customer` * `loginId` * `network` * `organization`
806 #[serde(rename = "type")]
807 pub type_: Option<String>,
808 /// The value of the external ID.
809 pub value: Option<String>,
810}
811
812impl common::Part for ExternalId {}
813
814/// Metadata about a field.
815///
816/// This type is not used in any activity, and only used as *part* of another schema.
817///
818#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
819#[serde_with::serde_as]
820#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
821pub struct FieldMetadata {
822 /// Output only. True if the field is the primary field for all sources in the person. Each person will have at most one field with `primary` set to true.
823 pub primary: Option<bool>,
824 /// The source of the field.
825 pub source: Option<Source>,
826 /// True if the field is the primary field for the source. Each source must have at most one field with `source_primary` set to true.
827 #[serde(rename = "sourcePrimary")]
828 pub source_primary: Option<bool>,
829 /// Output only. True if the field is verified; false if the field is unverified. A verified field is typically a name, email address, phone number, or website that has been confirmed to be owned by the person.
830 pub verified: Option<bool>,
831}
832
833impl common::Part for FieldMetadata {}
834
835/// The name that should be used to sort the person in a list.
836///
837/// This type is not used in any activity, and only used as *part* of another schema.
838///
839#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
840#[serde_with::serde_as]
841#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
842pub struct FileAs {
843 /// Metadata about the file-as.
844 pub metadata: Option<FieldMetadata>,
845 /// The file-as value
846 pub value: Option<String>,
847}
848
849impl common::Part for FileAs {}
850
851/// A person's gender.
852///
853/// This type is not used in any activity, and only used as *part* of another schema.
854///
855#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
856#[serde_with::serde_as]
857#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
858pub struct Gender {
859 /// Free form text field for pronouns that should be used to address the person. Common values are: * `he`/`him` * `she`/`her` * `they`/`them`
860 #[serde(rename = "addressMeAs")]
861 pub address_me_as: Option<String>,
862 /// Output only. The value of the gender translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale. Unspecified or custom value are not localized.
863 #[serde(rename = "formattedValue")]
864 pub formatted_value: Option<String>,
865 /// Metadata about the gender.
866 pub metadata: Option<FieldMetadata>,
867 /// The gender for the person. The gender can be custom or one of these predefined values: * `male` * `female` * `unspecified`
868 pub value: Option<String>,
869}
870
871impl common::Part for Gender {}
872
873/// The response to a get request for a list of people by resource name.
874///
875/// # Activities
876///
877/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
878/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
879///
880/// * [get batch get people](PersonGetBatchGetCall) (response)
881#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
882#[serde_with::serde_as]
883#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
884pub struct GetPeopleResponse {
885 /// The response for each requested resource name.
886 pub responses: Option<Vec<PersonResponse>>,
887}
888
889impl common::ResponseResult for GetPeopleResponse {}
890
891/// Arbitrary client data that is populated by clients. Duplicate keys and values are allowed.
892///
893/// This type is not used in any activity, and only used as *part* of another schema.
894///
895#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
896#[serde_with::serde_as]
897#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
898pub struct GroupClientData {
899 /// The client specified key of the client data.
900 pub key: Option<String>,
901 /// The client specified value of the client data.
902 pub value: Option<String>,
903}
904
905impl common::Part for GroupClientData {}
906
907/// A person's instant messaging client.
908///
909/// This type is not used in any activity, and only used as *part* of another schema.
910///
911#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
912#[serde_with::serde_as]
913#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
914pub struct ImClient {
915 /// Output only. The protocol of the IM client formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
916 #[serde(rename = "formattedProtocol")]
917 pub formatted_protocol: Option<String>,
918 /// Output only. The type of the IM client translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
919 #[serde(rename = "formattedType")]
920 pub formatted_type: Option<String>,
921 /// Metadata about the IM client.
922 pub metadata: Option<FieldMetadata>,
923 /// The protocol of the IM client. The protocol can be custom or one of these predefined values: * `aim` * `msn` * `yahoo` * `skype` * `qq` * `googleTalk` * `icq` * `jabber` * `netMeeting`
924 pub protocol: Option<String>,
925 /// The type of the IM client. The type can be custom or one of these predefined values: * `home` * `work` * `other`
926 #[serde(rename = "type")]
927 pub type_: Option<String>,
928 /// The user name used in the IM client.
929 pub username: Option<String>,
930}
931
932impl common::Part for ImClient {}
933
934/// One of the person's interests.
935///
936/// This type is not used in any activity, and only used as *part* of another schema.
937///
938#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
939#[serde_with::serde_as]
940#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
941pub struct Interest {
942 /// Metadata about the interest.
943 pub metadata: Option<FieldMetadata>,
944 /// The interest; for example, `stargazing`.
945 pub value: Option<String>,
946}
947
948impl common::Part for Interest {}
949
950/// The response to a request for the authenticated user’s connections.
951///
952/// # Activities
953///
954/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
955/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
956///
957/// * [connections list people](PersonConnectionListCall) (response)
958#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
959#[serde_with::serde_as]
960#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
961pub struct ListConnectionsResponse {
962 /// The list of people that the requestor is connected to.
963 pub connections: Option<Vec<Person>>,
964 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
965 #[serde(rename = "nextPageToken")]
966 pub next_page_token: Option<String>,
967 /// A token, which can be sent as `sync_token` to retrieve changes since the last request. Request must set `request_sync_token` to return the sync token. When the response is paginated, only the last page will contain `nextSyncToken`.
968 #[serde(rename = "nextSyncToken")]
969 pub next_sync_token: Option<String>,
970 /// The total number of items in the list without pagination.
971 #[serde(rename = "totalItems")]
972 pub total_items: Option<i32>,
973 /// **DEPRECATED** (Please use totalItems) The total number of people in the list without pagination.
974 #[serde(rename = "totalPeople")]
975 pub total_people: Option<i32>,
976}
977
978impl common::ResponseResult for ListConnectionsResponse {}
979
980/// The response to a list contact groups request.
981///
982/// # Activities
983///
984/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
985/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
986///
987/// * [list contact groups](ContactGroupListCall) (response)
988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
989#[serde_with::serde_as]
990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
991pub struct ListContactGroupsResponse {
992 /// The list of contact groups. Members of the contact groups are not populated.
993 #[serde(rename = "contactGroups")]
994 pub contact_groups: Option<Vec<ContactGroup>>,
995 /// The token that can be used to retrieve the next page of results.
996 #[serde(rename = "nextPageToken")]
997 pub next_page_token: Option<String>,
998 /// The token that can be used to retrieve changes since the last request.
999 #[serde(rename = "nextSyncToken")]
1000 pub next_sync_token: Option<String>,
1001 /// The total number of items in the list without pagination.
1002 #[serde(rename = "totalItems")]
1003 pub total_items: Option<i32>,
1004}
1005
1006impl common::ResponseResult for ListContactGroupsResponse {}
1007
1008/// The response to a request for the authenticated user’s domain directory.
1009///
1010/// # Activities
1011///
1012/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1013/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1014///
1015/// * [list directory people people](PersonListDirectoryPersonCall) (response)
1016#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1017#[serde_with::serde_as]
1018#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1019pub struct ListDirectoryPeopleResponse {
1020 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1021 #[serde(rename = "nextPageToken")]
1022 pub next_page_token: Option<String>,
1023 /// A token, which can be sent as `sync_token` to retrieve changes since the last request. Request must set `request_sync_token` to return the sync token.
1024 #[serde(rename = "nextSyncToken")]
1025 pub next_sync_token: Option<String>,
1026 /// The list of people in the domain directory.
1027 pub people: Option<Vec<Person>>,
1028}
1029
1030impl common::ResponseResult for ListDirectoryPeopleResponse {}
1031
1032/// The response to a request for the authenticated user’s “Other contacts”.
1033///
1034/// # Activities
1035///
1036/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1037/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1038///
1039/// * [list other contacts](OtherContactListCall) (response)
1040#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1041#[serde_with::serde_as]
1042#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1043pub struct ListOtherContactsResponse {
1044 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1045 #[serde(rename = "nextPageToken")]
1046 pub next_page_token: Option<String>,
1047 /// A token, which can be sent as `sync_token` to retrieve changes since the last request. Request must set `request_sync_token` to return the sync token.
1048 #[serde(rename = "nextSyncToken")]
1049 pub next_sync_token: Option<String>,
1050 /// The list of "Other contacts" returned as Person resources. "Other contacts" support a limited subset of fields. See ListOtherContactsRequest.request_mask for more detailed information.
1051 #[serde(rename = "otherContacts")]
1052 pub other_contacts: Option<Vec<Person>>,
1053 /// The total number of other contacts in the list without pagination.
1054 #[serde(rename = "totalSize")]
1055 pub total_size: Option<i32>,
1056}
1057
1058impl common::ResponseResult for ListOtherContactsResponse {}
1059
1060/// A person's locale preference.
1061///
1062/// This type is not used in any activity, and only used as *part* of another schema.
1063///
1064#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1065#[serde_with::serde_as]
1066#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1067pub struct Locale {
1068 /// Metadata about the locale.
1069 pub metadata: Option<FieldMetadata>,
1070 /// The well-formed [IETF BCP 47](https://tools.ietf.org/html/bcp47) language tag representing the locale.
1071 pub value: Option<String>,
1072}
1073
1074impl common::Part for Locale {}
1075
1076/// A person's location.
1077///
1078/// This type is not used in any activity, and only used as *part* of another schema.
1079///
1080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1081#[serde_with::serde_as]
1082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1083pub struct Location {
1084 /// The building identifier.
1085 #[serde(rename = "buildingId")]
1086 pub building_id: Option<String>,
1087 /// Whether the location is the current location.
1088 pub current: Option<bool>,
1089 /// The individual desk location.
1090 #[serde(rename = "deskCode")]
1091 pub desk_code: Option<String>,
1092 /// The floor name or number.
1093 pub floor: Option<String>,
1094 /// The floor section in `floor_name`.
1095 #[serde(rename = "floorSection")]
1096 pub floor_section: Option<String>,
1097 /// Metadata about the location.
1098 pub metadata: Option<FieldMetadata>,
1099 /// The type of the location. The type can be custom or one of these predefined values: * `desk` * `grewUp`
1100 #[serde(rename = "type")]
1101 pub type_: Option<String>,
1102 /// The free-form value of the location.
1103 pub value: Option<String>,
1104}
1105
1106impl common::Part for Location {}
1107
1108/// A person's membership in a group. Only contact group memberships can be modified.
1109///
1110/// This type is not used in any activity, and only used as *part* of another schema.
1111///
1112#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1113#[serde_with::serde_as]
1114#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1115pub struct Membership {
1116 /// The contact group membership.
1117 #[serde(rename = "contactGroupMembership")]
1118 pub contact_group_membership: Option<ContactGroupMembership>,
1119 /// Output only. The domain membership.
1120 #[serde(rename = "domainMembership")]
1121 pub domain_membership: Option<DomainMembership>,
1122 /// Metadata about the membership.
1123 pub metadata: Option<FieldMetadata>,
1124}
1125
1126impl common::Part for Membership {}
1127
1128/// A person's miscellaneous keyword.
1129///
1130/// This type is not used in any activity, and only used as *part* of another schema.
1131///
1132#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1133#[serde_with::serde_as]
1134#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1135pub struct MiscKeyword {
1136 /// Output only. The type of the miscellaneous keyword translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
1137 #[serde(rename = "formattedType")]
1138 pub formatted_type: Option<String>,
1139 /// Metadata about the miscellaneous keyword.
1140 pub metadata: Option<FieldMetadata>,
1141 /// The miscellaneous keyword type.
1142 #[serde(rename = "type")]
1143 pub type_: Option<String>,
1144 /// The value of the miscellaneous keyword.
1145 pub value: Option<String>,
1146}
1147
1148impl common::Part for MiscKeyword {}
1149
1150/// A request to modify an existing contact group’s members. Contacts can be removed from any group but they can only be added to a user group or “myContacts” or “starred” system groups.
1151///
1152/// # Activities
1153///
1154/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1155/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1156///
1157/// * [members modify contact groups](ContactGroupMemberModifyCall) (request)
1158#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1159#[serde_with::serde_as]
1160#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1161pub struct ModifyContactGroupMembersRequest {
1162 /// Optional. The resource names of the contact people to add in the form of `people/{person_id}`. The total number of resource names in `resource_names_to_add` and `resource_names_to_remove` must be less than or equal to 1000.
1163 #[serde(rename = "resourceNamesToAdd")]
1164 pub resource_names_to_add: Option<Vec<String>>,
1165 /// Optional. The resource names of the contact people to remove in the form of `people/{person_id}`. The total number of resource names in `resource_names_to_add` and `resource_names_to_remove` must be less than or equal to 1000.
1166 #[serde(rename = "resourceNamesToRemove")]
1167 pub resource_names_to_remove: Option<Vec<String>>,
1168}
1169
1170impl common::RequestValue for ModifyContactGroupMembersRequest {}
1171
1172/// The response to a modify contact group members request.
1173///
1174/// # Activities
1175///
1176/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1177/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1178///
1179/// * [members modify contact groups](ContactGroupMemberModifyCall) (response)
1180#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1181#[serde_with::serde_as]
1182#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1183pub struct ModifyContactGroupMembersResponse {
1184 /// The contact people resource names that cannot be removed from their last contact group.
1185 #[serde(rename = "canNotRemoveLastContactGroupResourceNames")]
1186 pub can_not_remove_last_contact_group_resource_names: Option<Vec<String>>,
1187 /// The contact people resource names that were not found.
1188 #[serde(rename = "notFoundResourceNames")]
1189 pub not_found_resource_names: Option<Vec<String>>,
1190}
1191
1192impl common::ResponseResult for ModifyContactGroupMembersResponse {}
1193
1194/// A person's name. If the name is a mononym, the family name is empty.
1195///
1196/// This type is not used in any activity, and only used as *part* of another schema.
1197///
1198#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1199#[serde_with::serde_as]
1200#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1201pub struct Name {
1202 /// Output only. The display name formatted according to the locale specified by the viewer's account or the `Accept-Language` HTTP header.
1203 #[serde(rename = "displayName")]
1204 pub display_name: Option<String>,
1205 /// Output only. The display name with the last name first formatted according to the locale specified by the viewer's account or the `Accept-Language` HTTP header.
1206 #[serde(rename = "displayNameLastFirst")]
1207 pub display_name_last_first: Option<String>,
1208 /// The family name.
1209 #[serde(rename = "familyName")]
1210 pub family_name: Option<String>,
1211 /// The given name.
1212 #[serde(rename = "givenName")]
1213 pub given_name: Option<String>,
1214 /// The honorific prefixes, such as `Mrs.` or `Dr.`
1215 #[serde(rename = "honorificPrefix")]
1216 pub honorific_prefix: Option<String>,
1217 /// The honorific suffixes, such as `Jr.`
1218 #[serde(rename = "honorificSuffix")]
1219 pub honorific_suffix: Option<String>,
1220 /// Metadata about the name.
1221 pub metadata: Option<FieldMetadata>,
1222 /// The middle name(s).
1223 #[serde(rename = "middleName")]
1224 pub middle_name: Option<String>,
1225 /// The family name spelled as it sounds.
1226 #[serde(rename = "phoneticFamilyName")]
1227 pub phonetic_family_name: Option<String>,
1228 /// The full name spelled as it sounds.
1229 #[serde(rename = "phoneticFullName")]
1230 pub phonetic_full_name: Option<String>,
1231 /// The given name spelled as it sounds.
1232 #[serde(rename = "phoneticGivenName")]
1233 pub phonetic_given_name: Option<String>,
1234 /// The honorific prefixes spelled as they sound.
1235 #[serde(rename = "phoneticHonorificPrefix")]
1236 pub phonetic_honorific_prefix: Option<String>,
1237 /// The honorific suffixes spelled as they sound.
1238 #[serde(rename = "phoneticHonorificSuffix")]
1239 pub phonetic_honorific_suffix: Option<String>,
1240 /// The middle name(s) spelled as they sound.
1241 #[serde(rename = "phoneticMiddleName")]
1242 pub phonetic_middle_name: Option<String>,
1243 /// The free form name value.
1244 #[serde(rename = "unstructuredName")]
1245 pub unstructured_name: Option<String>,
1246}
1247
1248impl common::Part for Name {}
1249
1250/// A person's nickname.
1251///
1252/// This type is not used in any activity, and only used as *part* of another schema.
1253///
1254#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1255#[serde_with::serde_as]
1256#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1257pub struct Nickname {
1258 /// Metadata about the nickname.
1259 pub metadata: Option<FieldMetadata>,
1260 /// The type of the nickname.
1261 #[serde(rename = "type")]
1262 pub type_: Option<String>,
1263 /// The nickname.
1264 pub value: Option<String>,
1265}
1266
1267impl common::Part for Nickname {}
1268
1269/// A person's occupation.
1270///
1271/// This type is not used in any activity, and only used as *part* of another schema.
1272///
1273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1274#[serde_with::serde_as]
1275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1276pub struct Occupation {
1277 /// Metadata about the occupation.
1278 pub metadata: Option<FieldMetadata>,
1279 /// The occupation; for example, `carpenter`.
1280 pub value: Option<String>,
1281}
1282
1283impl common::Part for Occupation {}
1284
1285/// A person's past or current organization. Overlapping date ranges are permitted.
1286///
1287/// This type is not used in any activity, and only used as *part* of another schema.
1288///
1289#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1290#[serde_with::serde_as]
1291#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1292pub struct Organization {
1293 /// The person's cost center at the organization.
1294 #[serde(rename = "costCenter")]
1295 pub cost_center: Option<String>,
1296 /// True if the organization is the person's current organization; false if the organization is a past organization.
1297 pub current: Option<bool>,
1298 /// The person's department at the organization.
1299 pub department: Option<String>,
1300 /// The domain name associated with the organization; for example, `google.com`.
1301 pub domain: Option<String>,
1302 /// The end date when the person left the organization.
1303 #[serde(rename = "endDate")]
1304 pub end_date: Option<Date>,
1305 /// Output only. The type of the organization translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
1306 #[serde(rename = "formattedType")]
1307 pub formatted_type: Option<String>,
1308 /// The person's full-time equivalent millipercent within the organization (100000 = 100%).
1309 #[serde(rename = "fullTimeEquivalentMillipercent")]
1310 pub full_time_equivalent_millipercent: Option<i32>,
1311 /// The person's job description at the organization.
1312 #[serde(rename = "jobDescription")]
1313 pub job_description: Option<String>,
1314 /// The location of the organization office the person works at.
1315 pub location: Option<String>,
1316 /// Metadata about the organization.
1317 pub metadata: Option<FieldMetadata>,
1318 /// The name of the organization.
1319 pub name: Option<String>,
1320 /// The phonetic name of the organization.
1321 #[serde(rename = "phoneticName")]
1322 pub phonetic_name: Option<String>,
1323 /// The start date when the person joined the organization.
1324 #[serde(rename = "startDate")]
1325 pub start_date: Option<Date>,
1326 /// The symbol associated with the organization; for example, a stock ticker symbol, abbreviation, or acronym.
1327 pub symbol: Option<String>,
1328 /// The person's job title at the organization.
1329 pub title: Option<String>,
1330 /// The type of the organization. The type can be custom or one of these predefined values: * `work` * `school`
1331 #[serde(rename = "type")]
1332 pub type_: Option<String>,
1333}
1334
1335impl common::Part for Organization {}
1336
1337/// Information about a person merged from various data sources such as the authenticated user’s contacts and profile data. Most fields can have multiple items. The items in a field have no guaranteed order, but each non-empty field is guaranteed to have exactly one field with `metadata.primary` set to true.
1338///
1339/// # Activities
1340///
1341/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1342/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1343///
1344/// * [copy other contact to my contacts group other contacts](OtherContactCopyOtherContactToMyContactsGroupCall) (response)
1345/// * [create contact people](PersonCreateContactCall) (request|response)
1346/// * [get people](PersonGetCall) (response)
1347/// * [update contact people](PersonUpdateContactCall) (request|response)
1348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1349#[serde_with::serde_as]
1350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1351pub struct Person {
1352 /// The person's street addresses.
1353 pub addresses: Option<Vec<Address>>,
1354 /// Output only. **DEPRECATED** (Please use `person.ageRanges` instead) The person's age range.
1355 #[serde(rename = "ageRange")]
1356 pub age_range: Option<String>,
1357 /// Output only. The person's age ranges.
1358 #[serde(rename = "ageRanges")]
1359 pub age_ranges: Option<Vec<AgeRangeType>>,
1360 /// The person's biographies. This field is a singleton for contact sources.
1361 pub biographies: Option<Vec<Biography>>,
1362 /// The person's birthdays. This field is a singleton for contact sources.
1363 pub birthdays: Option<Vec<Birthday>>,
1364 /// **DEPRECATED**: No data will be returned The person's bragging rights.
1365 #[serde(rename = "braggingRights")]
1366 pub bragging_rights: Option<Vec<BraggingRights>>,
1367 /// The person's calendar URLs.
1368 #[serde(rename = "calendarUrls")]
1369 pub calendar_urls: Option<Vec<CalendarUrl>>,
1370 /// The person's client data.
1371 #[serde(rename = "clientData")]
1372 pub client_data: Option<Vec<ClientData>>,
1373 /// Output only. The person's cover photos.
1374 #[serde(rename = "coverPhotos")]
1375 pub cover_photos: Option<Vec<CoverPhoto>>,
1376 /// The person's email addresses. For `people.connections.list` and `otherContacts.list` the number of email addresses is limited to 100. If a Person has more email addresses the entire set can be obtained by calling GetPeople.
1377 #[serde(rename = "emailAddresses")]
1378 pub email_addresses: Option<Vec<EmailAddress>>,
1379 /// The [HTTP entity tag](https://en.wikipedia.org/wiki/HTTP_ETag) of the resource. Used for web cache validation.
1380 pub etag: Option<String>,
1381 /// The person's events.
1382 pub events: Option<Vec<Event>>,
1383 /// The person's external IDs.
1384 #[serde(rename = "externalIds")]
1385 pub external_ids: Option<Vec<ExternalId>>,
1386 /// The person's file-ases.
1387 #[serde(rename = "fileAses")]
1388 pub file_ases: Option<Vec<FileAs>>,
1389 /// The person's genders. This field is a singleton for contact sources.
1390 pub genders: Option<Vec<Gender>>,
1391 /// The person's instant messaging clients.
1392 #[serde(rename = "imClients")]
1393 pub im_clients: Option<Vec<ImClient>>,
1394 /// The person's interests.
1395 pub interests: Option<Vec<Interest>>,
1396 /// The person's locale preferences.
1397 pub locales: Option<Vec<Locale>>,
1398 /// The person's locations.
1399 pub locations: Option<Vec<Location>>,
1400 /// The person's group memberships.
1401 pub memberships: Option<Vec<Membership>>,
1402 /// Output only. Metadata about the person.
1403 pub metadata: Option<PersonMetadata>,
1404 /// The person's miscellaneous keywords.
1405 #[serde(rename = "miscKeywords")]
1406 pub misc_keywords: Option<Vec<MiscKeyword>>,
1407 /// The person's names. This field is a singleton for contact sources.
1408 pub names: Option<Vec<Name>>,
1409 /// The person's nicknames.
1410 pub nicknames: Option<Vec<Nickname>>,
1411 /// The person's occupations.
1412 pub occupations: Option<Vec<Occupation>>,
1413 /// The person's past or current organizations.
1414 pub organizations: Option<Vec<Organization>>,
1415 /// The person's phone numbers. For `people.connections.list` and `otherContacts.list` the number of phone numbers is limited to 100. If a Person has more phone numbers the entire set can be obtained by calling GetPeople.
1416 #[serde(rename = "phoneNumbers")]
1417 pub phone_numbers: Option<Vec<PhoneNumber>>,
1418 /// Output only. The person's photos.
1419 pub photos: Option<Vec<Photo>>,
1420 /// The person's relations.
1421 pub relations: Option<Vec<Relation>>,
1422 /// Output only. **DEPRECATED**: No data will be returned The person's relationship interests.
1423 #[serde(rename = "relationshipInterests")]
1424 pub relationship_interests: Option<Vec<RelationshipInterest>>,
1425 /// Output only. **DEPRECATED**: No data will be returned The person's relationship statuses.
1426 #[serde(rename = "relationshipStatuses")]
1427 pub relationship_statuses: Option<Vec<RelationshipStatus>>,
1428 /// **DEPRECATED**: (Please use `person.locations` instead) The person's residences.
1429 pub residences: Option<Vec<Residence>>,
1430 /// The resource name for the person, assigned by the server. An ASCII string in the form of `people/{person_id}`.
1431 #[serde(rename = "resourceName")]
1432 pub resource_name: Option<String>,
1433 /// The person's SIP addresses.
1434 #[serde(rename = "sipAddresses")]
1435 pub sip_addresses: Option<Vec<SipAddress>>,
1436 /// The person's skills.
1437 pub skills: Option<Vec<Skill>>,
1438 /// Output only. **DEPRECATED**: No data will be returned The person's taglines.
1439 pub taglines: Option<Vec<Tagline>>,
1440 /// The person's associated URLs.
1441 pub urls: Option<Vec<Url>>,
1442 /// The person's user defined data.
1443 #[serde(rename = "userDefined")]
1444 pub user_defined: Option<Vec<UserDefined>>,
1445}
1446
1447impl common::RequestValue for Person {}
1448impl common::ResponseResult for Person {}
1449
1450/// The metadata about a person.
1451///
1452/// This type is not used in any activity, and only used as *part* of another schema.
1453///
1454#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1455#[serde_with::serde_as]
1456#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1457pub struct PersonMetadata {
1458 /// Output only. True if the person resource has been deleted. Populated only for `people.connections.list` and `otherContacts.list` sync requests.
1459 pub deleted: Option<bool>,
1460 /// Output only. Resource names of people linked to this resource.
1461 #[serde(rename = "linkedPeopleResourceNames")]
1462 pub linked_people_resource_names: Option<Vec<String>>,
1463 /// Output only. **DEPRECATED** (Please use `person.metadata.sources.profileMetadata.objectType` instead) The type of the person object.
1464 #[serde(rename = "objectType")]
1465 pub object_type: Option<String>,
1466 /// Output only. Any former resource names this person has had. Populated only for `people.connections.list` requests that include a sync token. The resource name may change when adding or removing fields that link a contact and profile such as a verified email, verified phone number, or profile URL.
1467 #[serde(rename = "previousResourceNames")]
1468 pub previous_resource_names: Option<Vec<String>>,
1469 /// The sources of data for the person.
1470 pub sources: Option<Vec<Source>>,
1471}
1472
1473impl common::Part for PersonMetadata {}
1474
1475/// The response for a single person
1476///
1477/// This type is not used in any activity, and only used as *part* of another schema.
1478///
1479#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1480#[serde_with::serde_as]
1481#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1482pub struct PersonResponse {
1483 /// **DEPRECATED** (Please use status instead) [HTTP 1.1 status code] (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
1484 #[serde(rename = "httpStatusCode")]
1485 pub http_status_code: Option<i32>,
1486 /// The person.
1487 pub person: Option<Person>,
1488 /// The original requested resource name. May be different than the resource name on the returned person. The resource name can change when adding or removing fields that link a contact and profile such as a verified email, verified phone number, or a profile URL.
1489 #[serde(rename = "requestedResourceName")]
1490 pub requested_resource_name: Option<String>,
1491 /// The status of the response.
1492 pub status: Option<Status>,
1493}
1494
1495impl common::Part for PersonResponse {}
1496
1497/// A person's phone number.
1498///
1499/// This type is not used in any activity, and only used as *part* of another schema.
1500///
1501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1502#[serde_with::serde_as]
1503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1504pub struct PhoneNumber {
1505 /// Output only. The canonicalized [ITU-T E.164](https://law.resource.org/pub/us/cfr/ibr/004/itu-t.E.164.1.2008.pdf) form of the phone number.
1506 #[serde(rename = "canonicalForm")]
1507 pub canonical_form: Option<String>,
1508 /// Output only. The type of the phone number translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
1509 #[serde(rename = "formattedType")]
1510 pub formatted_type: Option<String>,
1511 /// Metadata about the phone number.
1512 pub metadata: Option<FieldMetadata>,
1513 /// The type of the phone number. The type can be custom or one of these predefined values: * `home` * `work` * `mobile` * `homeFax` * `workFax` * `otherFax` * `pager` * `workMobile` * `workPager` * `main` * `googleVoice` * `other`
1514 #[serde(rename = "type")]
1515 pub type_: Option<String>,
1516 /// The phone number.
1517 pub value: Option<String>,
1518}
1519
1520impl common::Part for PhoneNumber {}
1521
1522/// A person's photo. A picture shown next to the person's name to help others recognize the person.
1523///
1524/// This type is not used in any activity, and only used as *part* of another schema.
1525///
1526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1527#[serde_with::serde_as]
1528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1529pub struct Photo {
1530 /// True if the photo is a default photo; false if the photo is a user-provided photo.
1531 pub default: Option<bool>,
1532 /// Metadata about the photo.
1533 pub metadata: Option<FieldMetadata>,
1534 /// The URL of the photo. You can change the desired size by appending a query parameter `sz={size}` at the end of the url, where {size} is the size in pixels. Example: https://lh3.googleusercontent.com/-T_wVWLlmg7w/AAAAAAAAAAI/AAAAAAAABa8/00gzXvDBYqw/s100/photo.jpg?sz=50
1535 pub url: Option<String>,
1536}
1537
1538impl common::Part for Photo {}
1539
1540/// The metadata about a profile.
1541///
1542/// This type is not used in any activity, and only used as *part* of another schema.
1543///
1544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1545#[serde_with::serde_as]
1546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1547pub struct ProfileMetadata {
1548 /// Output only. The profile object type.
1549 #[serde(rename = "objectType")]
1550 pub object_type: Option<String>,
1551 /// Output only. The user types.
1552 #[serde(rename = "userTypes")]
1553 pub user_types: Option<Vec<String>>,
1554}
1555
1556impl common::Part for ProfileMetadata {}
1557
1558/// A person's relation to another person.
1559///
1560/// This type is not used in any activity, and only used as *part* of another schema.
1561///
1562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1563#[serde_with::serde_as]
1564#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1565pub struct Relation {
1566 /// Output only. The type of the relation translated and formatted in the viewer's account locale or the locale specified in the Accept-Language HTTP header.
1567 #[serde(rename = "formattedType")]
1568 pub formatted_type: Option<String>,
1569 /// Metadata about the relation.
1570 pub metadata: Option<FieldMetadata>,
1571 /// The name of the other person this relation refers to.
1572 pub person: Option<String>,
1573 /// The person's relation to the other person. The type can be custom or one of these predefined values: * `spouse` * `child` * `mother` * `father` * `parent` * `brother` * `sister` * `friend` * `relative` * `domesticPartner` * `manager` * `assistant` * `referredBy` * `partner`
1574 #[serde(rename = "type")]
1575 pub type_: Option<String>,
1576}
1577
1578impl common::Part for Relation {}
1579
1580/// **DEPRECATED**: No data will be returned A person's relationship interest .
1581///
1582/// This type is not used in any activity, and only used as *part* of another schema.
1583///
1584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1585#[serde_with::serde_as]
1586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1587pub struct RelationshipInterest {
1588 /// Output only. The value of the relationship interest translated and formatted in the viewer's account locale or the locale specified in the Accept-Language HTTP header.
1589 #[serde(rename = "formattedValue")]
1590 pub formatted_value: Option<String>,
1591 /// Metadata about the relationship interest.
1592 pub metadata: Option<FieldMetadata>,
1593 /// The kind of relationship the person is looking for. The value can be custom or one of these predefined values: * `friend` * `date` * `relationship` * `networking`
1594 pub value: Option<String>,
1595}
1596
1597impl common::Part for RelationshipInterest {}
1598
1599/// **DEPRECATED**: No data will be returned A person's relationship status.
1600///
1601/// This type is not used in any activity, and only used as *part* of another schema.
1602///
1603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1604#[serde_with::serde_as]
1605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1606pub struct RelationshipStatus {
1607 /// Output only. The value of the relationship status translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
1608 #[serde(rename = "formattedValue")]
1609 pub formatted_value: Option<String>,
1610 /// Metadata about the relationship status.
1611 pub metadata: Option<FieldMetadata>,
1612 /// The relationship status. The value can be custom or one of these predefined values: * `single` * `inARelationship` * `engaged` * `married` * `itsComplicated` * `openRelationship` * `widowed` * `inDomesticPartnership` * `inCivilUnion`
1613 pub value: Option<String>,
1614}
1615
1616impl common::Part for RelationshipStatus {}
1617
1618/// **DEPRECATED**: Please use `person.locations` instead. A person's past or current residence.
1619///
1620/// This type is not used in any activity, and only used as *part* of another schema.
1621///
1622#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1623#[serde_with::serde_as]
1624#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1625pub struct Residence {
1626 /// True if the residence is the person's current residence; false if the residence is a past residence.
1627 pub current: Option<bool>,
1628 /// Metadata about the residence.
1629 pub metadata: Option<FieldMetadata>,
1630 /// The address of the residence.
1631 pub value: Option<String>,
1632}
1633
1634impl common::Part for Residence {}
1635
1636/// The response to a request for people in the authenticated user’s domain directory that match the specified query.
1637///
1638/// # Activities
1639///
1640/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1641/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1642///
1643/// * [search directory people people](PersonSearchDirectoryPersonCall) (response)
1644#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1645#[serde_with::serde_as]
1646#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1647pub struct SearchDirectoryPeopleResponse {
1648 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1649 #[serde(rename = "nextPageToken")]
1650 pub next_page_token: Option<String>,
1651 /// The list of people in the domain directory that match the query.
1652 pub people: Option<Vec<Person>>,
1653 /// The total number of items in the list without pagination.
1654 #[serde(rename = "totalSize")]
1655 pub total_size: Option<i32>,
1656}
1657
1658impl common::ResponseResult for SearchDirectoryPeopleResponse {}
1659
1660/// The response to a search request for the authenticated user, given a query.
1661///
1662/// # Activities
1663///
1664/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1665/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1666///
1667/// * [search other contacts](OtherContactSearchCall) (response)
1668/// * [search contacts people](PersonSearchContactCall) (response)
1669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1670#[serde_with::serde_as]
1671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1672pub struct SearchResponse {
1673 /// The results of the request.
1674 pub results: Option<Vec<SearchResult>>,
1675}
1676
1677impl common::ResponseResult for SearchResponse {}
1678
1679/// A result of a search query.
1680///
1681/// This type is not used in any activity, and only used as *part* of another schema.
1682///
1683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1684#[serde_with::serde_as]
1685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1686pub struct SearchResult {
1687 /// The matched Person.
1688 pub person: Option<Person>,
1689}
1690
1691impl common::Part for SearchResult {}
1692
1693/// A person's SIP address. Session Initial Protocol addresses are used for VoIP communications to make voice or video calls over the internet.
1694///
1695/// This type is not used in any activity, and only used as *part* of another schema.
1696///
1697#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1698#[serde_with::serde_as]
1699#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1700pub struct SipAddress {
1701 /// Output only. The type of the SIP address translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
1702 #[serde(rename = "formattedType")]
1703 pub formatted_type: Option<String>,
1704 /// Metadata about the SIP address.
1705 pub metadata: Option<FieldMetadata>,
1706 /// The type of the SIP address. The type can be custom or or one of these predefined values: * `home` * `work` * `mobile` * `other`
1707 #[serde(rename = "type")]
1708 pub type_: Option<String>,
1709 /// The SIP address in the [RFC 3261 19.1](https://tools.ietf.org/html/rfc3261#section-19.1) SIP URI format.
1710 pub value: Option<String>,
1711}
1712
1713impl common::Part for SipAddress {}
1714
1715/// A skill that the person has.
1716///
1717/// This type is not used in any activity, and only used as *part* of another schema.
1718///
1719#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1720#[serde_with::serde_as]
1721#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1722pub struct Skill {
1723 /// Metadata about the skill.
1724 pub metadata: Option<FieldMetadata>,
1725 /// The skill; for example, `underwater basket weaving`.
1726 pub value: Option<String>,
1727}
1728
1729impl common::Part for Skill {}
1730
1731/// The source of a field.
1732///
1733/// This type is not used in any activity, and only used as *part* of another schema.
1734///
1735#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1736#[serde_with::serde_as]
1737#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1738pub struct Source {
1739 /// **Only populated in `person.metadata.sources`.** The [HTTP entity tag](https://en.wikipedia.org/wiki/HTTP_ETag) of the source. Used for web cache validation.
1740 pub etag: Option<String>,
1741 /// The unique identifier within the source type generated by the server.
1742 pub id: Option<String>,
1743 /// Output only. **Only populated in `person.metadata.sources`.** Metadata about a source of type PROFILE.
1744 #[serde(rename = "profileMetadata")]
1745 pub profile_metadata: Option<ProfileMetadata>,
1746 /// The source type.
1747 #[serde(rename = "type")]
1748 pub type_: Option<String>,
1749 /// Output only. **Only populated in `person.metadata.sources`.** Last update timestamp of this source.
1750 #[serde(rename = "updateTime")]
1751 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1752}
1753
1754impl common::Part for Source {}
1755
1756/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
1757///
1758/// This type is not used in any activity, and only used as *part* of another schema.
1759///
1760#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1761#[serde_with::serde_as]
1762#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1763pub struct Status {
1764 /// The status code, which should be an enum value of google.rpc.Code.
1765 pub code: Option<i32>,
1766 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1767 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1768 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
1769 pub message: Option<String>,
1770}
1771
1772impl common::Part for Status {}
1773
1774/// **DEPRECATED**: No data will be returned A brief one-line description of the person.
1775///
1776/// This type is not used in any activity, and only used as *part* of another schema.
1777///
1778#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1779#[serde_with::serde_as]
1780#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1781pub struct Tagline {
1782 /// Metadata about the tagline.
1783 pub metadata: Option<FieldMetadata>,
1784 /// The tagline.
1785 pub value: Option<String>,
1786}
1787
1788impl common::Part for Tagline {}
1789
1790/// A request to update an existing user contact group. All updated fields will be replaced.
1791///
1792/// # Activities
1793///
1794/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1795/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1796///
1797/// * [update contact groups](ContactGroupUpdateCall) (request)
1798#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1799#[serde_with::serde_as]
1800#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1801pub struct UpdateContactGroupRequest {
1802 /// Required. The contact group to update.
1803 #[serde(rename = "contactGroup")]
1804 pub contact_group: Option<ContactGroup>,
1805 /// Optional. A field mask to restrict which fields on the group are returned. Defaults to `metadata`, `groupType`, and `name` if not set or set to empty. Valid fields are: * clientData * groupType * memberCount * metadata * name
1806 #[serde(rename = "readGroupFields")]
1807 pub read_group_fields: Option<common::FieldMask>,
1808 /// Optional. A field mask to restrict which fields on the group are updated. Multiple fields can be specified by separating them with commas. Defaults to `name` if not set or set to empty. Updated fields are replaced. Valid values are: * clientData * name
1809 #[serde(rename = "updateGroupFields")]
1810 pub update_group_fields: Option<common::FieldMask>,
1811}
1812
1813impl common::RequestValue for UpdateContactGroupRequest {}
1814
1815/// A request to update an existing contact’s photo. All requests must have a valid photo format: JPEG or PNG.
1816///
1817/// # Activities
1818///
1819/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1820/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1821///
1822/// * [update contact photo people](PersonUpdateContactPhotoCall) (request)
1823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1824#[serde_with::serde_as]
1825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1826pub struct UpdateContactPhotoRequest {
1827 /// Optional. A field mask to restrict which fields on the person are returned. Multiple fields can be specified by separating them with commas. Defaults to empty if not set, which will skip the post mutate get. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
1828 #[serde(rename = "personFields")]
1829 pub person_fields: Option<common::FieldMask>,
1830 /// Required. Raw photo bytes
1831 #[serde(rename = "photoBytes")]
1832 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1833 pub photo_bytes: Option<Vec<u8>>,
1834 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
1835 pub sources: Option<Vec<String>>,
1836}
1837
1838impl common::RequestValue for UpdateContactPhotoRequest {}
1839
1840/// The response for updating a contact’s photo.
1841///
1842/// # Activities
1843///
1844/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1845/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1846///
1847/// * [update contact photo people](PersonUpdateContactPhotoCall) (response)
1848#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1849#[serde_with::serde_as]
1850#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1851pub struct UpdateContactPhotoResponse {
1852 /// The updated person, if person_fields is set in the UpdateContactPhotoRequest; otherwise this will be unset.
1853 pub person: Option<Person>,
1854}
1855
1856impl common::ResponseResult for UpdateContactPhotoResponse {}
1857
1858/// A person's associated URLs.
1859///
1860/// This type is not used in any activity, and only used as *part* of another schema.
1861///
1862#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1863#[serde_with::serde_as]
1864#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1865pub struct Url {
1866 /// Output only. The type of the URL translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale.
1867 #[serde(rename = "formattedType")]
1868 pub formatted_type: Option<String>,
1869 /// Metadata about the URL.
1870 pub metadata: Option<FieldMetadata>,
1871 /// The type of the URL. The type can be custom or one of these predefined values: * `home` * `work` * `blog` * `profile` * `homePage` * `ftp` * `reservations` * `appInstallPage`: website for a Currents application. * `other`
1872 #[serde(rename = "type")]
1873 pub type_: Option<String>,
1874 /// The URL.
1875 pub value: Option<String>,
1876}
1877
1878impl common::Part for Url {}
1879
1880/// Arbitrary user data that is populated by the end users.
1881///
1882/// This type is not used in any activity, and only used as *part* of another schema.
1883///
1884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1885#[serde_with::serde_as]
1886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1887pub struct UserDefined {
1888 /// The end user specified key of the user defined data.
1889 pub key: Option<String>,
1890 /// Metadata about the user defined data.
1891 pub metadata: Option<FieldMetadata>,
1892 /// The end user specified value of the user defined data.
1893 pub value: Option<String>,
1894}
1895
1896impl common::Part for UserDefined {}
1897
1898// ###################
1899// MethodBuilders ###
1900// #################
1901
1902/// A builder providing access to all methods supported on *contactGroup* resources.
1903/// It is not used directly, but through the [`PeopleService`] hub.
1904///
1905/// # Example
1906///
1907/// Instantiate a resource builder
1908///
1909/// ```test_harness,no_run
1910/// extern crate hyper;
1911/// extern crate hyper_rustls;
1912/// extern crate google_people1 as people1;
1913///
1914/// # async fn dox() {
1915/// use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1916///
1917/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1918/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1919/// secret,
1920/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1921/// ).build().await.unwrap();
1922///
1923/// let client = hyper_util::client::legacy::Client::builder(
1924/// hyper_util::rt::TokioExecutor::new()
1925/// )
1926/// .build(
1927/// hyper_rustls::HttpsConnectorBuilder::new()
1928/// .with_native_roots()
1929/// .unwrap()
1930/// .https_or_http()
1931/// .enable_http1()
1932/// .build()
1933/// );
1934/// let mut hub = PeopleService::new(client, auth);
1935/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1936/// // like `batch_get(...)`, `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `members_modify(...)` and `update(...)`
1937/// // to build up your call.
1938/// let rb = hub.contact_groups();
1939/// # }
1940/// ```
1941pub struct ContactGroupMethods<'a, C>
1942where
1943 C: 'a,
1944{
1945 hub: &'a PeopleService<C>,
1946}
1947
1948impl<'a, C> common::MethodsBuilder for ContactGroupMethods<'a, C> {}
1949
1950impl<'a, C> ContactGroupMethods<'a, C> {
1951 /// Create a builder to help you perform the following task:
1952 ///
1953 /// Modify the members of a contact group owned by the authenticated user. The only system contact groups that can have members added are `contactGroups/myContacts` and `contactGroups/starred`. Other system contact groups are deprecated and can only have contacts removed.
1954 ///
1955 /// # Arguments
1956 ///
1957 /// * `request` - No description provided.
1958 /// * `resourceName` - Required. The resource name of the contact group to modify.
1959 pub fn members_modify(
1960 &self,
1961 request: ModifyContactGroupMembersRequest,
1962 resource_name: &str,
1963 ) -> ContactGroupMemberModifyCall<'a, C> {
1964 ContactGroupMemberModifyCall {
1965 hub: self.hub,
1966 _request: request,
1967 _resource_name: resource_name.to_string(),
1968 _delegate: Default::default(),
1969 _additional_params: Default::default(),
1970 _scopes: Default::default(),
1971 }
1972 }
1973
1974 /// Create a builder to help you perform the following task:
1975 ///
1976 /// Get a list of contact groups owned by the authenticated user by specifying a list of contact group resource names.
1977 pub fn batch_get(&self) -> ContactGroupBatchGetCall<'a, C> {
1978 ContactGroupBatchGetCall {
1979 hub: self.hub,
1980 _resource_names: Default::default(),
1981 _max_members: Default::default(),
1982 _group_fields: Default::default(),
1983 _delegate: Default::default(),
1984 _additional_params: Default::default(),
1985 _scopes: Default::default(),
1986 }
1987 }
1988
1989 /// Create a builder to help you perform the following task:
1990 ///
1991 /// Create a new contact group owned by the authenticated user. Created contact group names must be unique to the users contact groups. Attempting to create a group with a duplicate name will return a HTTP 409 error. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
1992 ///
1993 /// # Arguments
1994 ///
1995 /// * `request` - No description provided.
1996 pub fn create(&self, request: CreateContactGroupRequest) -> ContactGroupCreateCall<'a, C> {
1997 ContactGroupCreateCall {
1998 hub: self.hub,
1999 _request: request,
2000 _delegate: Default::default(),
2001 _additional_params: Default::default(),
2002 _scopes: Default::default(),
2003 }
2004 }
2005
2006 /// Create a builder to help you perform the following task:
2007 ///
2008 /// Delete an existing contact group owned by the authenticated user by specifying a contact group resource name. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2009 ///
2010 /// # Arguments
2011 ///
2012 /// * `resourceName` - Required. The resource name of the contact group to delete.
2013 pub fn delete(&self, resource_name: &str) -> ContactGroupDeleteCall<'a, C> {
2014 ContactGroupDeleteCall {
2015 hub: self.hub,
2016 _resource_name: resource_name.to_string(),
2017 _delete_contacts: Default::default(),
2018 _delegate: Default::default(),
2019 _additional_params: Default::default(),
2020 _scopes: Default::default(),
2021 }
2022 }
2023
2024 /// Create a builder to help you perform the following task:
2025 ///
2026 /// Get a specific contact group owned by the authenticated user by specifying a contact group resource name.
2027 ///
2028 /// # Arguments
2029 ///
2030 /// * `resourceName` - Required. The resource name of the contact group to get.
2031 pub fn get(&self, resource_name: &str) -> ContactGroupGetCall<'a, C> {
2032 ContactGroupGetCall {
2033 hub: self.hub,
2034 _resource_name: resource_name.to_string(),
2035 _max_members: Default::default(),
2036 _group_fields: Default::default(),
2037 _delegate: Default::default(),
2038 _additional_params: Default::default(),
2039 _scopes: Default::default(),
2040 }
2041 }
2042
2043 /// Create a builder to help you perform the following task:
2044 ///
2045 /// List all contact groups owned by the authenticated user. Members of the contact groups are not populated.
2046 pub fn list(&self) -> ContactGroupListCall<'a, C> {
2047 ContactGroupListCall {
2048 hub: self.hub,
2049 _sync_token: Default::default(),
2050 _page_token: Default::default(),
2051 _page_size: Default::default(),
2052 _group_fields: Default::default(),
2053 _delegate: Default::default(),
2054 _additional_params: Default::default(),
2055 _scopes: Default::default(),
2056 }
2057 }
2058
2059 /// Create a builder to help you perform the following task:
2060 ///
2061 /// Update the name of an existing contact group owned by the authenticated user. Updated contact group names must be unique to the users contact groups. Attempting to create a group with a duplicate name will return a HTTP 409 error. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2062 ///
2063 /// # Arguments
2064 ///
2065 /// * `request` - No description provided.
2066 /// * `resourceName` - The resource name for the contact group, assigned by the server. An ASCII string, in the form of `contactGroups/{contact_group_id}`.
2067 pub fn update(
2068 &self,
2069 request: UpdateContactGroupRequest,
2070 resource_name: &str,
2071 ) -> ContactGroupUpdateCall<'a, C> {
2072 ContactGroupUpdateCall {
2073 hub: self.hub,
2074 _request: request,
2075 _resource_name: resource_name.to_string(),
2076 _delegate: Default::default(),
2077 _additional_params: Default::default(),
2078 _scopes: Default::default(),
2079 }
2080 }
2081}
2082
2083/// A builder providing access to all methods supported on *otherContact* resources.
2084/// It is not used directly, but through the [`PeopleService`] hub.
2085///
2086/// # Example
2087///
2088/// Instantiate a resource builder
2089///
2090/// ```test_harness,no_run
2091/// extern crate hyper;
2092/// extern crate hyper_rustls;
2093/// extern crate google_people1 as people1;
2094///
2095/// # async fn dox() {
2096/// use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2097///
2098/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2099/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2100/// secret,
2101/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2102/// ).build().await.unwrap();
2103///
2104/// let client = hyper_util::client::legacy::Client::builder(
2105/// hyper_util::rt::TokioExecutor::new()
2106/// )
2107/// .build(
2108/// hyper_rustls::HttpsConnectorBuilder::new()
2109/// .with_native_roots()
2110/// .unwrap()
2111/// .https_or_http()
2112/// .enable_http1()
2113/// .build()
2114/// );
2115/// let mut hub = PeopleService::new(client, auth);
2116/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2117/// // like `copy_other_contact_to_my_contacts_group(...)`, `list(...)` and `search(...)`
2118/// // to build up your call.
2119/// let rb = hub.other_contacts();
2120/// # }
2121/// ```
2122pub struct OtherContactMethods<'a, C>
2123where
2124 C: 'a,
2125{
2126 hub: &'a PeopleService<C>,
2127}
2128
2129impl<'a, C> common::MethodsBuilder for OtherContactMethods<'a, C> {}
2130
2131impl<'a, C> OtherContactMethods<'a, C> {
2132 /// Create a builder to help you perform the following task:
2133 ///
2134 /// Copies an "Other contact" to a new contact in the user's "myContacts" group Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2135 ///
2136 /// # Arguments
2137 ///
2138 /// * `request` - No description provided.
2139 /// * `resourceName` - Required. The resource name of the "Other contact" to copy.
2140 pub fn copy_other_contact_to_my_contacts_group(
2141 &self,
2142 request: CopyOtherContactToMyContactsGroupRequest,
2143 resource_name: &str,
2144 ) -> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C> {
2145 OtherContactCopyOtherContactToMyContactsGroupCall {
2146 hub: self.hub,
2147 _request: request,
2148 _resource_name: resource_name.to_string(),
2149 _delegate: Default::default(),
2150 _additional_params: Default::default(),
2151 _scopes: Default::default(),
2152 }
2153 }
2154
2155 /// Create a builder to help you perform the following task:
2156 ///
2157 /// List all “Other contacts”, that is contacts that are not in a contact group. “Other contacts” are typically auto created contacts from interactions. Sync tokens expire 7 days after the full sync. A request with an expired sync token will get an error with an [google.rpc.ErrorInfo](https://cloud.google.com/apis/design/errors#error_info) with reason “EXPIRED_SYNC_TOKEN”. In the case of such an error clients should make a full sync request without a `sync_token`. The first page of a full sync request has an additional quota. If the quota is exceeded, a 429 error will be returned. This quota is fixed and can not be increased. When the `sync_token` is specified, resources deleted since the last sync will be returned as a person with `PersonMetadata.deleted` set to true. When the `page_token` or `sync_token` is specified, all other request parameters must match the first call. Writes may have a propagation delay of several minutes for sync requests. Incremental syncs are not intended for read-after-write use cases. See example usage at [List the user’s other contacts that have changed](https://developers.google.com/people/v1/other-contacts#list_the_users_other_contacts_that_have_changed).
2158 pub fn list(&self) -> OtherContactListCall<'a, C> {
2159 OtherContactListCall {
2160 hub: self.hub,
2161 _sync_token: Default::default(),
2162 _sources: Default::default(),
2163 _request_sync_token: Default::default(),
2164 _read_mask: Default::default(),
2165 _page_token: Default::default(),
2166 _page_size: Default::default(),
2167 _delegate: Default::default(),
2168 _additional_params: Default::default(),
2169 _scopes: Default::default(),
2170 }
2171 }
2172
2173 /// Create a builder to help you perform the following task:
2174 ///
2175 /// Provides a list of contacts in the authenticated user's other contacts that matches the search query. The query matches on a contact's `names`, `emailAddresses`, and `phoneNumbers` fields that are from the OTHER_CONTACT source. **IMPORTANT**: Before searching, clients should send a warmup request with an empty query to update the cache. See https://developers.google.com/people/v1/other-contacts#search_the_users_other_contacts
2176 pub fn search(&self) -> OtherContactSearchCall<'a, C> {
2177 OtherContactSearchCall {
2178 hub: self.hub,
2179 _read_mask: Default::default(),
2180 _query: Default::default(),
2181 _page_size: Default::default(),
2182 _delegate: Default::default(),
2183 _additional_params: Default::default(),
2184 _scopes: Default::default(),
2185 }
2186 }
2187}
2188
2189/// A builder providing access to all methods supported on *person* resources.
2190/// It is not used directly, but through the [`PeopleService`] hub.
2191///
2192/// # Example
2193///
2194/// Instantiate a resource builder
2195///
2196/// ```test_harness,no_run
2197/// extern crate hyper;
2198/// extern crate hyper_rustls;
2199/// extern crate google_people1 as people1;
2200///
2201/// # async fn dox() {
2202/// use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2203///
2204/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2205/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2206/// secret,
2207/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2208/// ).build().await.unwrap();
2209///
2210/// let client = hyper_util::client::legacy::Client::builder(
2211/// hyper_util::rt::TokioExecutor::new()
2212/// )
2213/// .build(
2214/// hyper_rustls::HttpsConnectorBuilder::new()
2215/// .with_native_roots()
2216/// .unwrap()
2217/// .https_or_http()
2218/// .enable_http1()
2219/// .build()
2220/// );
2221/// let mut hub = PeopleService::new(client, auth);
2222/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2223/// // like `batch_create_contacts(...)`, `batch_delete_contacts(...)`, `batch_update_contacts(...)`, `connections_list(...)`, `create_contact(...)`, `delete_contact(...)`, `delete_contact_photo(...)`, `get(...)`, `get_batch_get(...)`, `list_directory_people(...)`, `search_contacts(...)`, `search_directory_people(...)`, `update_contact(...)` and `update_contact_photo(...)`
2224/// // to build up your call.
2225/// let rb = hub.people();
2226/// # }
2227/// ```
2228pub struct PersonMethods<'a, C>
2229where
2230 C: 'a,
2231{
2232 hub: &'a PeopleService<C>,
2233}
2234
2235impl<'a, C> common::MethodsBuilder for PersonMethods<'a, C> {}
2236
2237impl<'a, C> PersonMethods<'a, C> {
2238 /// Create a builder to help you perform the following task:
2239 ///
2240 /// Provides a list of the authenticated user’s contacts. Sync tokens expire 7 days after the full sync. A request with an expired sync token will get an error with an [google.rpc.ErrorInfo](https://cloud.google.com/apis/design/errors#error_info) with reason “EXPIRED_SYNC_TOKEN”. In the case of such an error clients should make a full sync request without a `sync_token`. The first page of a full sync request has an additional quota. If the quota is exceeded, a 429 error will be returned. This quota is fixed and can not be increased. When the `sync_token` is specified, resources deleted since the last sync will be returned as a person with `PersonMetadata.deleted` set to true. When the `page_token` or `sync_token` is specified, all other request parameters must match the first call. Writes may have a propagation delay of several minutes for sync requests. Incremental syncs are not intended for read-after-write use cases. See example usage at [List the user’s contacts that have changed](https://developers.google.com/people/v1/contacts#list_the_users_contacts_that_have_changed).
2241 ///
2242 /// # Arguments
2243 ///
2244 /// * `resourceName` - Required. The resource name to return connections for. Only `people/me` is valid.
2245 pub fn connections_list(&self, resource_name: &str) -> PersonConnectionListCall<'a, C> {
2246 PersonConnectionListCall {
2247 hub: self.hub,
2248 _resource_name: resource_name.to_string(),
2249 _sync_token: Default::default(),
2250 _sources: Default::default(),
2251 _sort_order: Default::default(),
2252 _request_sync_token: Default::default(),
2253 _request_mask_include_field: Default::default(),
2254 _person_fields: Default::default(),
2255 _page_token: Default::default(),
2256 _page_size: Default::default(),
2257 _delegate: Default::default(),
2258 _additional_params: Default::default(),
2259 _scopes: Default::default(),
2260 }
2261 }
2262
2263 /// Create a builder to help you perform the following task:
2264 ///
2265 /// Create a batch of new contacts and return the PersonResponses for the newly Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2266 ///
2267 /// # Arguments
2268 ///
2269 /// * `request` - No description provided.
2270 pub fn batch_create_contacts(
2271 &self,
2272 request: BatchCreateContactsRequest,
2273 ) -> PersonBatchCreateContactCall<'a, C> {
2274 PersonBatchCreateContactCall {
2275 hub: self.hub,
2276 _request: request,
2277 _delegate: Default::default(),
2278 _additional_params: Default::default(),
2279 _scopes: Default::default(),
2280 }
2281 }
2282
2283 /// Create a builder to help you perform the following task:
2284 ///
2285 /// Delete a batch of contacts. Any non-contact data will not be deleted. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2286 ///
2287 /// # Arguments
2288 ///
2289 /// * `request` - No description provided.
2290 pub fn batch_delete_contacts(
2291 &self,
2292 request: BatchDeleteContactsRequest,
2293 ) -> PersonBatchDeleteContactCall<'a, C> {
2294 PersonBatchDeleteContactCall {
2295 hub: self.hub,
2296 _request: request,
2297 _delegate: Default::default(),
2298 _additional_params: Default::default(),
2299 _scopes: Default::default(),
2300 }
2301 }
2302
2303 /// Create a builder to help you perform the following task:
2304 ///
2305 /// Update a batch of contacts and return a map of resource names to PersonResponses for the updated contacts. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2306 ///
2307 /// # Arguments
2308 ///
2309 /// * `request` - No description provided.
2310 pub fn batch_update_contacts(
2311 &self,
2312 request: BatchUpdateContactsRequest,
2313 ) -> PersonBatchUpdateContactCall<'a, C> {
2314 PersonBatchUpdateContactCall {
2315 hub: self.hub,
2316 _request: request,
2317 _delegate: Default::default(),
2318 _additional_params: Default::default(),
2319 _scopes: Default::default(),
2320 }
2321 }
2322
2323 /// Create a builder to help you perform the following task:
2324 ///
2325 /// Create a new contact and return the person resource for that contact. The request returns a 400 error if more than one field is specified on a field that is a singleton for contact sources: * biographies * birthdays * genders * names Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2326 ///
2327 /// # Arguments
2328 ///
2329 /// * `request` - No description provided.
2330 pub fn create_contact(&self, request: Person) -> PersonCreateContactCall<'a, C> {
2331 PersonCreateContactCall {
2332 hub: self.hub,
2333 _request: request,
2334 _sources: Default::default(),
2335 _person_fields: Default::default(),
2336 _delegate: Default::default(),
2337 _additional_params: Default::default(),
2338 _scopes: Default::default(),
2339 }
2340 }
2341
2342 /// Create a builder to help you perform the following task:
2343 ///
2344 /// Delete a contact person. Any non-contact data will not be deleted. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2345 ///
2346 /// # Arguments
2347 ///
2348 /// * `resourceName` - Required. The resource name of the contact to delete.
2349 pub fn delete_contact(&self, resource_name: &str) -> PersonDeleteContactCall<'a, C> {
2350 PersonDeleteContactCall {
2351 hub: self.hub,
2352 _resource_name: resource_name.to_string(),
2353 _delegate: Default::default(),
2354 _additional_params: Default::default(),
2355 _scopes: Default::default(),
2356 }
2357 }
2358
2359 /// Create a builder to help you perform the following task:
2360 ///
2361 /// Delete a contact's photo. Mutate requests for the same user should be done sequentially to avoid // lock contention.
2362 ///
2363 /// # Arguments
2364 ///
2365 /// * `resourceName` - Required. The resource name of the contact whose photo will be deleted.
2366 pub fn delete_contact_photo(&self, resource_name: &str) -> PersonDeleteContactPhotoCall<'a, C> {
2367 PersonDeleteContactPhotoCall {
2368 hub: self.hub,
2369 _resource_name: resource_name.to_string(),
2370 _sources: Default::default(),
2371 _person_fields: Default::default(),
2372 _delegate: Default::default(),
2373 _additional_params: Default::default(),
2374 _scopes: Default::default(),
2375 }
2376 }
2377
2378 /// Create a builder to help you perform the following task:
2379 ///
2380 /// Provides information about a person by specifying a resource name. Use `people/me` to indicate the authenticated user. The request returns a 400 error if 'personFields' is not specified.
2381 ///
2382 /// # Arguments
2383 ///
2384 /// * `resourceName` - Required. The resource name of the person to provide information about. - To get information about the authenticated user, specify `people/me`. - To get information about a google account, specify `people/{account_id}`. - To get information about a contact, specify the resource name that identifies the contact as returned by `people.connections.list`.
2385 pub fn get(&self, resource_name: &str) -> PersonGetCall<'a, C> {
2386 PersonGetCall {
2387 hub: self.hub,
2388 _resource_name: resource_name.to_string(),
2389 _sources: Default::default(),
2390 _request_mask_include_field: Default::default(),
2391 _person_fields: Default::default(),
2392 _delegate: Default::default(),
2393 _additional_params: Default::default(),
2394 _scopes: Default::default(),
2395 }
2396 }
2397
2398 /// Create a builder to help you perform the following task:
2399 ///
2400 /// Provides information about a list of specific people by specifying a list of requested resource names. Use `people/me` to indicate the authenticated user. The request returns a 400 error if 'personFields' is not specified.
2401 pub fn get_batch_get(&self) -> PersonGetBatchGetCall<'a, C> {
2402 PersonGetBatchGetCall {
2403 hub: self.hub,
2404 _sources: Default::default(),
2405 _resource_names: Default::default(),
2406 _request_mask_include_field: Default::default(),
2407 _person_fields: Default::default(),
2408 _delegate: Default::default(),
2409 _additional_params: Default::default(),
2410 _scopes: Default::default(),
2411 }
2412 }
2413
2414 /// Create a builder to help you perform the following task:
2415 ///
2416 /// Provides a list of domain profiles and domain contacts in the authenticated user’s domain directory. When the `sync_token` is specified, resources deleted since the last sync will be returned as a person with `PersonMetadata.deleted` set to true. When the `page_token` or `sync_token` is specified, all other request parameters must match the first call. Writes may have a propagation delay of several minutes for sync requests. Incremental syncs are not intended for read-after-write use cases. See example usage at [List the directory people that have changed](https://developers.google.com/people/v1/directory#list_the_directory_people_that_have_changed).
2417 pub fn list_directory_people(&self) -> PersonListDirectoryPersonCall<'a, C> {
2418 PersonListDirectoryPersonCall {
2419 hub: self.hub,
2420 _sync_token: Default::default(),
2421 _sources: Default::default(),
2422 _request_sync_token: Default::default(),
2423 _read_mask: Default::default(),
2424 _page_token: Default::default(),
2425 _page_size: Default::default(),
2426 _merge_sources: Default::default(),
2427 _delegate: Default::default(),
2428 _additional_params: Default::default(),
2429 _scopes: Default::default(),
2430 }
2431 }
2432
2433 /// Create a builder to help you perform the following task:
2434 ///
2435 /// Provides a list of contacts in the authenticated user's grouped contacts that matches the search query. The query matches on a contact's `names`, `nickNames`, `emailAddresses`, `phoneNumbers`, and `organizations` fields that are from the CONTACT source. **IMPORTANT**: Before searching, clients should send a warmup request with an empty query to update the cache. See https://developers.google.com/people/v1/contacts#search_the_users_contacts
2436 pub fn search_contacts(&self) -> PersonSearchContactCall<'a, C> {
2437 PersonSearchContactCall {
2438 hub: self.hub,
2439 _sources: Default::default(),
2440 _read_mask: Default::default(),
2441 _query: Default::default(),
2442 _page_size: Default::default(),
2443 _delegate: Default::default(),
2444 _additional_params: Default::default(),
2445 _scopes: Default::default(),
2446 }
2447 }
2448
2449 /// Create a builder to help you perform the following task:
2450 ///
2451 /// Provides a list of domain profiles and domain contacts in the authenticated user's domain directory that match the search query.
2452 pub fn search_directory_people(&self) -> PersonSearchDirectoryPersonCall<'a, C> {
2453 PersonSearchDirectoryPersonCall {
2454 hub: self.hub,
2455 _sources: Default::default(),
2456 _read_mask: Default::default(),
2457 _query: Default::default(),
2458 _page_token: Default::default(),
2459 _page_size: Default::default(),
2460 _merge_sources: Default::default(),
2461 _delegate: Default::default(),
2462 _additional_params: Default::default(),
2463 _scopes: Default::default(),
2464 }
2465 }
2466
2467 /// Create a builder to help you perform the following task:
2468 ///
2469 /// Update contact data for an existing contact person. Any non-contact data will not be modified. Any non-contact data in the person to update will be ignored. All fields specified in the `update_mask` will be replaced. The server returns a 400 error if `person.metadata.sources` is not specified for the contact to be updated or if there is no contact source. The server returns a 400 error with reason `"failedPrecondition"` if `person.metadata.sources.etag` is different than the contact's etag, which indicates the contact has changed since its data was read. Clients should get the latest person and merge their updates into the latest person. The server returns a 400 error if `memberships` are being updated and there are no contact group memberships specified on the person. The server returns a 400 error if more than one field is specified on a field that is a singleton for contact sources: * biographies * birthdays * genders * names Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2470 ///
2471 /// # Arguments
2472 ///
2473 /// * `request` - No description provided.
2474 /// * `resourceName` - The resource name for the person, assigned by the server. An ASCII string in the form of `people/{person_id}`.
2475 pub fn update_contact(
2476 &self,
2477 request: Person,
2478 resource_name: &str,
2479 ) -> PersonUpdateContactCall<'a, C> {
2480 PersonUpdateContactCall {
2481 hub: self.hub,
2482 _request: request,
2483 _resource_name: resource_name.to_string(),
2484 _update_person_fields: Default::default(),
2485 _sources: Default::default(),
2486 _person_fields: Default::default(),
2487 _delegate: Default::default(),
2488 _additional_params: Default::default(),
2489 _scopes: Default::default(),
2490 }
2491 }
2492
2493 /// Create a builder to help you perform the following task:
2494 ///
2495 /// Update a contact's photo. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
2496 ///
2497 /// # Arguments
2498 ///
2499 /// * `request` - No description provided.
2500 /// * `resourceName` - Required. Person resource name
2501 pub fn update_contact_photo(
2502 &self,
2503 request: UpdateContactPhotoRequest,
2504 resource_name: &str,
2505 ) -> PersonUpdateContactPhotoCall<'a, C> {
2506 PersonUpdateContactPhotoCall {
2507 hub: self.hub,
2508 _request: request,
2509 _resource_name: resource_name.to_string(),
2510 _delegate: Default::default(),
2511 _additional_params: Default::default(),
2512 _scopes: Default::default(),
2513 }
2514 }
2515}
2516
2517// ###################
2518// CallBuilders ###
2519// #################
2520
2521/// Modify the members of a contact group owned by the authenticated user. The only system contact groups that can have members added are `contactGroups/myContacts` and `contactGroups/starred`. Other system contact groups are deprecated and can only have contacts removed.
2522///
2523/// A builder for the *members.modify* method supported by a *contactGroup* resource.
2524/// It is not used directly, but through a [`ContactGroupMethods`] instance.
2525///
2526/// # Example
2527///
2528/// Instantiate a resource method builder
2529///
2530/// ```test_harness,no_run
2531/// # extern crate hyper;
2532/// # extern crate hyper_rustls;
2533/// # extern crate google_people1 as people1;
2534/// use people1::api::ModifyContactGroupMembersRequest;
2535/// # async fn dox() {
2536/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2537///
2538/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2539/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2540/// # secret,
2541/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2542/// # ).build().await.unwrap();
2543///
2544/// # let client = hyper_util::client::legacy::Client::builder(
2545/// # hyper_util::rt::TokioExecutor::new()
2546/// # )
2547/// # .build(
2548/// # hyper_rustls::HttpsConnectorBuilder::new()
2549/// # .with_native_roots()
2550/// # .unwrap()
2551/// # .https_or_http()
2552/// # .enable_http1()
2553/// # .build()
2554/// # );
2555/// # let mut hub = PeopleService::new(client, auth);
2556/// // As the method needs a request, you would usually fill it with the desired information
2557/// // into the respective structure. Some of the parts shown here might not be applicable !
2558/// // Values shown here are possibly random and not representative !
2559/// let mut req = ModifyContactGroupMembersRequest::default();
2560///
2561/// // You can configure optional parameters by calling the respective setters at will, and
2562/// // execute the final call using `doit()`.
2563/// // Values shown here are possibly random and not representative !
2564/// let result = hub.contact_groups().members_modify(req, "resourceName")
2565/// .doit().await;
2566/// # }
2567/// ```
2568pub struct ContactGroupMemberModifyCall<'a, C>
2569where
2570 C: 'a,
2571{
2572 hub: &'a PeopleService<C>,
2573 _request: ModifyContactGroupMembersRequest,
2574 _resource_name: String,
2575 _delegate: Option<&'a mut dyn common::Delegate>,
2576 _additional_params: HashMap<String, String>,
2577 _scopes: BTreeSet<String>,
2578}
2579
2580impl<'a, C> common::CallBuilder for ContactGroupMemberModifyCall<'a, C> {}
2581
2582impl<'a, C> ContactGroupMemberModifyCall<'a, C>
2583where
2584 C: common::Connector,
2585{
2586 /// Perform the operation you have build so far.
2587 pub async fn doit(
2588 mut self,
2589 ) -> common::Result<(common::Response, ModifyContactGroupMembersResponse)> {
2590 use std::borrow::Cow;
2591 use std::io::{Read, Seek};
2592
2593 use common::{url::Params, ToParts};
2594 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2595
2596 let mut dd = common::DefaultDelegate;
2597 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2598 dlg.begin(common::MethodInfo {
2599 id: "people.contactGroups.members.modify",
2600 http_method: hyper::Method::POST,
2601 });
2602
2603 for &field in ["alt", "resourceName"].iter() {
2604 if self._additional_params.contains_key(field) {
2605 dlg.finished(false);
2606 return Err(common::Error::FieldClash(field));
2607 }
2608 }
2609
2610 let mut params = Params::with_capacity(4 + self._additional_params.len());
2611 params.push("resourceName", self._resource_name);
2612
2613 params.extend(self._additional_params.iter());
2614
2615 params.push("alt", "json");
2616 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}/members:modify";
2617 if self._scopes.is_empty() {
2618 self._scopes.insert(Scope::Contact.as_ref().to_string());
2619 }
2620
2621 #[allow(clippy::single_element_loop)]
2622 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
2623 url = params.uri_replacement(url, param_name, find_this, true);
2624 }
2625 {
2626 let to_remove = ["resourceName"];
2627 params.remove_params(&to_remove);
2628 }
2629
2630 let url = params.parse_with_url(&url);
2631
2632 let mut json_mime_type = mime::APPLICATION_JSON;
2633 let mut request_value_reader = {
2634 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2635 common::remove_json_null_values(&mut value);
2636 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2637 serde_json::to_writer(&mut dst, &value).unwrap();
2638 dst
2639 };
2640 let request_size = request_value_reader
2641 .seek(std::io::SeekFrom::End(0))
2642 .unwrap();
2643 request_value_reader
2644 .seek(std::io::SeekFrom::Start(0))
2645 .unwrap();
2646
2647 loop {
2648 let token = match self
2649 .hub
2650 .auth
2651 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2652 .await
2653 {
2654 Ok(token) => token,
2655 Err(e) => match dlg.token(e) {
2656 Ok(token) => token,
2657 Err(e) => {
2658 dlg.finished(false);
2659 return Err(common::Error::MissingToken(e));
2660 }
2661 },
2662 };
2663 request_value_reader
2664 .seek(std::io::SeekFrom::Start(0))
2665 .unwrap();
2666 let mut req_result = {
2667 let client = &self.hub.client;
2668 dlg.pre_request();
2669 let mut req_builder = hyper::Request::builder()
2670 .method(hyper::Method::POST)
2671 .uri(url.as_str())
2672 .header(USER_AGENT, self.hub._user_agent.clone());
2673
2674 if let Some(token) = token.as_ref() {
2675 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2676 }
2677
2678 let request = req_builder
2679 .header(CONTENT_TYPE, json_mime_type.to_string())
2680 .header(CONTENT_LENGTH, request_size as u64)
2681 .body(common::to_body(
2682 request_value_reader.get_ref().clone().into(),
2683 ));
2684
2685 client.request(request.unwrap()).await
2686 };
2687
2688 match req_result {
2689 Err(err) => {
2690 if let common::Retry::After(d) = dlg.http_error(&err) {
2691 sleep(d).await;
2692 continue;
2693 }
2694 dlg.finished(false);
2695 return Err(common::Error::HttpError(err));
2696 }
2697 Ok(res) => {
2698 let (mut parts, body) = res.into_parts();
2699 let mut body = common::Body::new(body);
2700 if !parts.status.is_success() {
2701 let bytes = common::to_bytes(body).await.unwrap_or_default();
2702 let error = serde_json::from_str(&common::to_string(&bytes));
2703 let response = common::to_response(parts, bytes.into());
2704
2705 if let common::Retry::After(d) =
2706 dlg.http_failure(&response, error.as_ref().ok())
2707 {
2708 sleep(d).await;
2709 continue;
2710 }
2711
2712 dlg.finished(false);
2713
2714 return Err(match error {
2715 Ok(value) => common::Error::BadRequest(value),
2716 _ => common::Error::Failure(response),
2717 });
2718 }
2719 let response = {
2720 let bytes = common::to_bytes(body).await.unwrap_or_default();
2721 let encoded = common::to_string(&bytes);
2722 match serde_json::from_str(&encoded) {
2723 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2724 Err(error) => {
2725 dlg.response_json_decode_error(&encoded, &error);
2726 return Err(common::Error::JsonDecodeError(
2727 encoded.to_string(),
2728 error,
2729 ));
2730 }
2731 }
2732 };
2733
2734 dlg.finished(true);
2735 return Ok(response);
2736 }
2737 }
2738 }
2739 }
2740
2741 ///
2742 /// Sets the *request* property to the given value.
2743 ///
2744 /// Even though the property as already been set when instantiating this call,
2745 /// we provide this method for API completeness.
2746 pub fn request(
2747 mut self,
2748 new_value: ModifyContactGroupMembersRequest,
2749 ) -> ContactGroupMemberModifyCall<'a, C> {
2750 self._request = new_value;
2751 self
2752 }
2753 /// Required. The resource name of the contact group to modify.
2754 ///
2755 /// Sets the *resource name* path property to the given value.
2756 ///
2757 /// Even though the property as already been set when instantiating this call,
2758 /// we provide this method for API completeness.
2759 pub fn resource_name(mut self, new_value: &str) -> ContactGroupMemberModifyCall<'a, C> {
2760 self._resource_name = new_value.to_string();
2761 self
2762 }
2763 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2764 /// while executing the actual API request.
2765 ///
2766 /// ````text
2767 /// It should be used to handle progress information, and to implement a certain level of resilience.
2768 /// ````
2769 ///
2770 /// Sets the *delegate* property to the given value.
2771 pub fn delegate(
2772 mut self,
2773 new_value: &'a mut dyn common::Delegate,
2774 ) -> ContactGroupMemberModifyCall<'a, C> {
2775 self._delegate = Some(new_value);
2776 self
2777 }
2778
2779 /// Set any additional parameter of the query string used in the request.
2780 /// It should be used to set parameters which are not yet available through their own
2781 /// setters.
2782 ///
2783 /// Please note that this method must not be used to set any of the known parameters
2784 /// which have their own setter method. If done anyway, the request will fail.
2785 ///
2786 /// # Additional Parameters
2787 ///
2788 /// * *$.xgafv* (query-string) - V1 error format.
2789 /// * *access_token* (query-string) - OAuth access token.
2790 /// * *alt* (query-string) - Data format for response.
2791 /// * *callback* (query-string) - JSONP
2792 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2793 /// * *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.
2794 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2795 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2796 /// * *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.
2797 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2798 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2799 pub fn param<T>(mut self, name: T, value: T) -> ContactGroupMemberModifyCall<'a, C>
2800 where
2801 T: AsRef<str>,
2802 {
2803 self._additional_params
2804 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2805 self
2806 }
2807
2808 /// Identifies the authorization scope for the method you are building.
2809 ///
2810 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2811 /// [`Scope::Contact`].
2812 ///
2813 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2814 /// tokens for more than one scope.
2815 ///
2816 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2817 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2818 /// sufficient, a read-write scope will do as well.
2819 pub fn add_scope<St>(mut self, scope: St) -> ContactGroupMemberModifyCall<'a, C>
2820 where
2821 St: AsRef<str>,
2822 {
2823 self._scopes.insert(String::from(scope.as_ref()));
2824 self
2825 }
2826 /// Identifies the authorization scope(s) for the method you are building.
2827 ///
2828 /// See [`Self::add_scope()`] for details.
2829 pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactGroupMemberModifyCall<'a, C>
2830 where
2831 I: IntoIterator<Item = St>,
2832 St: AsRef<str>,
2833 {
2834 self._scopes
2835 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2836 self
2837 }
2838
2839 /// Removes all scopes, and no default scope will be used either.
2840 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2841 /// for details).
2842 pub fn clear_scopes(mut self) -> ContactGroupMemberModifyCall<'a, C> {
2843 self._scopes.clear();
2844 self
2845 }
2846}
2847
2848/// Get a list of contact groups owned by the authenticated user by specifying a list of contact group resource names.
2849///
2850/// A builder for the *batchGet* method supported by a *contactGroup* resource.
2851/// It is not used directly, but through a [`ContactGroupMethods`] instance.
2852///
2853/// # Example
2854///
2855/// Instantiate a resource method builder
2856///
2857/// ```test_harness,no_run
2858/// # extern crate hyper;
2859/// # extern crate hyper_rustls;
2860/// # extern crate google_people1 as people1;
2861/// # async fn dox() {
2862/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2863///
2864/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2865/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2866/// # secret,
2867/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2868/// # ).build().await.unwrap();
2869///
2870/// # let client = hyper_util::client::legacy::Client::builder(
2871/// # hyper_util::rt::TokioExecutor::new()
2872/// # )
2873/// # .build(
2874/// # hyper_rustls::HttpsConnectorBuilder::new()
2875/// # .with_native_roots()
2876/// # .unwrap()
2877/// # .https_or_http()
2878/// # .enable_http1()
2879/// # .build()
2880/// # );
2881/// # let mut hub = PeopleService::new(client, auth);
2882/// // You can configure optional parameters by calling the respective setters at will, and
2883/// // execute the final call using `doit()`.
2884/// // Values shown here are possibly random and not representative !
2885/// let result = hub.contact_groups().batch_get()
2886/// .add_resource_names("amet.")
2887/// .max_members(-20)
2888/// .group_fields(FieldMask::new::<&str>(&[]))
2889/// .doit().await;
2890/// # }
2891/// ```
2892pub struct ContactGroupBatchGetCall<'a, C>
2893where
2894 C: 'a,
2895{
2896 hub: &'a PeopleService<C>,
2897 _resource_names: Vec<String>,
2898 _max_members: Option<i32>,
2899 _group_fields: Option<common::FieldMask>,
2900 _delegate: Option<&'a mut dyn common::Delegate>,
2901 _additional_params: HashMap<String, String>,
2902 _scopes: BTreeSet<String>,
2903}
2904
2905impl<'a, C> common::CallBuilder for ContactGroupBatchGetCall<'a, C> {}
2906
2907impl<'a, C> ContactGroupBatchGetCall<'a, C>
2908where
2909 C: common::Connector,
2910{
2911 /// Perform the operation you have build so far.
2912 pub async fn doit(
2913 mut self,
2914 ) -> common::Result<(common::Response, BatchGetContactGroupsResponse)> {
2915 use std::borrow::Cow;
2916 use std::io::{Read, Seek};
2917
2918 use common::{url::Params, ToParts};
2919 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2920
2921 let mut dd = common::DefaultDelegate;
2922 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2923 dlg.begin(common::MethodInfo {
2924 id: "people.contactGroups.batchGet",
2925 http_method: hyper::Method::GET,
2926 });
2927
2928 for &field in ["alt", "resourceNames", "maxMembers", "groupFields"].iter() {
2929 if self._additional_params.contains_key(field) {
2930 dlg.finished(false);
2931 return Err(common::Error::FieldClash(field));
2932 }
2933 }
2934
2935 let mut params = Params::with_capacity(5 + self._additional_params.len());
2936 if !self._resource_names.is_empty() {
2937 for f in self._resource_names.iter() {
2938 params.push("resourceNames", f);
2939 }
2940 }
2941 if let Some(value) = self._max_members.as_ref() {
2942 params.push("maxMembers", value.to_string());
2943 }
2944 if let Some(value) = self._group_fields.as_ref() {
2945 params.push("groupFields", value.to_string());
2946 }
2947
2948 params.extend(self._additional_params.iter());
2949
2950 params.push("alt", "json");
2951 let mut url = self.hub._base_url.clone() + "v1/contactGroups:batchGet";
2952 if self._scopes.is_empty() {
2953 self._scopes
2954 .insert(Scope::ContactReadonly.as_ref().to_string());
2955 }
2956
2957 let url = params.parse_with_url(&url);
2958
2959 loop {
2960 let token = match self
2961 .hub
2962 .auth
2963 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2964 .await
2965 {
2966 Ok(token) => token,
2967 Err(e) => match dlg.token(e) {
2968 Ok(token) => token,
2969 Err(e) => {
2970 dlg.finished(false);
2971 return Err(common::Error::MissingToken(e));
2972 }
2973 },
2974 };
2975 let mut req_result = {
2976 let client = &self.hub.client;
2977 dlg.pre_request();
2978 let mut req_builder = hyper::Request::builder()
2979 .method(hyper::Method::GET)
2980 .uri(url.as_str())
2981 .header(USER_AGENT, self.hub._user_agent.clone());
2982
2983 if let Some(token) = token.as_ref() {
2984 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2985 }
2986
2987 let request = req_builder
2988 .header(CONTENT_LENGTH, 0_u64)
2989 .body(common::to_body::<String>(None));
2990
2991 client.request(request.unwrap()).await
2992 };
2993
2994 match req_result {
2995 Err(err) => {
2996 if let common::Retry::After(d) = dlg.http_error(&err) {
2997 sleep(d).await;
2998 continue;
2999 }
3000 dlg.finished(false);
3001 return Err(common::Error::HttpError(err));
3002 }
3003 Ok(res) => {
3004 let (mut parts, body) = res.into_parts();
3005 let mut body = common::Body::new(body);
3006 if !parts.status.is_success() {
3007 let bytes = common::to_bytes(body).await.unwrap_or_default();
3008 let error = serde_json::from_str(&common::to_string(&bytes));
3009 let response = common::to_response(parts, bytes.into());
3010
3011 if let common::Retry::After(d) =
3012 dlg.http_failure(&response, error.as_ref().ok())
3013 {
3014 sleep(d).await;
3015 continue;
3016 }
3017
3018 dlg.finished(false);
3019
3020 return Err(match error {
3021 Ok(value) => common::Error::BadRequest(value),
3022 _ => common::Error::Failure(response),
3023 });
3024 }
3025 let response = {
3026 let bytes = common::to_bytes(body).await.unwrap_or_default();
3027 let encoded = common::to_string(&bytes);
3028 match serde_json::from_str(&encoded) {
3029 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3030 Err(error) => {
3031 dlg.response_json_decode_error(&encoded, &error);
3032 return Err(common::Error::JsonDecodeError(
3033 encoded.to_string(),
3034 error,
3035 ));
3036 }
3037 }
3038 };
3039
3040 dlg.finished(true);
3041 return Ok(response);
3042 }
3043 }
3044 }
3045 }
3046
3047 /// Required. The resource names of the contact groups to get. There is a maximum of 200 resource names.
3048 ///
3049 /// Append the given value to the *resource names* query property.
3050 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3051 pub fn add_resource_names(mut self, new_value: &str) -> ContactGroupBatchGetCall<'a, C> {
3052 self._resource_names.push(new_value.to_string());
3053 self
3054 }
3055 /// Optional. Specifies the maximum number of members to return for each group. Defaults to 0 if not set, which will return zero members.
3056 ///
3057 /// Sets the *max members* query property to the given value.
3058 pub fn max_members(mut self, new_value: i32) -> ContactGroupBatchGetCall<'a, C> {
3059 self._max_members = Some(new_value);
3060 self
3061 }
3062 /// Optional. A field mask to restrict which fields on the group are returned. Defaults to `metadata`, `groupType`, `memberCount`, and `name` if not set or set to empty. Valid fields are: * clientData * groupType * memberCount * metadata * name
3063 ///
3064 /// Sets the *group fields* query property to the given value.
3065 pub fn group_fields(mut self, new_value: common::FieldMask) -> ContactGroupBatchGetCall<'a, C> {
3066 self._group_fields = Some(new_value);
3067 self
3068 }
3069 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3070 /// while executing the actual API request.
3071 ///
3072 /// ````text
3073 /// It should be used to handle progress information, and to implement a certain level of resilience.
3074 /// ````
3075 ///
3076 /// Sets the *delegate* property to the given value.
3077 pub fn delegate(
3078 mut self,
3079 new_value: &'a mut dyn common::Delegate,
3080 ) -> ContactGroupBatchGetCall<'a, C> {
3081 self._delegate = Some(new_value);
3082 self
3083 }
3084
3085 /// Set any additional parameter of the query string used in the request.
3086 /// It should be used to set parameters which are not yet available through their own
3087 /// setters.
3088 ///
3089 /// Please note that this method must not be used to set any of the known parameters
3090 /// which have their own setter method. If done anyway, the request will fail.
3091 ///
3092 /// # Additional Parameters
3093 ///
3094 /// * *$.xgafv* (query-string) - V1 error format.
3095 /// * *access_token* (query-string) - OAuth access token.
3096 /// * *alt* (query-string) - Data format for response.
3097 /// * *callback* (query-string) - JSONP
3098 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3099 /// * *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.
3100 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3101 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3102 /// * *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.
3103 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3104 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3105 pub fn param<T>(mut self, name: T, value: T) -> ContactGroupBatchGetCall<'a, C>
3106 where
3107 T: AsRef<str>,
3108 {
3109 self._additional_params
3110 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3111 self
3112 }
3113
3114 /// Identifies the authorization scope for the method you are building.
3115 ///
3116 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3117 /// [`Scope::ContactReadonly`].
3118 ///
3119 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3120 /// tokens for more than one scope.
3121 ///
3122 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3123 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3124 /// sufficient, a read-write scope will do as well.
3125 pub fn add_scope<St>(mut self, scope: St) -> ContactGroupBatchGetCall<'a, C>
3126 where
3127 St: AsRef<str>,
3128 {
3129 self._scopes.insert(String::from(scope.as_ref()));
3130 self
3131 }
3132 /// Identifies the authorization scope(s) for the method you are building.
3133 ///
3134 /// See [`Self::add_scope()`] for details.
3135 pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactGroupBatchGetCall<'a, C>
3136 where
3137 I: IntoIterator<Item = St>,
3138 St: AsRef<str>,
3139 {
3140 self._scopes
3141 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3142 self
3143 }
3144
3145 /// Removes all scopes, and no default scope will be used either.
3146 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3147 /// for details).
3148 pub fn clear_scopes(mut self) -> ContactGroupBatchGetCall<'a, C> {
3149 self._scopes.clear();
3150 self
3151 }
3152}
3153
3154/// Create a new contact group owned by the authenticated user. Created contact group names must be unique to the users contact groups. Attempting to create a group with a duplicate name will return a HTTP 409 error. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
3155///
3156/// A builder for the *create* method supported by a *contactGroup* resource.
3157/// It is not used directly, but through a [`ContactGroupMethods`] instance.
3158///
3159/// # Example
3160///
3161/// Instantiate a resource method builder
3162///
3163/// ```test_harness,no_run
3164/// # extern crate hyper;
3165/// # extern crate hyper_rustls;
3166/// # extern crate google_people1 as people1;
3167/// use people1::api::CreateContactGroupRequest;
3168/// # async fn dox() {
3169/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3170///
3171/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3172/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3173/// # secret,
3174/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3175/// # ).build().await.unwrap();
3176///
3177/// # let client = hyper_util::client::legacy::Client::builder(
3178/// # hyper_util::rt::TokioExecutor::new()
3179/// # )
3180/// # .build(
3181/// # hyper_rustls::HttpsConnectorBuilder::new()
3182/// # .with_native_roots()
3183/// # .unwrap()
3184/// # .https_or_http()
3185/// # .enable_http1()
3186/// # .build()
3187/// # );
3188/// # let mut hub = PeopleService::new(client, auth);
3189/// // As the method needs a request, you would usually fill it with the desired information
3190/// // into the respective structure. Some of the parts shown here might not be applicable !
3191/// // Values shown here are possibly random and not representative !
3192/// let mut req = CreateContactGroupRequest::default();
3193///
3194/// // You can configure optional parameters by calling the respective setters at will, and
3195/// // execute the final call using `doit()`.
3196/// // Values shown here are possibly random and not representative !
3197/// let result = hub.contact_groups().create(req)
3198/// .doit().await;
3199/// # }
3200/// ```
3201pub struct ContactGroupCreateCall<'a, C>
3202where
3203 C: 'a,
3204{
3205 hub: &'a PeopleService<C>,
3206 _request: CreateContactGroupRequest,
3207 _delegate: Option<&'a mut dyn common::Delegate>,
3208 _additional_params: HashMap<String, String>,
3209 _scopes: BTreeSet<String>,
3210}
3211
3212impl<'a, C> common::CallBuilder for ContactGroupCreateCall<'a, C> {}
3213
3214impl<'a, C> ContactGroupCreateCall<'a, C>
3215where
3216 C: common::Connector,
3217{
3218 /// Perform the operation you have build so far.
3219 pub async fn doit(mut self) -> common::Result<(common::Response, ContactGroup)> {
3220 use std::borrow::Cow;
3221 use std::io::{Read, Seek};
3222
3223 use common::{url::Params, ToParts};
3224 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3225
3226 let mut dd = common::DefaultDelegate;
3227 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3228 dlg.begin(common::MethodInfo {
3229 id: "people.contactGroups.create",
3230 http_method: hyper::Method::POST,
3231 });
3232
3233 for &field in ["alt"].iter() {
3234 if self._additional_params.contains_key(field) {
3235 dlg.finished(false);
3236 return Err(common::Error::FieldClash(field));
3237 }
3238 }
3239
3240 let mut params = Params::with_capacity(3 + self._additional_params.len());
3241
3242 params.extend(self._additional_params.iter());
3243
3244 params.push("alt", "json");
3245 let mut url = self.hub._base_url.clone() + "v1/contactGroups";
3246 if self._scopes.is_empty() {
3247 self._scopes.insert(Scope::Contact.as_ref().to_string());
3248 }
3249
3250 let url = params.parse_with_url(&url);
3251
3252 let mut json_mime_type = mime::APPLICATION_JSON;
3253 let mut request_value_reader = {
3254 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3255 common::remove_json_null_values(&mut value);
3256 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3257 serde_json::to_writer(&mut dst, &value).unwrap();
3258 dst
3259 };
3260 let request_size = request_value_reader
3261 .seek(std::io::SeekFrom::End(0))
3262 .unwrap();
3263 request_value_reader
3264 .seek(std::io::SeekFrom::Start(0))
3265 .unwrap();
3266
3267 loop {
3268 let token = match self
3269 .hub
3270 .auth
3271 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3272 .await
3273 {
3274 Ok(token) => token,
3275 Err(e) => match dlg.token(e) {
3276 Ok(token) => token,
3277 Err(e) => {
3278 dlg.finished(false);
3279 return Err(common::Error::MissingToken(e));
3280 }
3281 },
3282 };
3283 request_value_reader
3284 .seek(std::io::SeekFrom::Start(0))
3285 .unwrap();
3286 let mut req_result = {
3287 let client = &self.hub.client;
3288 dlg.pre_request();
3289 let mut req_builder = hyper::Request::builder()
3290 .method(hyper::Method::POST)
3291 .uri(url.as_str())
3292 .header(USER_AGENT, self.hub._user_agent.clone());
3293
3294 if let Some(token) = token.as_ref() {
3295 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3296 }
3297
3298 let request = req_builder
3299 .header(CONTENT_TYPE, json_mime_type.to_string())
3300 .header(CONTENT_LENGTH, request_size as u64)
3301 .body(common::to_body(
3302 request_value_reader.get_ref().clone().into(),
3303 ));
3304
3305 client.request(request.unwrap()).await
3306 };
3307
3308 match req_result {
3309 Err(err) => {
3310 if let common::Retry::After(d) = dlg.http_error(&err) {
3311 sleep(d).await;
3312 continue;
3313 }
3314 dlg.finished(false);
3315 return Err(common::Error::HttpError(err));
3316 }
3317 Ok(res) => {
3318 let (mut parts, body) = res.into_parts();
3319 let mut body = common::Body::new(body);
3320 if !parts.status.is_success() {
3321 let bytes = common::to_bytes(body).await.unwrap_or_default();
3322 let error = serde_json::from_str(&common::to_string(&bytes));
3323 let response = common::to_response(parts, bytes.into());
3324
3325 if let common::Retry::After(d) =
3326 dlg.http_failure(&response, error.as_ref().ok())
3327 {
3328 sleep(d).await;
3329 continue;
3330 }
3331
3332 dlg.finished(false);
3333
3334 return Err(match error {
3335 Ok(value) => common::Error::BadRequest(value),
3336 _ => common::Error::Failure(response),
3337 });
3338 }
3339 let response = {
3340 let bytes = common::to_bytes(body).await.unwrap_or_default();
3341 let encoded = common::to_string(&bytes);
3342 match serde_json::from_str(&encoded) {
3343 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3344 Err(error) => {
3345 dlg.response_json_decode_error(&encoded, &error);
3346 return Err(common::Error::JsonDecodeError(
3347 encoded.to_string(),
3348 error,
3349 ));
3350 }
3351 }
3352 };
3353
3354 dlg.finished(true);
3355 return Ok(response);
3356 }
3357 }
3358 }
3359 }
3360
3361 ///
3362 /// Sets the *request* property to the given value.
3363 ///
3364 /// Even though the property as already been set when instantiating this call,
3365 /// we provide this method for API completeness.
3366 pub fn request(
3367 mut self,
3368 new_value: CreateContactGroupRequest,
3369 ) -> ContactGroupCreateCall<'a, C> {
3370 self._request = new_value;
3371 self
3372 }
3373 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3374 /// while executing the actual API request.
3375 ///
3376 /// ````text
3377 /// It should be used to handle progress information, and to implement a certain level of resilience.
3378 /// ````
3379 ///
3380 /// Sets the *delegate* property to the given value.
3381 pub fn delegate(
3382 mut self,
3383 new_value: &'a mut dyn common::Delegate,
3384 ) -> ContactGroupCreateCall<'a, C> {
3385 self._delegate = Some(new_value);
3386 self
3387 }
3388
3389 /// Set any additional parameter of the query string used in the request.
3390 /// It should be used to set parameters which are not yet available through their own
3391 /// setters.
3392 ///
3393 /// Please note that this method must not be used to set any of the known parameters
3394 /// which have their own setter method. If done anyway, the request will fail.
3395 ///
3396 /// # Additional Parameters
3397 ///
3398 /// * *$.xgafv* (query-string) - V1 error format.
3399 /// * *access_token* (query-string) - OAuth access token.
3400 /// * *alt* (query-string) - Data format for response.
3401 /// * *callback* (query-string) - JSONP
3402 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3403 /// * *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.
3404 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3405 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3406 /// * *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.
3407 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3408 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3409 pub fn param<T>(mut self, name: T, value: T) -> ContactGroupCreateCall<'a, C>
3410 where
3411 T: AsRef<str>,
3412 {
3413 self._additional_params
3414 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3415 self
3416 }
3417
3418 /// Identifies the authorization scope for the method you are building.
3419 ///
3420 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3421 /// [`Scope::Contact`].
3422 ///
3423 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3424 /// tokens for more than one scope.
3425 ///
3426 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3427 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3428 /// sufficient, a read-write scope will do as well.
3429 pub fn add_scope<St>(mut self, scope: St) -> ContactGroupCreateCall<'a, C>
3430 where
3431 St: AsRef<str>,
3432 {
3433 self._scopes.insert(String::from(scope.as_ref()));
3434 self
3435 }
3436 /// Identifies the authorization scope(s) for the method you are building.
3437 ///
3438 /// See [`Self::add_scope()`] for details.
3439 pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactGroupCreateCall<'a, C>
3440 where
3441 I: IntoIterator<Item = St>,
3442 St: AsRef<str>,
3443 {
3444 self._scopes
3445 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3446 self
3447 }
3448
3449 /// Removes all scopes, and no default scope will be used either.
3450 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3451 /// for details).
3452 pub fn clear_scopes(mut self) -> ContactGroupCreateCall<'a, C> {
3453 self._scopes.clear();
3454 self
3455 }
3456}
3457
3458/// Delete an existing contact group owned by the authenticated user by specifying a contact group resource name. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
3459///
3460/// A builder for the *delete* method supported by a *contactGroup* resource.
3461/// It is not used directly, but through a [`ContactGroupMethods`] instance.
3462///
3463/// # Example
3464///
3465/// Instantiate a resource method builder
3466///
3467/// ```test_harness,no_run
3468/// # extern crate hyper;
3469/// # extern crate hyper_rustls;
3470/// # extern crate google_people1 as people1;
3471/// # async fn dox() {
3472/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3473///
3474/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3475/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3476/// # secret,
3477/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3478/// # ).build().await.unwrap();
3479///
3480/// # let client = hyper_util::client::legacy::Client::builder(
3481/// # hyper_util::rt::TokioExecutor::new()
3482/// # )
3483/// # .build(
3484/// # hyper_rustls::HttpsConnectorBuilder::new()
3485/// # .with_native_roots()
3486/// # .unwrap()
3487/// # .https_or_http()
3488/// # .enable_http1()
3489/// # .build()
3490/// # );
3491/// # let mut hub = PeopleService::new(client, auth);
3492/// // You can configure optional parameters by calling the respective setters at will, and
3493/// // execute the final call using `doit()`.
3494/// // Values shown here are possibly random and not representative !
3495/// let result = hub.contact_groups().delete("resourceName")
3496/// .delete_contacts(true)
3497/// .doit().await;
3498/// # }
3499/// ```
3500pub struct ContactGroupDeleteCall<'a, C>
3501where
3502 C: 'a,
3503{
3504 hub: &'a PeopleService<C>,
3505 _resource_name: String,
3506 _delete_contacts: Option<bool>,
3507 _delegate: Option<&'a mut dyn common::Delegate>,
3508 _additional_params: HashMap<String, String>,
3509 _scopes: BTreeSet<String>,
3510}
3511
3512impl<'a, C> common::CallBuilder for ContactGroupDeleteCall<'a, C> {}
3513
3514impl<'a, C> ContactGroupDeleteCall<'a, C>
3515where
3516 C: common::Connector,
3517{
3518 /// Perform the operation you have build so far.
3519 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3520 use std::borrow::Cow;
3521 use std::io::{Read, Seek};
3522
3523 use common::{url::Params, ToParts};
3524 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3525
3526 let mut dd = common::DefaultDelegate;
3527 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3528 dlg.begin(common::MethodInfo {
3529 id: "people.contactGroups.delete",
3530 http_method: hyper::Method::DELETE,
3531 });
3532
3533 for &field in ["alt", "resourceName", "deleteContacts"].iter() {
3534 if self._additional_params.contains_key(field) {
3535 dlg.finished(false);
3536 return Err(common::Error::FieldClash(field));
3537 }
3538 }
3539
3540 let mut params = Params::with_capacity(4 + self._additional_params.len());
3541 params.push("resourceName", self._resource_name);
3542 if let Some(value) = self._delete_contacts.as_ref() {
3543 params.push("deleteContacts", value.to_string());
3544 }
3545
3546 params.extend(self._additional_params.iter());
3547
3548 params.push("alt", "json");
3549 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}";
3550 if self._scopes.is_empty() {
3551 self._scopes.insert(Scope::Contact.as_ref().to_string());
3552 }
3553
3554 #[allow(clippy::single_element_loop)]
3555 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
3556 url = params.uri_replacement(url, param_name, find_this, true);
3557 }
3558 {
3559 let to_remove = ["resourceName"];
3560 params.remove_params(&to_remove);
3561 }
3562
3563 let url = params.parse_with_url(&url);
3564
3565 loop {
3566 let token = match self
3567 .hub
3568 .auth
3569 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3570 .await
3571 {
3572 Ok(token) => token,
3573 Err(e) => match dlg.token(e) {
3574 Ok(token) => token,
3575 Err(e) => {
3576 dlg.finished(false);
3577 return Err(common::Error::MissingToken(e));
3578 }
3579 },
3580 };
3581 let mut req_result = {
3582 let client = &self.hub.client;
3583 dlg.pre_request();
3584 let mut req_builder = hyper::Request::builder()
3585 .method(hyper::Method::DELETE)
3586 .uri(url.as_str())
3587 .header(USER_AGENT, self.hub._user_agent.clone());
3588
3589 if let Some(token) = token.as_ref() {
3590 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3591 }
3592
3593 let request = req_builder
3594 .header(CONTENT_LENGTH, 0_u64)
3595 .body(common::to_body::<String>(None));
3596
3597 client.request(request.unwrap()).await
3598 };
3599
3600 match req_result {
3601 Err(err) => {
3602 if let common::Retry::After(d) = dlg.http_error(&err) {
3603 sleep(d).await;
3604 continue;
3605 }
3606 dlg.finished(false);
3607 return Err(common::Error::HttpError(err));
3608 }
3609 Ok(res) => {
3610 let (mut parts, body) = res.into_parts();
3611 let mut body = common::Body::new(body);
3612 if !parts.status.is_success() {
3613 let bytes = common::to_bytes(body).await.unwrap_or_default();
3614 let error = serde_json::from_str(&common::to_string(&bytes));
3615 let response = common::to_response(parts, bytes.into());
3616
3617 if let common::Retry::After(d) =
3618 dlg.http_failure(&response, error.as_ref().ok())
3619 {
3620 sleep(d).await;
3621 continue;
3622 }
3623
3624 dlg.finished(false);
3625
3626 return Err(match error {
3627 Ok(value) => common::Error::BadRequest(value),
3628 _ => common::Error::Failure(response),
3629 });
3630 }
3631 let response = {
3632 let bytes = common::to_bytes(body).await.unwrap_or_default();
3633 let encoded = common::to_string(&bytes);
3634 match serde_json::from_str(&encoded) {
3635 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3636 Err(error) => {
3637 dlg.response_json_decode_error(&encoded, &error);
3638 return Err(common::Error::JsonDecodeError(
3639 encoded.to_string(),
3640 error,
3641 ));
3642 }
3643 }
3644 };
3645
3646 dlg.finished(true);
3647 return Ok(response);
3648 }
3649 }
3650 }
3651 }
3652
3653 /// Required. The resource name of the contact group to delete.
3654 ///
3655 /// Sets the *resource name* path property to the given value.
3656 ///
3657 /// Even though the property as already been set when instantiating this call,
3658 /// we provide this method for API completeness.
3659 pub fn resource_name(mut self, new_value: &str) -> ContactGroupDeleteCall<'a, C> {
3660 self._resource_name = new_value.to_string();
3661 self
3662 }
3663 /// Optional. Set to true to also delete the contacts in the specified group.
3664 ///
3665 /// Sets the *delete contacts* query property to the given value.
3666 pub fn delete_contacts(mut self, new_value: bool) -> ContactGroupDeleteCall<'a, C> {
3667 self._delete_contacts = Some(new_value);
3668 self
3669 }
3670 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3671 /// while executing the actual API request.
3672 ///
3673 /// ````text
3674 /// It should be used to handle progress information, and to implement a certain level of resilience.
3675 /// ````
3676 ///
3677 /// Sets the *delegate* property to the given value.
3678 pub fn delegate(
3679 mut self,
3680 new_value: &'a mut dyn common::Delegate,
3681 ) -> ContactGroupDeleteCall<'a, C> {
3682 self._delegate = Some(new_value);
3683 self
3684 }
3685
3686 /// Set any additional parameter of the query string used in the request.
3687 /// It should be used to set parameters which are not yet available through their own
3688 /// setters.
3689 ///
3690 /// Please note that this method must not be used to set any of the known parameters
3691 /// which have their own setter method. If done anyway, the request will fail.
3692 ///
3693 /// # Additional Parameters
3694 ///
3695 /// * *$.xgafv* (query-string) - V1 error format.
3696 /// * *access_token* (query-string) - OAuth access token.
3697 /// * *alt* (query-string) - Data format for response.
3698 /// * *callback* (query-string) - JSONP
3699 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3700 /// * *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.
3701 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3702 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3703 /// * *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.
3704 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3705 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3706 pub fn param<T>(mut self, name: T, value: T) -> ContactGroupDeleteCall<'a, C>
3707 where
3708 T: AsRef<str>,
3709 {
3710 self._additional_params
3711 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3712 self
3713 }
3714
3715 /// Identifies the authorization scope for the method you are building.
3716 ///
3717 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3718 /// [`Scope::Contact`].
3719 ///
3720 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3721 /// tokens for more than one scope.
3722 ///
3723 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3724 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3725 /// sufficient, a read-write scope will do as well.
3726 pub fn add_scope<St>(mut self, scope: St) -> ContactGroupDeleteCall<'a, C>
3727 where
3728 St: AsRef<str>,
3729 {
3730 self._scopes.insert(String::from(scope.as_ref()));
3731 self
3732 }
3733 /// Identifies the authorization scope(s) for the method you are building.
3734 ///
3735 /// See [`Self::add_scope()`] for details.
3736 pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactGroupDeleteCall<'a, C>
3737 where
3738 I: IntoIterator<Item = St>,
3739 St: AsRef<str>,
3740 {
3741 self._scopes
3742 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3743 self
3744 }
3745
3746 /// Removes all scopes, and no default scope will be used either.
3747 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3748 /// for details).
3749 pub fn clear_scopes(mut self) -> ContactGroupDeleteCall<'a, C> {
3750 self._scopes.clear();
3751 self
3752 }
3753}
3754
3755/// Get a specific contact group owned by the authenticated user by specifying a contact group resource name.
3756///
3757/// A builder for the *get* method supported by a *contactGroup* resource.
3758/// It is not used directly, but through a [`ContactGroupMethods`] instance.
3759///
3760/// # Example
3761///
3762/// Instantiate a resource method builder
3763///
3764/// ```test_harness,no_run
3765/// # extern crate hyper;
3766/// # extern crate hyper_rustls;
3767/// # extern crate google_people1 as people1;
3768/// # async fn dox() {
3769/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3770///
3771/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3772/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3773/// # secret,
3774/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3775/// # ).build().await.unwrap();
3776///
3777/// # let client = hyper_util::client::legacy::Client::builder(
3778/// # hyper_util::rt::TokioExecutor::new()
3779/// # )
3780/// # .build(
3781/// # hyper_rustls::HttpsConnectorBuilder::new()
3782/// # .with_native_roots()
3783/// # .unwrap()
3784/// # .https_or_http()
3785/// # .enable_http1()
3786/// # .build()
3787/// # );
3788/// # let mut hub = PeopleService::new(client, auth);
3789/// // You can configure optional parameters by calling the respective setters at will, and
3790/// // execute the final call using `doit()`.
3791/// // Values shown here are possibly random and not representative !
3792/// let result = hub.contact_groups().get("resourceName")
3793/// .max_members(-12)
3794/// .group_fields(FieldMask::new::<&str>(&[]))
3795/// .doit().await;
3796/// # }
3797/// ```
3798pub struct ContactGroupGetCall<'a, C>
3799where
3800 C: 'a,
3801{
3802 hub: &'a PeopleService<C>,
3803 _resource_name: String,
3804 _max_members: Option<i32>,
3805 _group_fields: Option<common::FieldMask>,
3806 _delegate: Option<&'a mut dyn common::Delegate>,
3807 _additional_params: HashMap<String, String>,
3808 _scopes: BTreeSet<String>,
3809}
3810
3811impl<'a, C> common::CallBuilder for ContactGroupGetCall<'a, C> {}
3812
3813impl<'a, C> ContactGroupGetCall<'a, C>
3814where
3815 C: common::Connector,
3816{
3817 /// Perform the operation you have build so far.
3818 pub async fn doit(mut self) -> common::Result<(common::Response, ContactGroup)> {
3819 use std::borrow::Cow;
3820 use std::io::{Read, Seek};
3821
3822 use common::{url::Params, ToParts};
3823 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3824
3825 let mut dd = common::DefaultDelegate;
3826 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3827 dlg.begin(common::MethodInfo {
3828 id: "people.contactGroups.get",
3829 http_method: hyper::Method::GET,
3830 });
3831
3832 for &field in ["alt", "resourceName", "maxMembers", "groupFields"].iter() {
3833 if self._additional_params.contains_key(field) {
3834 dlg.finished(false);
3835 return Err(common::Error::FieldClash(field));
3836 }
3837 }
3838
3839 let mut params = Params::with_capacity(5 + self._additional_params.len());
3840 params.push("resourceName", self._resource_name);
3841 if let Some(value) = self._max_members.as_ref() {
3842 params.push("maxMembers", value.to_string());
3843 }
3844 if let Some(value) = self._group_fields.as_ref() {
3845 params.push("groupFields", value.to_string());
3846 }
3847
3848 params.extend(self._additional_params.iter());
3849
3850 params.push("alt", "json");
3851 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}";
3852 if self._scopes.is_empty() {
3853 self._scopes
3854 .insert(Scope::ContactReadonly.as_ref().to_string());
3855 }
3856
3857 #[allow(clippy::single_element_loop)]
3858 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
3859 url = params.uri_replacement(url, param_name, find_this, true);
3860 }
3861 {
3862 let to_remove = ["resourceName"];
3863 params.remove_params(&to_remove);
3864 }
3865
3866 let url = params.parse_with_url(&url);
3867
3868 loop {
3869 let token = match self
3870 .hub
3871 .auth
3872 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3873 .await
3874 {
3875 Ok(token) => token,
3876 Err(e) => match dlg.token(e) {
3877 Ok(token) => token,
3878 Err(e) => {
3879 dlg.finished(false);
3880 return Err(common::Error::MissingToken(e));
3881 }
3882 },
3883 };
3884 let mut req_result = {
3885 let client = &self.hub.client;
3886 dlg.pre_request();
3887 let mut req_builder = hyper::Request::builder()
3888 .method(hyper::Method::GET)
3889 .uri(url.as_str())
3890 .header(USER_AGENT, self.hub._user_agent.clone());
3891
3892 if let Some(token) = token.as_ref() {
3893 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3894 }
3895
3896 let request = req_builder
3897 .header(CONTENT_LENGTH, 0_u64)
3898 .body(common::to_body::<String>(None));
3899
3900 client.request(request.unwrap()).await
3901 };
3902
3903 match req_result {
3904 Err(err) => {
3905 if let common::Retry::After(d) = dlg.http_error(&err) {
3906 sleep(d).await;
3907 continue;
3908 }
3909 dlg.finished(false);
3910 return Err(common::Error::HttpError(err));
3911 }
3912 Ok(res) => {
3913 let (mut parts, body) = res.into_parts();
3914 let mut body = common::Body::new(body);
3915 if !parts.status.is_success() {
3916 let bytes = common::to_bytes(body).await.unwrap_or_default();
3917 let error = serde_json::from_str(&common::to_string(&bytes));
3918 let response = common::to_response(parts, bytes.into());
3919
3920 if let common::Retry::After(d) =
3921 dlg.http_failure(&response, error.as_ref().ok())
3922 {
3923 sleep(d).await;
3924 continue;
3925 }
3926
3927 dlg.finished(false);
3928
3929 return Err(match error {
3930 Ok(value) => common::Error::BadRequest(value),
3931 _ => common::Error::Failure(response),
3932 });
3933 }
3934 let response = {
3935 let bytes = common::to_bytes(body).await.unwrap_or_default();
3936 let encoded = common::to_string(&bytes);
3937 match serde_json::from_str(&encoded) {
3938 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3939 Err(error) => {
3940 dlg.response_json_decode_error(&encoded, &error);
3941 return Err(common::Error::JsonDecodeError(
3942 encoded.to_string(),
3943 error,
3944 ));
3945 }
3946 }
3947 };
3948
3949 dlg.finished(true);
3950 return Ok(response);
3951 }
3952 }
3953 }
3954 }
3955
3956 /// Required. The resource name of the contact group to get.
3957 ///
3958 /// Sets the *resource name* path property to the given value.
3959 ///
3960 /// Even though the property as already been set when instantiating this call,
3961 /// we provide this method for API completeness.
3962 pub fn resource_name(mut self, new_value: &str) -> ContactGroupGetCall<'a, C> {
3963 self._resource_name = new_value.to_string();
3964 self
3965 }
3966 /// Optional. Specifies the maximum number of members to return. Defaults to 0 if not set, which will return zero members.
3967 ///
3968 /// Sets the *max members* query property to the given value.
3969 pub fn max_members(mut self, new_value: i32) -> ContactGroupGetCall<'a, C> {
3970 self._max_members = Some(new_value);
3971 self
3972 }
3973 /// Optional. A field mask to restrict which fields on the group are returned. Defaults to `metadata`, `groupType`, `memberCount`, and `name` if not set or set to empty. Valid fields are: * clientData * groupType * memberCount * metadata * name
3974 ///
3975 /// Sets the *group fields* query property to the given value.
3976 pub fn group_fields(mut self, new_value: common::FieldMask) -> ContactGroupGetCall<'a, C> {
3977 self._group_fields = Some(new_value);
3978 self
3979 }
3980 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3981 /// while executing the actual API request.
3982 ///
3983 /// ````text
3984 /// It should be used to handle progress information, and to implement a certain level of resilience.
3985 /// ````
3986 ///
3987 /// Sets the *delegate* property to the given value.
3988 pub fn delegate(
3989 mut self,
3990 new_value: &'a mut dyn common::Delegate,
3991 ) -> ContactGroupGetCall<'a, C> {
3992 self._delegate = Some(new_value);
3993 self
3994 }
3995
3996 /// Set any additional parameter of the query string used in the request.
3997 /// It should be used to set parameters which are not yet available through their own
3998 /// setters.
3999 ///
4000 /// Please note that this method must not be used to set any of the known parameters
4001 /// which have their own setter method. If done anyway, the request will fail.
4002 ///
4003 /// # Additional Parameters
4004 ///
4005 /// * *$.xgafv* (query-string) - V1 error format.
4006 /// * *access_token* (query-string) - OAuth access token.
4007 /// * *alt* (query-string) - Data format for response.
4008 /// * *callback* (query-string) - JSONP
4009 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4010 /// * *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.
4011 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4012 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4013 /// * *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.
4014 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4015 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4016 pub fn param<T>(mut self, name: T, value: T) -> ContactGroupGetCall<'a, C>
4017 where
4018 T: AsRef<str>,
4019 {
4020 self._additional_params
4021 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4022 self
4023 }
4024
4025 /// Identifies the authorization scope for the method you are building.
4026 ///
4027 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4028 /// [`Scope::ContactReadonly`].
4029 ///
4030 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4031 /// tokens for more than one scope.
4032 ///
4033 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4034 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4035 /// sufficient, a read-write scope will do as well.
4036 pub fn add_scope<St>(mut self, scope: St) -> ContactGroupGetCall<'a, C>
4037 where
4038 St: AsRef<str>,
4039 {
4040 self._scopes.insert(String::from(scope.as_ref()));
4041 self
4042 }
4043 /// Identifies the authorization scope(s) for the method you are building.
4044 ///
4045 /// See [`Self::add_scope()`] for details.
4046 pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactGroupGetCall<'a, C>
4047 where
4048 I: IntoIterator<Item = St>,
4049 St: AsRef<str>,
4050 {
4051 self._scopes
4052 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4053 self
4054 }
4055
4056 /// Removes all scopes, and no default scope will be used either.
4057 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4058 /// for details).
4059 pub fn clear_scopes(mut self) -> ContactGroupGetCall<'a, C> {
4060 self._scopes.clear();
4061 self
4062 }
4063}
4064
4065/// List all contact groups owned by the authenticated user. Members of the contact groups are not populated.
4066///
4067/// A builder for the *list* method supported by a *contactGroup* resource.
4068/// It is not used directly, but through a [`ContactGroupMethods`] instance.
4069///
4070/// # Example
4071///
4072/// Instantiate a resource method builder
4073///
4074/// ```test_harness,no_run
4075/// # extern crate hyper;
4076/// # extern crate hyper_rustls;
4077/// # extern crate google_people1 as people1;
4078/// # async fn dox() {
4079/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4080///
4081/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4082/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4083/// # secret,
4084/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4085/// # ).build().await.unwrap();
4086///
4087/// # let client = hyper_util::client::legacy::Client::builder(
4088/// # hyper_util::rt::TokioExecutor::new()
4089/// # )
4090/// # .build(
4091/// # hyper_rustls::HttpsConnectorBuilder::new()
4092/// # .with_native_roots()
4093/// # .unwrap()
4094/// # .https_or_http()
4095/// # .enable_http1()
4096/// # .build()
4097/// # );
4098/// # let mut hub = PeopleService::new(client, auth);
4099/// // You can configure optional parameters by calling the respective setters at will, and
4100/// // execute the final call using `doit()`.
4101/// // Values shown here are possibly random and not representative !
4102/// let result = hub.contact_groups().list()
4103/// .sync_token("eos")
4104/// .page_token("dolor")
4105/// .page_size(-17)
4106/// .group_fields(FieldMask::new::<&str>(&[]))
4107/// .doit().await;
4108/// # }
4109/// ```
4110pub struct ContactGroupListCall<'a, C>
4111where
4112 C: 'a,
4113{
4114 hub: &'a PeopleService<C>,
4115 _sync_token: Option<String>,
4116 _page_token: Option<String>,
4117 _page_size: Option<i32>,
4118 _group_fields: Option<common::FieldMask>,
4119 _delegate: Option<&'a mut dyn common::Delegate>,
4120 _additional_params: HashMap<String, String>,
4121 _scopes: BTreeSet<String>,
4122}
4123
4124impl<'a, C> common::CallBuilder for ContactGroupListCall<'a, C> {}
4125
4126impl<'a, C> ContactGroupListCall<'a, C>
4127where
4128 C: common::Connector,
4129{
4130 /// Perform the operation you have build so far.
4131 pub async fn doit(mut self) -> common::Result<(common::Response, ListContactGroupsResponse)> {
4132 use std::borrow::Cow;
4133 use std::io::{Read, Seek};
4134
4135 use common::{url::Params, ToParts};
4136 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4137
4138 let mut dd = common::DefaultDelegate;
4139 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4140 dlg.begin(common::MethodInfo {
4141 id: "people.contactGroups.list",
4142 http_method: hyper::Method::GET,
4143 });
4144
4145 for &field in ["alt", "syncToken", "pageToken", "pageSize", "groupFields"].iter() {
4146 if self._additional_params.contains_key(field) {
4147 dlg.finished(false);
4148 return Err(common::Error::FieldClash(field));
4149 }
4150 }
4151
4152 let mut params = Params::with_capacity(6 + self._additional_params.len());
4153 if let Some(value) = self._sync_token.as_ref() {
4154 params.push("syncToken", value);
4155 }
4156 if let Some(value) = self._page_token.as_ref() {
4157 params.push("pageToken", value);
4158 }
4159 if let Some(value) = self._page_size.as_ref() {
4160 params.push("pageSize", value.to_string());
4161 }
4162 if let Some(value) = self._group_fields.as_ref() {
4163 params.push("groupFields", value.to_string());
4164 }
4165
4166 params.extend(self._additional_params.iter());
4167
4168 params.push("alt", "json");
4169 let mut url = self.hub._base_url.clone() + "v1/contactGroups";
4170 if self._scopes.is_empty() {
4171 self._scopes
4172 .insert(Scope::ContactReadonly.as_ref().to_string());
4173 }
4174
4175 let url = params.parse_with_url(&url);
4176
4177 loop {
4178 let token = match self
4179 .hub
4180 .auth
4181 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4182 .await
4183 {
4184 Ok(token) => token,
4185 Err(e) => match dlg.token(e) {
4186 Ok(token) => token,
4187 Err(e) => {
4188 dlg.finished(false);
4189 return Err(common::Error::MissingToken(e));
4190 }
4191 },
4192 };
4193 let mut req_result = {
4194 let client = &self.hub.client;
4195 dlg.pre_request();
4196 let mut req_builder = hyper::Request::builder()
4197 .method(hyper::Method::GET)
4198 .uri(url.as_str())
4199 .header(USER_AGENT, self.hub._user_agent.clone());
4200
4201 if let Some(token) = token.as_ref() {
4202 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4203 }
4204
4205 let request = req_builder
4206 .header(CONTENT_LENGTH, 0_u64)
4207 .body(common::to_body::<String>(None));
4208
4209 client.request(request.unwrap()).await
4210 };
4211
4212 match req_result {
4213 Err(err) => {
4214 if let common::Retry::After(d) = dlg.http_error(&err) {
4215 sleep(d).await;
4216 continue;
4217 }
4218 dlg.finished(false);
4219 return Err(common::Error::HttpError(err));
4220 }
4221 Ok(res) => {
4222 let (mut parts, body) = res.into_parts();
4223 let mut body = common::Body::new(body);
4224 if !parts.status.is_success() {
4225 let bytes = common::to_bytes(body).await.unwrap_or_default();
4226 let error = serde_json::from_str(&common::to_string(&bytes));
4227 let response = common::to_response(parts, bytes.into());
4228
4229 if let common::Retry::After(d) =
4230 dlg.http_failure(&response, error.as_ref().ok())
4231 {
4232 sleep(d).await;
4233 continue;
4234 }
4235
4236 dlg.finished(false);
4237
4238 return Err(match error {
4239 Ok(value) => common::Error::BadRequest(value),
4240 _ => common::Error::Failure(response),
4241 });
4242 }
4243 let response = {
4244 let bytes = common::to_bytes(body).await.unwrap_or_default();
4245 let encoded = common::to_string(&bytes);
4246 match serde_json::from_str(&encoded) {
4247 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4248 Err(error) => {
4249 dlg.response_json_decode_error(&encoded, &error);
4250 return Err(common::Error::JsonDecodeError(
4251 encoded.to_string(),
4252 error,
4253 ));
4254 }
4255 }
4256 };
4257
4258 dlg.finished(true);
4259 return Ok(response);
4260 }
4261 }
4262 }
4263 }
4264
4265 /// Optional. A sync token, returned by a previous call to `contactgroups.list`. Only resources changed since the sync token was created will be returned.
4266 ///
4267 /// Sets the *sync token* query property to the given value.
4268 pub fn sync_token(mut self, new_value: &str) -> ContactGroupListCall<'a, C> {
4269 self._sync_token = Some(new_value.to_string());
4270 self
4271 }
4272 /// Optional. The next_page_token value returned from a previous call to [ListContactGroups](https://developers.google.com/people/api/rest/v1/contactgroups/list). Requests the next page of resources.
4273 ///
4274 /// Sets the *page token* query property to the given value.
4275 pub fn page_token(mut self, new_value: &str) -> ContactGroupListCall<'a, C> {
4276 self._page_token = Some(new_value.to_string());
4277 self
4278 }
4279 /// Optional. The maximum number of resources to return. Valid values are between 1 and 1000, inclusive. Defaults to 30 if not set or set to 0.
4280 ///
4281 /// Sets the *page size* query property to the given value.
4282 pub fn page_size(mut self, new_value: i32) -> ContactGroupListCall<'a, C> {
4283 self._page_size = Some(new_value);
4284 self
4285 }
4286 /// Optional. A field mask to restrict which fields on the group are returned. Defaults to `metadata`, `groupType`, `memberCount`, and `name` if not set or set to empty. Valid fields are: * clientData * groupType * memberCount * metadata * name
4287 ///
4288 /// Sets the *group fields* query property to the given value.
4289 pub fn group_fields(mut self, new_value: common::FieldMask) -> ContactGroupListCall<'a, C> {
4290 self._group_fields = Some(new_value);
4291 self
4292 }
4293 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4294 /// while executing the actual API request.
4295 ///
4296 /// ````text
4297 /// It should be used to handle progress information, and to implement a certain level of resilience.
4298 /// ````
4299 ///
4300 /// Sets the *delegate* property to the given value.
4301 pub fn delegate(
4302 mut self,
4303 new_value: &'a mut dyn common::Delegate,
4304 ) -> ContactGroupListCall<'a, C> {
4305 self._delegate = Some(new_value);
4306 self
4307 }
4308
4309 /// Set any additional parameter of the query string used in the request.
4310 /// It should be used to set parameters which are not yet available through their own
4311 /// setters.
4312 ///
4313 /// Please note that this method must not be used to set any of the known parameters
4314 /// which have their own setter method. If done anyway, the request will fail.
4315 ///
4316 /// # Additional Parameters
4317 ///
4318 /// * *$.xgafv* (query-string) - V1 error format.
4319 /// * *access_token* (query-string) - OAuth access token.
4320 /// * *alt* (query-string) - Data format for response.
4321 /// * *callback* (query-string) - JSONP
4322 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4323 /// * *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.
4324 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4325 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4326 /// * *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.
4327 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4328 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4329 pub fn param<T>(mut self, name: T, value: T) -> ContactGroupListCall<'a, C>
4330 where
4331 T: AsRef<str>,
4332 {
4333 self._additional_params
4334 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4335 self
4336 }
4337
4338 /// Identifies the authorization scope for the method you are building.
4339 ///
4340 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4341 /// [`Scope::ContactReadonly`].
4342 ///
4343 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4344 /// tokens for more than one scope.
4345 ///
4346 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4347 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4348 /// sufficient, a read-write scope will do as well.
4349 pub fn add_scope<St>(mut self, scope: St) -> ContactGroupListCall<'a, C>
4350 where
4351 St: AsRef<str>,
4352 {
4353 self._scopes.insert(String::from(scope.as_ref()));
4354 self
4355 }
4356 /// Identifies the authorization scope(s) for the method you are building.
4357 ///
4358 /// See [`Self::add_scope()`] for details.
4359 pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactGroupListCall<'a, C>
4360 where
4361 I: IntoIterator<Item = St>,
4362 St: AsRef<str>,
4363 {
4364 self._scopes
4365 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4366 self
4367 }
4368
4369 /// Removes all scopes, and no default scope will be used either.
4370 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4371 /// for details).
4372 pub fn clear_scopes(mut self) -> ContactGroupListCall<'a, C> {
4373 self._scopes.clear();
4374 self
4375 }
4376}
4377
4378/// Update the name of an existing contact group owned by the authenticated user. Updated contact group names must be unique to the users contact groups. Attempting to create a group with a duplicate name will return a HTTP 409 error. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
4379///
4380/// A builder for the *update* method supported by a *contactGroup* resource.
4381/// It is not used directly, but through a [`ContactGroupMethods`] instance.
4382///
4383/// # Example
4384///
4385/// Instantiate a resource method builder
4386///
4387/// ```test_harness,no_run
4388/// # extern crate hyper;
4389/// # extern crate hyper_rustls;
4390/// # extern crate google_people1 as people1;
4391/// use people1::api::UpdateContactGroupRequest;
4392/// # async fn dox() {
4393/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4394///
4395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4396/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4397/// # secret,
4398/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4399/// # ).build().await.unwrap();
4400///
4401/// # let client = hyper_util::client::legacy::Client::builder(
4402/// # hyper_util::rt::TokioExecutor::new()
4403/// # )
4404/// # .build(
4405/// # hyper_rustls::HttpsConnectorBuilder::new()
4406/// # .with_native_roots()
4407/// # .unwrap()
4408/// # .https_or_http()
4409/// # .enable_http1()
4410/// # .build()
4411/// # );
4412/// # let mut hub = PeopleService::new(client, auth);
4413/// // As the method needs a request, you would usually fill it with the desired information
4414/// // into the respective structure. Some of the parts shown here might not be applicable !
4415/// // Values shown here are possibly random and not representative !
4416/// let mut req = UpdateContactGroupRequest::default();
4417///
4418/// // You can configure optional parameters by calling the respective setters at will, and
4419/// // execute the final call using `doit()`.
4420/// // Values shown here are possibly random and not representative !
4421/// let result = hub.contact_groups().update(req, "resourceName")
4422/// .doit().await;
4423/// # }
4424/// ```
4425pub struct ContactGroupUpdateCall<'a, C>
4426where
4427 C: 'a,
4428{
4429 hub: &'a PeopleService<C>,
4430 _request: UpdateContactGroupRequest,
4431 _resource_name: String,
4432 _delegate: Option<&'a mut dyn common::Delegate>,
4433 _additional_params: HashMap<String, String>,
4434 _scopes: BTreeSet<String>,
4435}
4436
4437impl<'a, C> common::CallBuilder for ContactGroupUpdateCall<'a, C> {}
4438
4439impl<'a, C> ContactGroupUpdateCall<'a, C>
4440where
4441 C: common::Connector,
4442{
4443 /// Perform the operation you have build so far.
4444 pub async fn doit(mut self) -> common::Result<(common::Response, ContactGroup)> {
4445 use std::borrow::Cow;
4446 use std::io::{Read, Seek};
4447
4448 use common::{url::Params, ToParts};
4449 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4450
4451 let mut dd = common::DefaultDelegate;
4452 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4453 dlg.begin(common::MethodInfo {
4454 id: "people.contactGroups.update",
4455 http_method: hyper::Method::PUT,
4456 });
4457
4458 for &field in ["alt", "resourceName"].iter() {
4459 if self._additional_params.contains_key(field) {
4460 dlg.finished(false);
4461 return Err(common::Error::FieldClash(field));
4462 }
4463 }
4464
4465 let mut params = Params::with_capacity(4 + self._additional_params.len());
4466 params.push("resourceName", self._resource_name);
4467
4468 params.extend(self._additional_params.iter());
4469
4470 params.push("alt", "json");
4471 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}";
4472 if self._scopes.is_empty() {
4473 self._scopes.insert(Scope::Contact.as_ref().to_string());
4474 }
4475
4476 #[allow(clippy::single_element_loop)]
4477 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
4478 url = params.uri_replacement(url, param_name, find_this, true);
4479 }
4480 {
4481 let to_remove = ["resourceName"];
4482 params.remove_params(&to_remove);
4483 }
4484
4485 let url = params.parse_with_url(&url);
4486
4487 let mut json_mime_type = mime::APPLICATION_JSON;
4488 let mut request_value_reader = {
4489 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4490 common::remove_json_null_values(&mut value);
4491 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4492 serde_json::to_writer(&mut dst, &value).unwrap();
4493 dst
4494 };
4495 let request_size = request_value_reader
4496 .seek(std::io::SeekFrom::End(0))
4497 .unwrap();
4498 request_value_reader
4499 .seek(std::io::SeekFrom::Start(0))
4500 .unwrap();
4501
4502 loop {
4503 let token = match self
4504 .hub
4505 .auth
4506 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4507 .await
4508 {
4509 Ok(token) => token,
4510 Err(e) => match dlg.token(e) {
4511 Ok(token) => token,
4512 Err(e) => {
4513 dlg.finished(false);
4514 return Err(common::Error::MissingToken(e));
4515 }
4516 },
4517 };
4518 request_value_reader
4519 .seek(std::io::SeekFrom::Start(0))
4520 .unwrap();
4521 let mut req_result = {
4522 let client = &self.hub.client;
4523 dlg.pre_request();
4524 let mut req_builder = hyper::Request::builder()
4525 .method(hyper::Method::PUT)
4526 .uri(url.as_str())
4527 .header(USER_AGENT, self.hub._user_agent.clone());
4528
4529 if let Some(token) = token.as_ref() {
4530 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4531 }
4532
4533 let request = req_builder
4534 .header(CONTENT_TYPE, json_mime_type.to_string())
4535 .header(CONTENT_LENGTH, request_size as u64)
4536 .body(common::to_body(
4537 request_value_reader.get_ref().clone().into(),
4538 ));
4539
4540 client.request(request.unwrap()).await
4541 };
4542
4543 match req_result {
4544 Err(err) => {
4545 if let common::Retry::After(d) = dlg.http_error(&err) {
4546 sleep(d).await;
4547 continue;
4548 }
4549 dlg.finished(false);
4550 return Err(common::Error::HttpError(err));
4551 }
4552 Ok(res) => {
4553 let (mut parts, body) = res.into_parts();
4554 let mut body = common::Body::new(body);
4555 if !parts.status.is_success() {
4556 let bytes = common::to_bytes(body).await.unwrap_or_default();
4557 let error = serde_json::from_str(&common::to_string(&bytes));
4558 let response = common::to_response(parts, bytes.into());
4559
4560 if let common::Retry::After(d) =
4561 dlg.http_failure(&response, error.as_ref().ok())
4562 {
4563 sleep(d).await;
4564 continue;
4565 }
4566
4567 dlg.finished(false);
4568
4569 return Err(match error {
4570 Ok(value) => common::Error::BadRequest(value),
4571 _ => common::Error::Failure(response),
4572 });
4573 }
4574 let response = {
4575 let bytes = common::to_bytes(body).await.unwrap_or_default();
4576 let encoded = common::to_string(&bytes);
4577 match serde_json::from_str(&encoded) {
4578 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4579 Err(error) => {
4580 dlg.response_json_decode_error(&encoded, &error);
4581 return Err(common::Error::JsonDecodeError(
4582 encoded.to_string(),
4583 error,
4584 ));
4585 }
4586 }
4587 };
4588
4589 dlg.finished(true);
4590 return Ok(response);
4591 }
4592 }
4593 }
4594 }
4595
4596 ///
4597 /// Sets the *request* property to the given value.
4598 ///
4599 /// Even though the property as already been set when instantiating this call,
4600 /// we provide this method for API completeness.
4601 pub fn request(
4602 mut self,
4603 new_value: UpdateContactGroupRequest,
4604 ) -> ContactGroupUpdateCall<'a, C> {
4605 self._request = new_value;
4606 self
4607 }
4608 /// The resource name for the contact group, assigned by the server. An ASCII string, in the form of `contactGroups/{contact_group_id}`.
4609 ///
4610 /// Sets the *resource name* path property to the given value.
4611 ///
4612 /// Even though the property as already been set when instantiating this call,
4613 /// we provide this method for API completeness.
4614 pub fn resource_name(mut self, new_value: &str) -> ContactGroupUpdateCall<'a, C> {
4615 self._resource_name = new_value.to_string();
4616 self
4617 }
4618 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4619 /// while executing the actual API request.
4620 ///
4621 /// ````text
4622 /// It should be used to handle progress information, and to implement a certain level of resilience.
4623 /// ````
4624 ///
4625 /// Sets the *delegate* property to the given value.
4626 pub fn delegate(
4627 mut self,
4628 new_value: &'a mut dyn common::Delegate,
4629 ) -> ContactGroupUpdateCall<'a, C> {
4630 self._delegate = Some(new_value);
4631 self
4632 }
4633
4634 /// Set any additional parameter of the query string used in the request.
4635 /// It should be used to set parameters which are not yet available through their own
4636 /// setters.
4637 ///
4638 /// Please note that this method must not be used to set any of the known parameters
4639 /// which have their own setter method. If done anyway, the request will fail.
4640 ///
4641 /// # Additional Parameters
4642 ///
4643 /// * *$.xgafv* (query-string) - V1 error format.
4644 /// * *access_token* (query-string) - OAuth access token.
4645 /// * *alt* (query-string) - Data format for response.
4646 /// * *callback* (query-string) - JSONP
4647 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4648 /// * *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.
4649 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4650 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4651 /// * *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.
4652 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4653 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4654 pub fn param<T>(mut self, name: T, value: T) -> ContactGroupUpdateCall<'a, C>
4655 where
4656 T: AsRef<str>,
4657 {
4658 self._additional_params
4659 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4660 self
4661 }
4662
4663 /// Identifies the authorization scope for the method you are building.
4664 ///
4665 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4666 /// [`Scope::Contact`].
4667 ///
4668 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4669 /// tokens for more than one scope.
4670 ///
4671 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4672 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4673 /// sufficient, a read-write scope will do as well.
4674 pub fn add_scope<St>(mut self, scope: St) -> ContactGroupUpdateCall<'a, C>
4675 where
4676 St: AsRef<str>,
4677 {
4678 self._scopes.insert(String::from(scope.as_ref()));
4679 self
4680 }
4681 /// Identifies the authorization scope(s) for the method you are building.
4682 ///
4683 /// See [`Self::add_scope()`] for details.
4684 pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactGroupUpdateCall<'a, C>
4685 where
4686 I: IntoIterator<Item = St>,
4687 St: AsRef<str>,
4688 {
4689 self._scopes
4690 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4691 self
4692 }
4693
4694 /// Removes all scopes, and no default scope will be used either.
4695 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4696 /// for details).
4697 pub fn clear_scopes(mut self) -> ContactGroupUpdateCall<'a, C> {
4698 self._scopes.clear();
4699 self
4700 }
4701}
4702
4703/// Copies an "Other contact" to a new contact in the user's "myContacts" group Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
4704///
4705/// A builder for the *copyOtherContactToMyContactsGroup* method supported by a *otherContact* resource.
4706/// It is not used directly, but through a [`OtherContactMethods`] instance.
4707///
4708/// # Example
4709///
4710/// Instantiate a resource method builder
4711///
4712/// ```test_harness,no_run
4713/// # extern crate hyper;
4714/// # extern crate hyper_rustls;
4715/// # extern crate google_people1 as people1;
4716/// use people1::api::CopyOtherContactToMyContactsGroupRequest;
4717/// # async fn dox() {
4718/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4719///
4720/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4721/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4722/// # secret,
4723/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4724/// # ).build().await.unwrap();
4725///
4726/// # let client = hyper_util::client::legacy::Client::builder(
4727/// # hyper_util::rt::TokioExecutor::new()
4728/// # )
4729/// # .build(
4730/// # hyper_rustls::HttpsConnectorBuilder::new()
4731/// # .with_native_roots()
4732/// # .unwrap()
4733/// # .https_or_http()
4734/// # .enable_http1()
4735/// # .build()
4736/// # );
4737/// # let mut hub = PeopleService::new(client, auth);
4738/// // As the method needs a request, you would usually fill it with the desired information
4739/// // into the respective structure. Some of the parts shown here might not be applicable !
4740/// // Values shown here are possibly random and not representative !
4741/// let mut req = CopyOtherContactToMyContactsGroupRequest::default();
4742///
4743/// // You can configure optional parameters by calling the respective setters at will, and
4744/// // execute the final call using `doit()`.
4745/// // Values shown here are possibly random and not representative !
4746/// let result = hub.other_contacts().copy_other_contact_to_my_contacts_group(req, "resourceName")
4747/// .doit().await;
4748/// # }
4749/// ```
4750pub struct OtherContactCopyOtherContactToMyContactsGroupCall<'a, C>
4751where
4752 C: 'a,
4753{
4754 hub: &'a PeopleService<C>,
4755 _request: CopyOtherContactToMyContactsGroupRequest,
4756 _resource_name: String,
4757 _delegate: Option<&'a mut dyn common::Delegate>,
4758 _additional_params: HashMap<String, String>,
4759 _scopes: BTreeSet<String>,
4760}
4761
4762impl<'a, C> common::CallBuilder for OtherContactCopyOtherContactToMyContactsGroupCall<'a, C> {}
4763
4764impl<'a, C> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C>
4765where
4766 C: common::Connector,
4767{
4768 /// Perform the operation you have build so far.
4769 pub async fn doit(mut self) -> common::Result<(common::Response, Person)> {
4770 use std::borrow::Cow;
4771 use std::io::{Read, Seek};
4772
4773 use common::{url::Params, ToParts};
4774 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4775
4776 let mut dd = common::DefaultDelegate;
4777 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4778 dlg.begin(common::MethodInfo {
4779 id: "people.otherContacts.copyOtherContactToMyContactsGroup",
4780 http_method: hyper::Method::POST,
4781 });
4782
4783 for &field in ["alt", "resourceName"].iter() {
4784 if self._additional_params.contains_key(field) {
4785 dlg.finished(false);
4786 return Err(common::Error::FieldClash(field));
4787 }
4788 }
4789
4790 let mut params = Params::with_capacity(4 + self._additional_params.len());
4791 params.push("resourceName", self._resource_name);
4792
4793 params.extend(self._additional_params.iter());
4794
4795 params.push("alt", "json");
4796 let mut url =
4797 self.hub._base_url.clone() + "v1/{+resourceName}:copyOtherContactToMyContactsGroup";
4798 if self._scopes.is_empty() {
4799 self._scopes.insert(Scope::Contact.as_ref().to_string());
4800 }
4801
4802 #[allow(clippy::single_element_loop)]
4803 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
4804 url = params.uri_replacement(url, param_name, find_this, true);
4805 }
4806 {
4807 let to_remove = ["resourceName"];
4808 params.remove_params(&to_remove);
4809 }
4810
4811 let url = params.parse_with_url(&url);
4812
4813 let mut json_mime_type = mime::APPLICATION_JSON;
4814 let mut request_value_reader = {
4815 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4816 common::remove_json_null_values(&mut value);
4817 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4818 serde_json::to_writer(&mut dst, &value).unwrap();
4819 dst
4820 };
4821 let request_size = request_value_reader
4822 .seek(std::io::SeekFrom::End(0))
4823 .unwrap();
4824 request_value_reader
4825 .seek(std::io::SeekFrom::Start(0))
4826 .unwrap();
4827
4828 loop {
4829 let token = match self
4830 .hub
4831 .auth
4832 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4833 .await
4834 {
4835 Ok(token) => token,
4836 Err(e) => match dlg.token(e) {
4837 Ok(token) => token,
4838 Err(e) => {
4839 dlg.finished(false);
4840 return Err(common::Error::MissingToken(e));
4841 }
4842 },
4843 };
4844 request_value_reader
4845 .seek(std::io::SeekFrom::Start(0))
4846 .unwrap();
4847 let mut req_result = {
4848 let client = &self.hub.client;
4849 dlg.pre_request();
4850 let mut req_builder = hyper::Request::builder()
4851 .method(hyper::Method::POST)
4852 .uri(url.as_str())
4853 .header(USER_AGENT, self.hub._user_agent.clone());
4854
4855 if let Some(token) = token.as_ref() {
4856 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4857 }
4858
4859 let request = req_builder
4860 .header(CONTENT_TYPE, json_mime_type.to_string())
4861 .header(CONTENT_LENGTH, request_size as u64)
4862 .body(common::to_body(
4863 request_value_reader.get_ref().clone().into(),
4864 ));
4865
4866 client.request(request.unwrap()).await
4867 };
4868
4869 match req_result {
4870 Err(err) => {
4871 if let common::Retry::After(d) = dlg.http_error(&err) {
4872 sleep(d).await;
4873 continue;
4874 }
4875 dlg.finished(false);
4876 return Err(common::Error::HttpError(err));
4877 }
4878 Ok(res) => {
4879 let (mut parts, body) = res.into_parts();
4880 let mut body = common::Body::new(body);
4881 if !parts.status.is_success() {
4882 let bytes = common::to_bytes(body).await.unwrap_or_default();
4883 let error = serde_json::from_str(&common::to_string(&bytes));
4884 let response = common::to_response(parts, bytes.into());
4885
4886 if let common::Retry::After(d) =
4887 dlg.http_failure(&response, error.as_ref().ok())
4888 {
4889 sleep(d).await;
4890 continue;
4891 }
4892
4893 dlg.finished(false);
4894
4895 return Err(match error {
4896 Ok(value) => common::Error::BadRequest(value),
4897 _ => common::Error::Failure(response),
4898 });
4899 }
4900 let response = {
4901 let bytes = common::to_bytes(body).await.unwrap_or_default();
4902 let encoded = common::to_string(&bytes);
4903 match serde_json::from_str(&encoded) {
4904 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4905 Err(error) => {
4906 dlg.response_json_decode_error(&encoded, &error);
4907 return Err(common::Error::JsonDecodeError(
4908 encoded.to_string(),
4909 error,
4910 ));
4911 }
4912 }
4913 };
4914
4915 dlg.finished(true);
4916 return Ok(response);
4917 }
4918 }
4919 }
4920 }
4921
4922 ///
4923 /// Sets the *request* property to the given value.
4924 ///
4925 /// Even though the property as already been set when instantiating this call,
4926 /// we provide this method for API completeness.
4927 pub fn request(
4928 mut self,
4929 new_value: CopyOtherContactToMyContactsGroupRequest,
4930 ) -> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C> {
4931 self._request = new_value;
4932 self
4933 }
4934 /// Required. The resource name of the "Other contact" to copy.
4935 ///
4936 /// Sets the *resource name* path property to the given value.
4937 ///
4938 /// Even though the property as already been set when instantiating this call,
4939 /// we provide this method for API completeness.
4940 pub fn resource_name(
4941 mut self,
4942 new_value: &str,
4943 ) -> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C> {
4944 self._resource_name = new_value.to_string();
4945 self
4946 }
4947 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4948 /// while executing the actual API request.
4949 ///
4950 /// ````text
4951 /// It should be used to handle progress information, and to implement a certain level of resilience.
4952 /// ````
4953 ///
4954 /// Sets the *delegate* property to the given value.
4955 pub fn delegate(
4956 mut self,
4957 new_value: &'a mut dyn common::Delegate,
4958 ) -> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C> {
4959 self._delegate = Some(new_value);
4960 self
4961 }
4962
4963 /// Set any additional parameter of the query string used in the request.
4964 /// It should be used to set parameters which are not yet available through their own
4965 /// setters.
4966 ///
4967 /// Please note that this method must not be used to set any of the known parameters
4968 /// which have their own setter method. If done anyway, the request will fail.
4969 ///
4970 /// # Additional Parameters
4971 ///
4972 /// * *$.xgafv* (query-string) - V1 error format.
4973 /// * *access_token* (query-string) - OAuth access token.
4974 /// * *alt* (query-string) - Data format for response.
4975 /// * *callback* (query-string) - JSONP
4976 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4977 /// * *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.
4978 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4979 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4980 /// * *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.
4981 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4982 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4983 pub fn param<T>(
4984 mut self,
4985 name: T,
4986 value: T,
4987 ) -> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C>
4988 where
4989 T: AsRef<str>,
4990 {
4991 self._additional_params
4992 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4993 self
4994 }
4995
4996 /// Identifies the authorization scope for the method you are building.
4997 ///
4998 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4999 /// [`Scope::Contact`].
5000 ///
5001 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5002 /// tokens for more than one scope.
5003 ///
5004 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5005 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5006 /// sufficient, a read-write scope will do as well.
5007 pub fn add_scope<St>(
5008 mut self,
5009 scope: St,
5010 ) -> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C>
5011 where
5012 St: AsRef<str>,
5013 {
5014 self._scopes.insert(String::from(scope.as_ref()));
5015 self
5016 }
5017 /// Identifies the authorization scope(s) for the method you are building.
5018 ///
5019 /// See [`Self::add_scope()`] for details.
5020 pub fn add_scopes<I, St>(
5021 mut self,
5022 scopes: I,
5023 ) -> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C>
5024 where
5025 I: IntoIterator<Item = St>,
5026 St: AsRef<str>,
5027 {
5028 self._scopes
5029 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5030 self
5031 }
5032
5033 /// Removes all scopes, and no default scope will be used either.
5034 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5035 /// for details).
5036 pub fn clear_scopes(mut self) -> OtherContactCopyOtherContactToMyContactsGroupCall<'a, C> {
5037 self._scopes.clear();
5038 self
5039 }
5040}
5041
5042/// List all “Other contacts”, that is contacts that are not in a contact group. “Other contacts” are typically auto created contacts from interactions. Sync tokens expire 7 days after the full sync. A request with an expired sync token will get an error with an [google.rpc.ErrorInfo](https://cloud.google.com/apis/design/errors#error_info) with reason “EXPIRED_SYNC_TOKEN”. In the case of such an error clients should make a full sync request without a `sync_token`. The first page of a full sync request has an additional quota. If the quota is exceeded, a 429 error will be returned. This quota is fixed and can not be increased. When the `sync_token` is specified, resources deleted since the last sync will be returned as a person with `PersonMetadata.deleted` set to true. When the `page_token` or `sync_token` is specified, all other request parameters must match the first call. Writes may have a propagation delay of several minutes for sync requests. Incremental syncs are not intended for read-after-write use cases. See example usage at [List the user’s other contacts that have changed](https://developers.google.com/people/v1/other-contacts#list_the_users_other_contacts_that_have_changed).
5043///
5044/// A builder for the *list* method supported by a *otherContact* resource.
5045/// It is not used directly, but through a [`OtherContactMethods`] instance.
5046///
5047/// # Example
5048///
5049/// Instantiate a resource method builder
5050///
5051/// ```test_harness,no_run
5052/// # extern crate hyper;
5053/// # extern crate hyper_rustls;
5054/// # extern crate google_people1 as people1;
5055/// # async fn dox() {
5056/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5057///
5058/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5059/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5060/// # secret,
5061/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5062/// # ).build().await.unwrap();
5063///
5064/// # let client = hyper_util::client::legacy::Client::builder(
5065/// # hyper_util::rt::TokioExecutor::new()
5066/// # )
5067/// # .build(
5068/// # hyper_rustls::HttpsConnectorBuilder::new()
5069/// # .with_native_roots()
5070/// # .unwrap()
5071/// # .https_or_http()
5072/// # .enable_http1()
5073/// # .build()
5074/// # );
5075/// # let mut hub = PeopleService::new(client, auth);
5076/// // You can configure optional parameters by calling the respective setters at will, and
5077/// // execute the final call using `doit()`.
5078/// // Values shown here are possibly random and not representative !
5079/// let result = hub.other_contacts().list()
5080/// .sync_token("amet")
5081/// .add_sources("duo")
5082/// .request_sync_token(true)
5083/// .read_mask(FieldMask::new::<&str>(&[]))
5084/// .page_token("sed")
5085/// .page_size(-37)
5086/// .doit().await;
5087/// # }
5088/// ```
5089pub struct OtherContactListCall<'a, C>
5090where
5091 C: 'a,
5092{
5093 hub: &'a PeopleService<C>,
5094 _sync_token: Option<String>,
5095 _sources: Vec<String>,
5096 _request_sync_token: Option<bool>,
5097 _read_mask: Option<common::FieldMask>,
5098 _page_token: Option<String>,
5099 _page_size: Option<i32>,
5100 _delegate: Option<&'a mut dyn common::Delegate>,
5101 _additional_params: HashMap<String, String>,
5102 _scopes: BTreeSet<String>,
5103}
5104
5105impl<'a, C> common::CallBuilder for OtherContactListCall<'a, C> {}
5106
5107impl<'a, C> OtherContactListCall<'a, C>
5108where
5109 C: common::Connector,
5110{
5111 /// Perform the operation you have build so far.
5112 pub async fn doit(mut self) -> common::Result<(common::Response, ListOtherContactsResponse)> {
5113 use std::borrow::Cow;
5114 use std::io::{Read, Seek};
5115
5116 use common::{url::Params, ToParts};
5117 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5118
5119 let mut dd = common::DefaultDelegate;
5120 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5121 dlg.begin(common::MethodInfo {
5122 id: "people.otherContacts.list",
5123 http_method: hyper::Method::GET,
5124 });
5125
5126 for &field in [
5127 "alt",
5128 "syncToken",
5129 "sources",
5130 "requestSyncToken",
5131 "readMask",
5132 "pageToken",
5133 "pageSize",
5134 ]
5135 .iter()
5136 {
5137 if self._additional_params.contains_key(field) {
5138 dlg.finished(false);
5139 return Err(common::Error::FieldClash(field));
5140 }
5141 }
5142
5143 let mut params = Params::with_capacity(8 + self._additional_params.len());
5144 if let Some(value) = self._sync_token.as_ref() {
5145 params.push("syncToken", value);
5146 }
5147 if !self._sources.is_empty() {
5148 for f in self._sources.iter() {
5149 params.push("sources", f);
5150 }
5151 }
5152 if let Some(value) = self._request_sync_token.as_ref() {
5153 params.push("requestSyncToken", value.to_string());
5154 }
5155 if let Some(value) = self._read_mask.as_ref() {
5156 params.push("readMask", value.to_string());
5157 }
5158 if let Some(value) = self._page_token.as_ref() {
5159 params.push("pageToken", value);
5160 }
5161 if let Some(value) = self._page_size.as_ref() {
5162 params.push("pageSize", value.to_string());
5163 }
5164
5165 params.extend(self._additional_params.iter());
5166
5167 params.push("alt", "json");
5168 let mut url = self.hub._base_url.clone() + "v1/otherContacts";
5169 if self._scopes.is_empty() {
5170 self._scopes
5171 .insert(Scope::ContactOtherReadonly.as_ref().to_string());
5172 }
5173
5174 let url = params.parse_with_url(&url);
5175
5176 loop {
5177 let token = match self
5178 .hub
5179 .auth
5180 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5181 .await
5182 {
5183 Ok(token) => token,
5184 Err(e) => match dlg.token(e) {
5185 Ok(token) => token,
5186 Err(e) => {
5187 dlg.finished(false);
5188 return Err(common::Error::MissingToken(e));
5189 }
5190 },
5191 };
5192 let mut req_result = {
5193 let client = &self.hub.client;
5194 dlg.pre_request();
5195 let mut req_builder = hyper::Request::builder()
5196 .method(hyper::Method::GET)
5197 .uri(url.as_str())
5198 .header(USER_AGENT, self.hub._user_agent.clone());
5199
5200 if let Some(token) = token.as_ref() {
5201 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5202 }
5203
5204 let request = req_builder
5205 .header(CONTENT_LENGTH, 0_u64)
5206 .body(common::to_body::<String>(None));
5207
5208 client.request(request.unwrap()).await
5209 };
5210
5211 match req_result {
5212 Err(err) => {
5213 if let common::Retry::After(d) = dlg.http_error(&err) {
5214 sleep(d).await;
5215 continue;
5216 }
5217 dlg.finished(false);
5218 return Err(common::Error::HttpError(err));
5219 }
5220 Ok(res) => {
5221 let (mut parts, body) = res.into_parts();
5222 let mut body = common::Body::new(body);
5223 if !parts.status.is_success() {
5224 let bytes = common::to_bytes(body).await.unwrap_or_default();
5225 let error = serde_json::from_str(&common::to_string(&bytes));
5226 let response = common::to_response(parts, bytes.into());
5227
5228 if let common::Retry::After(d) =
5229 dlg.http_failure(&response, error.as_ref().ok())
5230 {
5231 sleep(d).await;
5232 continue;
5233 }
5234
5235 dlg.finished(false);
5236
5237 return Err(match error {
5238 Ok(value) => common::Error::BadRequest(value),
5239 _ => common::Error::Failure(response),
5240 });
5241 }
5242 let response = {
5243 let bytes = common::to_bytes(body).await.unwrap_or_default();
5244 let encoded = common::to_string(&bytes);
5245 match serde_json::from_str(&encoded) {
5246 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5247 Err(error) => {
5248 dlg.response_json_decode_error(&encoded, &error);
5249 return Err(common::Error::JsonDecodeError(
5250 encoded.to_string(),
5251 error,
5252 ));
5253 }
5254 }
5255 };
5256
5257 dlg.finished(true);
5258 return Ok(response);
5259 }
5260 }
5261 }
5262 }
5263
5264 /// Optional. A sync token, received from a previous response `next_sync_token` Provide this to retrieve only the resources changed since the last request. When syncing, all other parameters provided to `otherContacts.list` must match the first call that provided the sync token. More details about sync behavior at `otherContacts.list`.
5265 ///
5266 /// Sets the *sync token* query property to the given value.
5267 pub fn sync_token(mut self, new_value: &str) -> OtherContactListCall<'a, C> {
5268 self._sync_token = Some(new_value.to_string());
5269 self
5270 }
5271 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT if not set. Possible values for this field are: * READ_SOURCE_TYPE_CONTACT * READ_SOURCE_TYPE_CONTACT,READ_SOURCE_TYPE_PROFILE Specifying READ_SOURCE_TYPE_PROFILE without specifying READ_SOURCE_TYPE_CONTACT is not permitted.
5272 ///
5273 /// Append the given value to the *sources* query property.
5274 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5275 pub fn add_sources(mut self, new_value: &str) -> OtherContactListCall<'a, C> {
5276 self._sources.push(new_value.to_string());
5277 self
5278 }
5279 /// Optional. Whether the response should return `next_sync_token` on the last page of results. It can be used to get incremental changes since the last request by setting it on the request `sync_token`. More details about sync behavior at `otherContacts.list`.
5280 ///
5281 /// Sets the *request sync token* query property to the given value.
5282 pub fn request_sync_token(mut self, new_value: bool) -> OtherContactListCall<'a, C> {
5283 self._request_sync_token = Some(new_value);
5284 self
5285 }
5286 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. What values are valid depend on what ReadSourceType is used. If READ_SOURCE_TYPE_CONTACT is used, valid values are: * emailAddresses * metadata * names * phoneNumbers * photos If READ_SOURCE_TYPE_PROFILE is used, valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
5287 ///
5288 /// Sets the *read mask* query property to the given value.
5289 pub fn read_mask(mut self, new_value: common::FieldMask) -> OtherContactListCall<'a, C> {
5290 self._read_mask = Some(new_value);
5291 self
5292 }
5293 /// Optional. A page token, received from a previous response `next_page_token`. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `otherContacts.list` must match the first call that provided the page token.
5294 ///
5295 /// Sets the *page token* query property to the given value.
5296 pub fn page_token(mut self, new_value: &str) -> OtherContactListCall<'a, C> {
5297 self._page_token = Some(new_value.to_string());
5298 self
5299 }
5300 /// Optional. The number of "Other contacts" to include in the response. Valid values are between 1 and 1000, inclusive. Defaults to 100 if not set or set to 0.
5301 ///
5302 /// Sets the *page size* query property to the given value.
5303 pub fn page_size(mut self, new_value: i32) -> OtherContactListCall<'a, C> {
5304 self._page_size = Some(new_value);
5305 self
5306 }
5307 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5308 /// while executing the actual API request.
5309 ///
5310 /// ````text
5311 /// It should be used to handle progress information, and to implement a certain level of resilience.
5312 /// ````
5313 ///
5314 /// Sets the *delegate* property to the given value.
5315 pub fn delegate(
5316 mut self,
5317 new_value: &'a mut dyn common::Delegate,
5318 ) -> OtherContactListCall<'a, C> {
5319 self._delegate = Some(new_value);
5320 self
5321 }
5322
5323 /// Set any additional parameter of the query string used in the request.
5324 /// It should be used to set parameters which are not yet available through their own
5325 /// setters.
5326 ///
5327 /// Please note that this method must not be used to set any of the known parameters
5328 /// which have their own setter method. If done anyway, the request will fail.
5329 ///
5330 /// # Additional Parameters
5331 ///
5332 /// * *$.xgafv* (query-string) - V1 error format.
5333 /// * *access_token* (query-string) - OAuth access token.
5334 /// * *alt* (query-string) - Data format for response.
5335 /// * *callback* (query-string) - JSONP
5336 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5337 /// * *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.
5338 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5339 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5340 /// * *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.
5341 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5342 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5343 pub fn param<T>(mut self, name: T, value: T) -> OtherContactListCall<'a, C>
5344 where
5345 T: AsRef<str>,
5346 {
5347 self._additional_params
5348 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5349 self
5350 }
5351
5352 /// Identifies the authorization scope for the method you are building.
5353 ///
5354 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5355 /// [`Scope::ContactOtherReadonly`].
5356 ///
5357 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5358 /// tokens for more than one scope.
5359 ///
5360 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5361 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5362 /// sufficient, a read-write scope will do as well.
5363 pub fn add_scope<St>(mut self, scope: St) -> OtherContactListCall<'a, C>
5364 where
5365 St: AsRef<str>,
5366 {
5367 self._scopes.insert(String::from(scope.as_ref()));
5368 self
5369 }
5370 /// Identifies the authorization scope(s) for the method you are building.
5371 ///
5372 /// See [`Self::add_scope()`] for details.
5373 pub fn add_scopes<I, St>(mut self, scopes: I) -> OtherContactListCall<'a, C>
5374 where
5375 I: IntoIterator<Item = St>,
5376 St: AsRef<str>,
5377 {
5378 self._scopes
5379 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5380 self
5381 }
5382
5383 /// Removes all scopes, and no default scope will be used either.
5384 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5385 /// for details).
5386 pub fn clear_scopes(mut self) -> OtherContactListCall<'a, C> {
5387 self._scopes.clear();
5388 self
5389 }
5390}
5391
5392/// Provides a list of contacts in the authenticated user's other contacts that matches the search query. The query matches on a contact's `names`, `emailAddresses`, and `phoneNumbers` fields that are from the OTHER_CONTACT source. **IMPORTANT**: Before searching, clients should send a warmup request with an empty query to update the cache. See https://developers.google.com/people/v1/other-contacts#search_the_users_other_contacts
5393///
5394/// A builder for the *search* method supported by a *otherContact* resource.
5395/// It is not used directly, but through a [`OtherContactMethods`] instance.
5396///
5397/// # Example
5398///
5399/// Instantiate a resource method builder
5400///
5401/// ```test_harness,no_run
5402/// # extern crate hyper;
5403/// # extern crate hyper_rustls;
5404/// # extern crate google_people1 as people1;
5405/// # async fn dox() {
5406/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5407///
5408/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5409/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5410/// # secret,
5411/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5412/// # ).build().await.unwrap();
5413///
5414/// # let client = hyper_util::client::legacy::Client::builder(
5415/// # hyper_util::rt::TokioExecutor::new()
5416/// # )
5417/// # .build(
5418/// # hyper_rustls::HttpsConnectorBuilder::new()
5419/// # .with_native_roots()
5420/// # .unwrap()
5421/// # .https_or_http()
5422/// # .enable_http1()
5423/// # .build()
5424/// # );
5425/// # let mut hub = PeopleService::new(client, auth);
5426/// // You can configure optional parameters by calling the respective setters at will, and
5427/// // execute the final call using `doit()`.
5428/// // Values shown here are possibly random and not representative !
5429/// let result = hub.other_contacts().search()
5430/// .read_mask(FieldMask::new::<&str>(&[]))
5431/// .query("gubergren")
5432/// .page_size(-16)
5433/// .doit().await;
5434/// # }
5435/// ```
5436pub struct OtherContactSearchCall<'a, C>
5437where
5438 C: 'a,
5439{
5440 hub: &'a PeopleService<C>,
5441 _read_mask: Option<common::FieldMask>,
5442 _query: Option<String>,
5443 _page_size: Option<i32>,
5444 _delegate: Option<&'a mut dyn common::Delegate>,
5445 _additional_params: HashMap<String, String>,
5446 _scopes: BTreeSet<String>,
5447}
5448
5449impl<'a, C> common::CallBuilder for OtherContactSearchCall<'a, C> {}
5450
5451impl<'a, C> OtherContactSearchCall<'a, C>
5452where
5453 C: common::Connector,
5454{
5455 /// Perform the operation you have build so far.
5456 pub async fn doit(mut self) -> common::Result<(common::Response, SearchResponse)> {
5457 use std::borrow::Cow;
5458 use std::io::{Read, Seek};
5459
5460 use common::{url::Params, ToParts};
5461 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5462
5463 let mut dd = common::DefaultDelegate;
5464 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5465 dlg.begin(common::MethodInfo {
5466 id: "people.otherContacts.search",
5467 http_method: hyper::Method::GET,
5468 });
5469
5470 for &field in ["alt", "readMask", "query", "pageSize"].iter() {
5471 if self._additional_params.contains_key(field) {
5472 dlg.finished(false);
5473 return Err(common::Error::FieldClash(field));
5474 }
5475 }
5476
5477 let mut params = Params::with_capacity(5 + self._additional_params.len());
5478 if let Some(value) = self._read_mask.as_ref() {
5479 params.push("readMask", value.to_string());
5480 }
5481 if let Some(value) = self._query.as_ref() {
5482 params.push("query", value);
5483 }
5484 if let Some(value) = self._page_size.as_ref() {
5485 params.push("pageSize", value.to_string());
5486 }
5487
5488 params.extend(self._additional_params.iter());
5489
5490 params.push("alt", "json");
5491 let mut url = self.hub._base_url.clone() + "v1/otherContacts:search";
5492 if self._scopes.is_empty() {
5493 self._scopes
5494 .insert(Scope::ContactOtherReadonly.as_ref().to_string());
5495 }
5496
5497 let url = params.parse_with_url(&url);
5498
5499 loop {
5500 let token = match self
5501 .hub
5502 .auth
5503 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5504 .await
5505 {
5506 Ok(token) => token,
5507 Err(e) => match dlg.token(e) {
5508 Ok(token) => token,
5509 Err(e) => {
5510 dlg.finished(false);
5511 return Err(common::Error::MissingToken(e));
5512 }
5513 },
5514 };
5515 let mut req_result = {
5516 let client = &self.hub.client;
5517 dlg.pre_request();
5518 let mut req_builder = hyper::Request::builder()
5519 .method(hyper::Method::GET)
5520 .uri(url.as_str())
5521 .header(USER_AGENT, self.hub._user_agent.clone());
5522
5523 if let Some(token) = token.as_ref() {
5524 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5525 }
5526
5527 let request = req_builder
5528 .header(CONTENT_LENGTH, 0_u64)
5529 .body(common::to_body::<String>(None));
5530
5531 client.request(request.unwrap()).await
5532 };
5533
5534 match req_result {
5535 Err(err) => {
5536 if let common::Retry::After(d) = dlg.http_error(&err) {
5537 sleep(d).await;
5538 continue;
5539 }
5540 dlg.finished(false);
5541 return Err(common::Error::HttpError(err));
5542 }
5543 Ok(res) => {
5544 let (mut parts, body) = res.into_parts();
5545 let mut body = common::Body::new(body);
5546 if !parts.status.is_success() {
5547 let bytes = common::to_bytes(body).await.unwrap_or_default();
5548 let error = serde_json::from_str(&common::to_string(&bytes));
5549 let response = common::to_response(parts, bytes.into());
5550
5551 if let common::Retry::After(d) =
5552 dlg.http_failure(&response, error.as_ref().ok())
5553 {
5554 sleep(d).await;
5555 continue;
5556 }
5557
5558 dlg.finished(false);
5559
5560 return Err(match error {
5561 Ok(value) => common::Error::BadRequest(value),
5562 _ => common::Error::Failure(response),
5563 });
5564 }
5565 let response = {
5566 let bytes = common::to_bytes(body).await.unwrap_or_default();
5567 let encoded = common::to_string(&bytes);
5568 match serde_json::from_str(&encoded) {
5569 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5570 Err(error) => {
5571 dlg.response_json_decode_error(&encoded, &error);
5572 return Err(common::Error::JsonDecodeError(
5573 encoded.to_string(),
5574 error,
5575 ));
5576 }
5577 }
5578 };
5579
5580 dlg.finished(true);
5581 return Ok(response);
5582 }
5583 }
5584 }
5585 }
5586
5587 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. Valid values are: * emailAddresses * metadata * names * phoneNumbers
5588 ///
5589 /// Sets the *read mask* query property to the given value.
5590 pub fn read_mask(mut self, new_value: common::FieldMask) -> OtherContactSearchCall<'a, C> {
5591 self._read_mask = Some(new_value);
5592 self
5593 }
5594 /// Required. The plain-text query for the request. The query is used to match prefix phrases of the fields on a person. For example, a person with name "foo name" matches queries such as "f", "fo", "foo", "foo n", "nam", etc., but not "oo n".
5595 ///
5596 /// Sets the *query* query property to the given value.
5597 pub fn query(mut self, new_value: &str) -> OtherContactSearchCall<'a, C> {
5598 self._query = Some(new_value.to_string());
5599 self
5600 }
5601 /// Optional. The number of results to return. Defaults to 10 if field is not set, or set to 0. Values greater than 30 will be capped to 30.
5602 ///
5603 /// Sets the *page size* query property to the given value.
5604 pub fn page_size(mut self, new_value: i32) -> OtherContactSearchCall<'a, C> {
5605 self._page_size = Some(new_value);
5606 self
5607 }
5608 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5609 /// while executing the actual API request.
5610 ///
5611 /// ````text
5612 /// It should be used to handle progress information, and to implement a certain level of resilience.
5613 /// ````
5614 ///
5615 /// Sets the *delegate* property to the given value.
5616 pub fn delegate(
5617 mut self,
5618 new_value: &'a mut dyn common::Delegate,
5619 ) -> OtherContactSearchCall<'a, C> {
5620 self._delegate = Some(new_value);
5621 self
5622 }
5623
5624 /// Set any additional parameter of the query string used in the request.
5625 /// It should be used to set parameters which are not yet available through their own
5626 /// setters.
5627 ///
5628 /// Please note that this method must not be used to set any of the known parameters
5629 /// which have their own setter method. If done anyway, the request will fail.
5630 ///
5631 /// # Additional Parameters
5632 ///
5633 /// * *$.xgafv* (query-string) - V1 error format.
5634 /// * *access_token* (query-string) - OAuth access token.
5635 /// * *alt* (query-string) - Data format for response.
5636 /// * *callback* (query-string) - JSONP
5637 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5638 /// * *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.
5639 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5640 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5641 /// * *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.
5642 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5643 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5644 pub fn param<T>(mut self, name: T, value: T) -> OtherContactSearchCall<'a, C>
5645 where
5646 T: AsRef<str>,
5647 {
5648 self._additional_params
5649 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5650 self
5651 }
5652
5653 /// Identifies the authorization scope for the method you are building.
5654 ///
5655 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5656 /// [`Scope::ContactOtherReadonly`].
5657 ///
5658 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5659 /// tokens for more than one scope.
5660 ///
5661 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5662 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5663 /// sufficient, a read-write scope will do as well.
5664 pub fn add_scope<St>(mut self, scope: St) -> OtherContactSearchCall<'a, C>
5665 where
5666 St: AsRef<str>,
5667 {
5668 self._scopes.insert(String::from(scope.as_ref()));
5669 self
5670 }
5671 /// Identifies the authorization scope(s) for the method you are building.
5672 ///
5673 /// See [`Self::add_scope()`] for details.
5674 pub fn add_scopes<I, St>(mut self, scopes: I) -> OtherContactSearchCall<'a, C>
5675 where
5676 I: IntoIterator<Item = St>,
5677 St: AsRef<str>,
5678 {
5679 self._scopes
5680 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5681 self
5682 }
5683
5684 /// Removes all scopes, and no default scope will be used either.
5685 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5686 /// for details).
5687 pub fn clear_scopes(mut self) -> OtherContactSearchCall<'a, C> {
5688 self._scopes.clear();
5689 self
5690 }
5691}
5692
5693/// Provides a list of the authenticated user’s contacts. Sync tokens expire 7 days after the full sync. A request with an expired sync token will get an error with an [google.rpc.ErrorInfo](https://cloud.google.com/apis/design/errors#error_info) with reason “EXPIRED_SYNC_TOKEN”. In the case of such an error clients should make a full sync request without a `sync_token`. The first page of a full sync request has an additional quota. If the quota is exceeded, a 429 error will be returned. This quota is fixed and can not be increased. When the `sync_token` is specified, resources deleted since the last sync will be returned as a person with `PersonMetadata.deleted` set to true. When the `page_token` or `sync_token` is specified, all other request parameters must match the first call. Writes may have a propagation delay of several minutes for sync requests. Incremental syncs are not intended for read-after-write use cases. See example usage at [List the user’s contacts that have changed](https://developers.google.com/people/v1/contacts#list_the_users_contacts_that_have_changed).
5694///
5695/// A builder for the *connections.list* method supported by a *person* resource.
5696/// It is not used directly, but through a [`PersonMethods`] instance.
5697///
5698/// # Example
5699///
5700/// Instantiate a resource method builder
5701///
5702/// ```test_harness,no_run
5703/// # extern crate hyper;
5704/// # extern crate hyper_rustls;
5705/// # extern crate google_people1 as people1;
5706/// # async fn dox() {
5707/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5708///
5709/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5710/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5711/// # secret,
5712/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5713/// # ).build().await.unwrap();
5714///
5715/// # let client = hyper_util::client::legacy::Client::builder(
5716/// # hyper_util::rt::TokioExecutor::new()
5717/// # )
5718/// # .build(
5719/// # hyper_rustls::HttpsConnectorBuilder::new()
5720/// # .with_native_roots()
5721/// # .unwrap()
5722/// # .https_or_http()
5723/// # .enable_http1()
5724/// # .build()
5725/// # );
5726/// # let mut hub = PeopleService::new(client, auth);
5727/// // You can configure optional parameters by calling the respective setters at will, and
5728/// // execute the final call using `doit()`.
5729/// // Values shown here are possibly random and not representative !
5730/// let result = hub.people().connections_list("resourceName")
5731/// .sync_token("ipsum")
5732/// .add_sources("ipsum")
5733/// .sort_order("est")
5734/// .request_sync_token(true)
5735/// .request_mask_include_field(FieldMask::new::<&str>(&[]))
5736/// .person_fields(FieldMask::new::<&str>(&[]))
5737/// .page_token("ea")
5738/// .page_size(-99)
5739/// .doit().await;
5740/// # }
5741/// ```
5742pub struct PersonConnectionListCall<'a, C>
5743where
5744 C: 'a,
5745{
5746 hub: &'a PeopleService<C>,
5747 _resource_name: String,
5748 _sync_token: Option<String>,
5749 _sources: Vec<String>,
5750 _sort_order: Option<String>,
5751 _request_sync_token: Option<bool>,
5752 _request_mask_include_field: Option<common::FieldMask>,
5753 _person_fields: Option<common::FieldMask>,
5754 _page_token: Option<String>,
5755 _page_size: Option<i32>,
5756 _delegate: Option<&'a mut dyn common::Delegate>,
5757 _additional_params: HashMap<String, String>,
5758 _scopes: BTreeSet<String>,
5759}
5760
5761impl<'a, C> common::CallBuilder for PersonConnectionListCall<'a, C> {}
5762
5763impl<'a, C> PersonConnectionListCall<'a, C>
5764where
5765 C: common::Connector,
5766{
5767 /// Perform the operation you have build so far.
5768 pub async fn doit(mut self) -> common::Result<(common::Response, ListConnectionsResponse)> {
5769 use std::borrow::Cow;
5770 use std::io::{Read, Seek};
5771
5772 use common::{url::Params, ToParts};
5773 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5774
5775 let mut dd = common::DefaultDelegate;
5776 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5777 dlg.begin(common::MethodInfo {
5778 id: "people.people.connections.list",
5779 http_method: hyper::Method::GET,
5780 });
5781
5782 for &field in [
5783 "alt",
5784 "resourceName",
5785 "syncToken",
5786 "sources",
5787 "sortOrder",
5788 "requestSyncToken",
5789 "requestMask.includeField",
5790 "personFields",
5791 "pageToken",
5792 "pageSize",
5793 ]
5794 .iter()
5795 {
5796 if self._additional_params.contains_key(field) {
5797 dlg.finished(false);
5798 return Err(common::Error::FieldClash(field));
5799 }
5800 }
5801
5802 let mut params = Params::with_capacity(11 + self._additional_params.len());
5803 params.push("resourceName", self._resource_name);
5804 if let Some(value) = self._sync_token.as_ref() {
5805 params.push("syncToken", value);
5806 }
5807 if !self._sources.is_empty() {
5808 for f in self._sources.iter() {
5809 params.push("sources", f);
5810 }
5811 }
5812 if let Some(value) = self._sort_order.as_ref() {
5813 params.push("sortOrder", value);
5814 }
5815 if let Some(value) = self._request_sync_token.as_ref() {
5816 params.push("requestSyncToken", value.to_string());
5817 }
5818 if let Some(value) = self._request_mask_include_field.as_ref() {
5819 params.push("requestMask.includeField", value.to_string());
5820 }
5821 if let Some(value) = self._person_fields.as_ref() {
5822 params.push("personFields", value.to_string());
5823 }
5824 if let Some(value) = self._page_token.as_ref() {
5825 params.push("pageToken", value);
5826 }
5827 if let Some(value) = self._page_size.as_ref() {
5828 params.push("pageSize", value.to_string());
5829 }
5830
5831 params.extend(self._additional_params.iter());
5832
5833 params.push("alt", "json");
5834 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}/connections";
5835 if self._scopes.is_empty() {
5836 self._scopes
5837 .insert(Scope::ContactReadonly.as_ref().to_string());
5838 }
5839
5840 #[allow(clippy::single_element_loop)]
5841 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
5842 url = params.uri_replacement(url, param_name, find_this, true);
5843 }
5844 {
5845 let to_remove = ["resourceName"];
5846 params.remove_params(&to_remove);
5847 }
5848
5849 let url = params.parse_with_url(&url);
5850
5851 loop {
5852 let token = match self
5853 .hub
5854 .auth
5855 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5856 .await
5857 {
5858 Ok(token) => token,
5859 Err(e) => match dlg.token(e) {
5860 Ok(token) => token,
5861 Err(e) => {
5862 dlg.finished(false);
5863 return Err(common::Error::MissingToken(e));
5864 }
5865 },
5866 };
5867 let mut req_result = {
5868 let client = &self.hub.client;
5869 dlg.pre_request();
5870 let mut req_builder = hyper::Request::builder()
5871 .method(hyper::Method::GET)
5872 .uri(url.as_str())
5873 .header(USER_AGENT, self.hub._user_agent.clone());
5874
5875 if let Some(token) = token.as_ref() {
5876 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5877 }
5878
5879 let request = req_builder
5880 .header(CONTENT_LENGTH, 0_u64)
5881 .body(common::to_body::<String>(None));
5882
5883 client.request(request.unwrap()).await
5884 };
5885
5886 match req_result {
5887 Err(err) => {
5888 if let common::Retry::After(d) = dlg.http_error(&err) {
5889 sleep(d).await;
5890 continue;
5891 }
5892 dlg.finished(false);
5893 return Err(common::Error::HttpError(err));
5894 }
5895 Ok(res) => {
5896 let (mut parts, body) = res.into_parts();
5897 let mut body = common::Body::new(body);
5898 if !parts.status.is_success() {
5899 let bytes = common::to_bytes(body).await.unwrap_or_default();
5900 let error = serde_json::from_str(&common::to_string(&bytes));
5901 let response = common::to_response(parts, bytes.into());
5902
5903 if let common::Retry::After(d) =
5904 dlg.http_failure(&response, error.as_ref().ok())
5905 {
5906 sleep(d).await;
5907 continue;
5908 }
5909
5910 dlg.finished(false);
5911
5912 return Err(match error {
5913 Ok(value) => common::Error::BadRequest(value),
5914 _ => common::Error::Failure(response),
5915 });
5916 }
5917 let response = {
5918 let bytes = common::to_bytes(body).await.unwrap_or_default();
5919 let encoded = common::to_string(&bytes);
5920 match serde_json::from_str(&encoded) {
5921 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5922 Err(error) => {
5923 dlg.response_json_decode_error(&encoded, &error);
5924 return Err(common::Error::JsonDecodeError(
5925 encoded.to_string(),
5926 error,
5927 ));
5928 }
5929 }
5930 };
5931
5932 dlg.finished(true);
5933 return Ok(response);
5934 }
5935 }
5936 }
5937 }
5938
5939 /// Required. The resource name to return connections for. Only `people/me` is valid.
5940 ///
5941 /// Sets the *resource name* path property to the given value.
5942 ///
5943 /// Even though the property as already been set when instantiating this call,
5944 /// we provide this method for API completeness.
5945 pub fn resource_name(mut self, new_value: &str) -> PersonConnectionListCall<'a, C> {
5946 self._resource_name = new_value.to_string();
5947 self
5948 }
5949 /// Optional. A sync token, received from a previous response `next_sync_token` Provide this to retrieve only the resources changed since the last request. When syncing, all other parameters provided to `people.connections.list` must match the first call that provided the sync token. More details about sync behavior at `people.connections.list`.
5950 ///
5951 /// Sets the *sync token* query property to the given value.
5952 pub fn sync_token(mut self, new_value: &str) -> PersonConnectionListCall<'a, C> {
5953 self._sync_token = Some(new_value.to_string());
5954 self
5955 }
5956 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
5957 ///
5958 /// Append the given value to the *sources* query property.
5959 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5960 pub fn add_sources(mut self, new_value: &str) -> PersonConnectionListCall<'a, C> {
5961 self._sources.push(new_value.to_string());
5962 self
5963 }
5964 /// Optional. The order in which the connections should be sorted. Defaults to `LAST_MODIFIED_ASCENDING`.
5965 ///
5966 /// Sets the *sort order* query property to the given value.
5967 pub fn sort_order(mut self, new_value: &str) -> PersonConnectionListCall<'a, C> {
5968 self._sort_order = Some(new_value.to_string());
5969 self
5970 }
5971 /// Optional. Whether the response should return `next_sync_token` on the last page of results. It can be used to get incremental changes since the last request by setting it on the request `sync_token`. More details about sync behavior at `people.connections.list`.
5972 ///
5973 /// Sets the *request sync token* query property to the given value.
5974 pub fn request_sync_token(mut self, new_value: bool) -> PersonConnectionListCall<'a, C> {
5975 self._request_sync_token = Some(new_value);
5976 self
5977 }
5978 /// Required. Comma-separated list of person fields to be included in the response. Each path should start with `person.`: for example, `person.names` or `person.photos`.
5979 ///
5980 /// Sets the *request mask.include field* query property to the given value.
5981 pub fn request_mask_include_field(
5982 mut self,
5983 new_value: common::FieldMask,
5984 ) -> PersonConnectionListCall<'a, C> {
5985 self._request_mask_include_field = Some(new_value);
5986 self
5987 }
5988 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
5989 ///
5990 /// Sets the *person fields* query property to the given value.
5991 pub fn person_fields(
5992 mut self,
5993 new_value: common::FieldMask,
5994 ) -> PersonConnectionListCall<'a, C> {
5995 self._person_fields = Some(new_value);
5996 self
5997 }
5998 /// Optional. A page token, received from a previous response `next_page_token`. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `people.connections.list` must match the first call that provided the page token.
5999 ///
6000 /// Sets the *page token* query property to the given value.
6001 pub fn page_token(mut self, new_value: &str) -> PersonConnectionListCall<'a, C> {
6002 self._page_token = Some(new_value.to_string());
6003 self
6004 }
6005 /// Optional. The number of connections to include in the response. Valid values are between 1 and 1000, inclusive. Defaults to 100 if not set or set to 0.
6006 ///
6007 /// Sets the *page size* query property to the given value.
6008 pub fn page_size(mut self, new_value: i32) -> PersonConnectionListCall<'a, C> {
6009 self._page_size = Some(new_value);
6010 self
6011 }
6012 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6013 /// while executing the actual API request.
6014 ///
6015 /// ````text
6016 /// It should be used to handle progress information, and to implement a certain level of resilience.
6017 /// ````
6018 ///
6019 /// Sets the *delegate* property to the given value.
6020 pub fn delegate(
6021 mut self,
6022 new_value: &'a mut dyn common::Delegate,
6023 ) -> PersonConnectionListCall<'a, C> {
6024 self._delegate = Some(new_value);
6025 self
6026 }
6027
6028 /// Set any additional parameter of the query string used in the request.
6029 /// It should be used to set parameters which are not yet available through their own
6030 /// setters.
6031 ///
6032 /// Please note that this method must not be used to set any of the known parameters
6033 /// which have their own setter method. If done anyway, the request will fail.
6034 ///
6035 /// # Additional Parameters
6036 ///
6037 /// * *$.xgafv* (query-string) - V1 error format.
6038 /// * *access_token* (query-string) - OAuth access token.
6039 /// * *alt* (query-string) - Data format for response.
6040 /// * *callback* (query-string) - JSONP
6041 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6042 /// * *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.
6043 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6044 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6045 /// * *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.
6046 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6047 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6048 pub fn param<T>(mut self, name: T, value: T) -> PersonConnectionListCall<'a, C>
6049 where
6050 T: AsRef<str>,
6051 {
6052 self._additional_params
6053 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6054 self
6055 }
6056
6057 /// Identifies the authorization scope for the method you are building.
6058 ///
6059 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6060 /// [`Scope::ContactReadonly`].
6061 ///
6062 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6063 /// tokens for more than one scope.
6064 ///
6065 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6066 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6067 /// sufficient, a read-write scope will do as well.
6068 pub fn add_scope<St>(mut self, scope: St) -> PersonConnectionListCall<'a, C>
6069 where
6070 St: AsRef<str>,
6071 {
6072 self._scopes.insert(String::from(scope.as_ref()));
6073 self
6074 }
6075 /// Identifies the authorization scope(s) for the method you are building.
6076 ///
6077 /// See [`Self::add_scope()`] for details.
6078 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonConnectionListCall<'a, C>
6079 where
6080 I: IntoIterator<Item = St>,
6081 St: AsRef<str>,
6082 {
6083 self._scopes
6084 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6085 self
6086 }
6087
6088 /// Removes all scopes, and no default scope will be used either.
6089 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6090 /// for details).
6091 pub fn clear_scopes(mut self) -> PersonConnectionListCall<'a, C> {
6092 self._scopes.clear();
6093 self
6094 }
6095}
6096
6097/// Create a batch of new contacts and return the PersonResponses for the newly Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
6098///
6099/// A builder for the *batchCreateContacts* method supported by a *person* resource.
6100/// It is not used directly, but through a [`PersonMethods`] instance.
6101///
6102/// # Example
6103///
6104/// Instantiate a resource method builder
6105///
6106/// ```test_harness,no_run
6107/// # extern crate hyper;
6108/// # extern crate hyper_rustls;
6109/// # extern crate google_people1 as people1;
6110/// use people1::api::BatchCreateContactsRequest;
6111/// # async fn dox() {
6112/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6113///
6114/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6115/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6116/// # secret,
6117/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6118/// # ).build().await.unwrap();
6119///
6120/// # let client = hyper_util::client::legacy::Client::builder(
6121/// # hyper_util::rt::TokioExecutor::new()
6122/// # )
6123/// # .build(
6124/// # hyper_rustls::HttpsConnectorBuilder::new()
6125/// # .with_native_roots()
6126/// # .unwrap()
6127/// # .https_or_http()
6128/// # .enable_http1()
6129/// # .build()
6130/// # );
6131/// # let mut hub = PeopleService::new(client, auth);
6132/// // As the method needs a request, you would usually fill it with the desired information
6133/// // into the respective structure. Some of the parts shown here might not be applicable !
6134/// // Values shown here are possibly random and not representative !
6135/// let mut req = BatchCreateContactsRequest::default();
6136///
6137/// // You can configure optional parameters by calling the respective setters at will, and
6138/// // execute the final call using `doit()`.
6139/// // Values shown here are possibly random and not representative !
6140/// let result = hub.people().batch_create_contacts(req)
6141/// .doit().await;
6142/// # }
6143/// ```
6144pub struct PersonBatchCreateContactCall<'a, C>
6145where
6146 C: 'a,
6147{
6148 hub: &'a PeopleService<C>,
6149 _request: BatchCreateContactsRequest,
6150 _delegate: Option<&'a mut dyn common::Delegate>,
6151 _additional_params: HashMap<String, String>,
6152 _scopes: BTreeSet<String>,
6153}
6154
6155impl<'a, C> common::CallBuilder for PersonBatchCreateContactCall<'a, C> {}
6156
6157impl<'a, C> PersonBatchCreateContactCall<'a, C>
6158where
6159 C: common::Connector,
6160{
6161 /// Perform the operation you have build so far.
6162 pub async fn doit(mut self) -> common::Result<(common::Response, BatchCreateContactsResponse)> {
6163 use std::borrow::Cow;
6164 use std::io::{Read, Seek};
6165
6166 use common::{url::Params, ToParts};
6167 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6168
6169 let mut dd = common::DefaultDelegate;
6170 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6171 dlg.begin(common::MethodInfo {
6172 id: "people.people.batchCreateContacts",
6173 http_method: hyper::Method::POST,
6174 });
6175
6176 for &field in ["alt"].iter() {
6177 if self._additional_params.contains_key(field) {
6178 dlg.finished(false);
6179 return Err(common::Error::FieldClash(field));
6180 }
6181 }
6182
6183 let mut params = Params::with_capacity(3 + self._additional_params.len());
6184
6185 params.extend(self._additional_params.iter());
6186
6187 params.push("alt", "json");
6188 let mut url = self.hub._base_url.clone() + "v1/people:batchCreateContacts";
6189 if self._scopes.is_empty() {
6190 self._scopes.insert(Scope::Contact.as_ref().to_string());
6191 }
6192
6193 let url = params.parse_with_url(&url);
6194
6195 let mut json_mime_type = mime::APPLICATION_JSON;
6196 let mut request_value_reader = {
6197 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6198 common::remove_json_null_values(&mut value);
6199 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6200 serde_json::to_writer(&mut dst, &value).unwrap();
6201 dst
6202 };
6203 let request_size = request_value_reader
6204 .seek(std::io::SeekFrom::End(0))
6205 .unwrap();
6206 request_value_reader
6207 .seek(std::io::SeekFrom::Start(0))
6208 .unwrap();
6209
6210 loop {
6211 let token = match self
6212 .hub
6213 .auth
6214 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6215 .await
6216 {
6217 Ok(token) => token,
6218 Err(e) => match dlg.token(e) {
6219 Ok(token) => token,
6220 Err(e) => {
6221 dlg.finished(false);
6222 return Err(common::Error::MissingToken(e));
6223 }
6224 },
6225 };
6226 request_value_reader
6227 .seek(std::io::SeekFrom::Start(0))
6228 .unwrap();
6229 let mut req_result = {
6230 let client = &self.hub.client;
6231 dlg.pre_request();
6232 let mut req_builder = hyper::Request::builder()
6233 .method(hyper::Method::POST)
6234 .uri(url.as_str())
6235 .header(USER_AGENT, self.hub._user_agent.clone());
6236
6237 if let Some(token) = token.as_ref() {
6238 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6239 }
6240
6241 let request = req_builder
6242 .header(CONTENT_TYPE, json_mime_type.to_string())
6243 .header(CONTENT_LENGTH, request_size as u64)
6244 .body(common::to_body(
6245 request_value_reader.get_ref().clone().into(),
6246 ));
6247
6248 client.request(request.unwrap()).await
6249 };
6250
6251 match req_result {
6252 Err(err) => {
6253 if let common::Retry::After(d) = dlg.http_error(&err) {
6254 sleep(d).await;
6255 continue;
6256 }
6257 dlg.finished(false);
6258 return Err(common::Error::HttpError(err));
6259 }
6260 Ok(res) => {
6261 let (mut parts, body) = res.into_parts();
6262 let mut body = common::Body::new(body);
6263 if !parts.status.is_success() {
6264 let bytes = common::to_bytes(body).await.unwrap_or_default();
6265 let error = serde_json::from_str(&common::to_string(&bytes));
6266 let response = common::to_response(parts, bytes.into());
6267
6268 if let common::Retry::After(d) =
6269 dlg.http_failure(&response, error.as_ref().ok())
6270 {
6271 sleep(d).await;
6272 continue;
6273 }
6274
6275 dlg.finished(false);
6276
6277 return Err(match error {
6278 Ok(value) => common::Error::BadRequest(value),
6279 _ => common::Error::Failure(response),
6280 });
6281 }
6282 let response = {
6283 let bytes = common::to_bytes(body).await.unwrap_or_default();
6284 let encoded = common::to_string(&bytes);
6285 match serde_json::from_str(&encoded) {
6286 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6287 Err(error) => {
6288 dlg.response_json_decode_error(&encoded, &error);
6289 return Err(common::Error::JsonDecodeError(
6290 encoded.to_string(),
6291 error,
6292 ));
6293 }
6294 }
6295 };
6296
6297 dlg.finished(true);
6298 return Ok(response);
6299 }
6300 }
6301 }
6302 }
6303
6304 ///
6305 /// Sets the *request* property to the given value.
6306 ///
6307 /// Even though the property as already been set when instantiating this call,
6308 /// we provide this method for API completeness.
6309 pub fn request(
6310 mut self,
6311 new_value: BatchCreateContactsRequest,
6312 ) -> PersonBatchCreateContactCall<'a, C> {
6313 self._request = new_value;
6314 self
6315 }
6316 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6317 /// while executing the actual API request.
6318 ///
6319 /// ````text
6320 /// It should be used to handle progress information, and to implement a certain level of resilience.
6321 /// ````
6322 ///
6323 /// Sets the *delegate* property to the given value.
6324 pub fn delegate(
6325 mut self,
6326 new_value: &'a mut dyn common::Delegate,
6327 ) -> PersonBatchCreateContactCall<'a, C> {
6328 self._delegate = Some(new_value);
6329 self
6330 }
6331
6332 /// Set any additional parameter of the query string used in the request.
6333 /// It should be used to set parameters which are not yet available through their own
6334 /// setters.
6335 ///
6336 /// Please note that this method must not be used to set any of the known parameters
6337 /// which have their own setter method. If done anyway, the request will fail.
6338 ///
6339 /// # Additional Parameters
6340 ///
6341 /// * *$.xgafv* (query-string) - V1 error format.
6342 /// * *access_token* (query-string) - OAuth access token.
6343 /// * *alt* (query-string) - Data format for response.
6344 /// * *callback* (query-string) - JSONP
6345 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6346 /// * *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.
6347 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6348 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6349 /// * *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.
6350 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6351 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6352 pub fn param<T>(mut self, name: T, value: T) -> PersonBatchCreateContactCall<'a, C>
6353 where
6354 T: AsRef<str>,
6355 {
6356 self._additional_params
6357 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6358 self
6359 }
6360
6361 /// Identifies the authorization scope for the method you are building.
6362 ///
6363 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6364 /// [`Scope::Contact`].
6365 ///
6366 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6367 /// tokens for more than one scope.
6368 ///
6369 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6370 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6371 /// sufficient, a read-write scope will do as well.
6372 pub fn add_scope<St>(mut self, scope: St) -> PersonBatchCreateContactCall<'a, C>
6373 where
6374 St: AsRef<str>,
6375 {
6376 self._scopes.insert(String::from(scope.as_ref()));
6377 self
6378 }
6379 /// Identifies the authorization scope(s) for the method you are building.
6380 ///
6381 /// See [`Self::add_scope()`] for details.
6382 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonBatchCreateContactCall<'a, C>
6383 where
6384 I: IntoIterator<Item = St>,
6385 St: AsRef<str>,
6386 {
6387 self._scopes
6388 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6389 self
6390 }
6391
6392 /// Removes all scopes, and no default scope will be used either.
6393 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6394 /// for details).
6395 pub fn clear_scopes(mut self) -> PersonBatchCreateContactCall<'a, C> {
6396 self._scopes.clear();
6397 self
6398 }
6399}
6400
6401/// Delete a batch of contacts. Any non-contact data will not be deleted. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
6402///
6403/// A builder for the *batchDeleteContacts* method supported by a *person* resource.
6404/// It is not used directly, but through a [`PersonMethods`] instance.
6405///
6406/// # Example
6407///
6408/// Instantiate a resource method builder
6409///
6410/// ```test_harness,no_run
6411/// # extern crate hyper;
6412/// # extern crate hyper_rustls;
6413/// # extern crate google_people1 as people1;
6414/// use people1::api::BatchDeleteContactsRequest;
6415/// # async fn dox() {
6416/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6417///
6418/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6419/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6420/// # secret,
6421/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6422/// # ).build().await.unwrap();
6423///
6424/// # let client = hyper_util::client::legacy::Client::builder(
6425/// # hyper_util::rt::TokioExecutor::new()
6426/// # )
6427/// # .build(
6428/// # hyper_rustls::HttpsConnectorBuilder::new()
6429/// # .with_native_roots()
6430/// # .unwrap()
6431/// # .https_or_http()
6432/// # .enable_http1()
6433/// # .build()
6434/// # );
6435/// # let mut hub = PeopleService::new(client, auth);
6436/// // As the method needs a request, you would usually fill it with the desired information
6437/// // into the respective structure. Some of the parts shown here might not be applicable !
6438/// // Values shown here are possibly random and not representative !
6439/// let mut req = BatchDeleteContactsRequest::default();
6440///
6441/// // You can configure optional parameters by calling the respective setters at will, and
6442/// // execute the final call using `doit()`.
6443/// // Values shown here are possibly random and not representative !
6444/// let result = hub.people().batch_delete_contacts(req)
6445/// .doit().await;
6446/// # }
6447/// ```
6448pub struct PersonBatchDeleteContactCall<'a, C>
6449where
6450 C: 'a,
6451{
6452 hub: &'a PeopleService<C>,
6453 _request: BatchDeleteContactsRequest,
6454 _delegate: Option<&'a mut dyn common::Delegate>,
6455 _additional_params: HashMap<String, String>,
6456 _scopes: BTreeSet<String>,
6457}
6458
6459impl<'a, C> common::CallBuilder for PersonBatchDeleteContactCall<'a, C> {}
6460
6461impl<'a, C> PersonBatchDeleteContactCall<'a, C>
6462where
6463 C: common::Connector,
6464{
6465 /// Perform the operation you have build so far.
6466 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6467 use std::borrow::Cow;
6468 use std::io::{Read, Seek};
6469
6470 use common::{url::Params, ToParts};
6471 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6472
6473 let mut dd = common::DefaultDelegate;
6474 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6475 dlg.begin(common::MethodInfo {
6476 id: "people.people.batchDeleteContacts",
6477 http_method: hyper::Method::POST,
6478 });
6479
6480 for &field in ["alt"].iter() {
6481 if self._additional_params.contains_key(field) {
6482 dlg.finished(false);
6483 return Err(common::Error::FieldClash(field));
6484 }
6485 }
6486
6487 let mut params = Params::with_capacity(3 + self._additional_params.len());
6488
6489 params.extend(self._additional_params.iter());
6490
6491 params.push("alt", "json");
6492 let mut url = self.hub._base_url.clone() + "v1/people:batchDeleteContacts";
6493 if self._scopes.is_empty() {
6494 self._scopes.insert(Scope::Contact.as_ref().to_string());
6495 }
6496
6497 let url = params.parse_with_url(&url);
6498
6499 let mut json_mime_type = mime::APPLICATION_JSON;
6500 let mut request_value_reader = {
6501 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6502 common::remove_json_null_values(&mut value);
6503 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6504 serde_json::to_writer(&mut dst, &value).unwrap();
6505 dst
6506 };
6507 let request_size = request_value_reader
6508 .seek(std::io::SeekFrom::End(0))
6509 .unwrap();
6510 request_value_reader
6511 .seek(std::io::SeekFrom::Start(0))
6512 .unwrap();
6513
6514 loop {
6515 let token = match self
6516 .hub
6517 .auth
6518 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6519 .await
6520 {
6521 Ok(token) => token,
6522 Err(e) => match dlg.token(e) {
6523 Ok(token) => token,
6524 Err(e) => {
6525 dlg.finished(false);
6526 return Err(common::Error::MissingToken(e));
6527 }
6528 },
6529 };
6530 request_value_reader
6531 .seek(std::io::SeekFrom::Start(0))
6532 .unwrap();
6533 let mut req_result = {
6534 let client = &self.hub.client;
6535 dlg.pre_request();
6536 let mut req_builder = hyper::Request::builder()
6537 .method(hyper::Method::POST)
6538 .uri(url.as_str())
6539 .header(USER_AGENT, self.hub._user_agent.clone());
6540
6541 if let Some(token) = token.as_ref() {
6542 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6543 }
6544
6545 let request = req_builder
6546 .header(CONTENT_TYPE, json_mime_type.to_string())
6547 .header(CONTENT_LENGTH, request_size as u64)
6548 .body(common::to_body(
6549 request_value_reader.get_ref().clone().into(),
6550 ));
6551
6552 client.request(request.unwrap()).await
6553 };
6554
6555 match req_result {
6556 Err(err) => {
6557 if let common::Retry::After(d) = dlg.http_error(&err) {
6558 sleep(d).await;
6559 continue;
6560 }
6561 dlg.finished(false);
6562 return Err(common::Error::HttpError(err));
6563 }
6564 Ok(res) => {
6565 let (mut parts, body) = res.into_parts();
6566 let mut body = common::Body::new(body);
6567 if !parts.status.is_success() {
6568 let bytes = common::to_bytes(body).await.unwrap_or_default();
6569 let error = serde_json::from_str(&common::to_string(&bytes));
6570 let response = common::to_response(parts, bytes.into());
6571
6572 if let common::Retry::After(d) =
6573 dlg.http_failure(&response, error.as_ref().ok())
6574 {
6575 sleep(d).await;
6576 continue;
6577 }
6578
6579 dlg.finished(false);
6580
6581 return Err(match error {
6582 Ok(value) => common::Error::BadRequest(value),
6583 _ => common::Error::Failure(response),
6584 });
6585 }
6586 let response = {
6587 let bytes = common::to_bytes(body).await.unwrap_or_default();
6588 let encoded = common::to_string(&bytes);
6589 match serde_json::from_str(&encoded) {
6590 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6591 Err(error) => {
6592 dlg.response_json_decode_error(&encoded, &error);
6593 return Err(common::Error::JsonDecodeError(
6594 encoded.to_string(),
6595 error,
6596 ));
6597 }
6598 }
6599 };
6600
6601 dlg.finished(true);
6602 return Ok(response);
6603 }
6604 }
6605 }
6606 }
6607
6608 ///
6609 /// Sets the *request* property to the given value.
6610 ///
6611 /// Even though the property as already been set when instantiating this call,
6612 /// we provide this method for API completeness.
6613 pub fn request(
6614 mut self,
6615 new_value: BatchDeleteContactsRequest,
6616 ) -> PersonBatchDeleteContactCall<'a, C> {
6617 self._request = new_value;
6618 self
6619 }
6620 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6621 /// while executing the actual API request.
6622 ///
6623 /// ````text
6624 /// It should be used to handle progress information, and to implement a certain level of resilience.
6625 /// ````
6626 ///
6627 /// Sets the *delegate* property to the given value.
6628 pub fn delegate(
6629 mut self,
6630 new_value: &'a mut dyn common::Delegate,
6631 ) -> PersonBatchDeleteContactCall<'a, C> {
6632 self._delegate = Some(new_value);
6633 self
6634 }
6635
6636 /// Set any additional parameter of the query string used in the request.
6637 /// It should be used to set parameters which are not yet available through their own
6638 /// setters.
6639 ///
6640 /// Please note that this method must not be used to set any of the known parameters
6641 /// which have their own setter method. If done anyway, the request will fail.
6642 ///
6643 /// # Additional Parameters
6644 ///
6645 /// * *$.xgafv* (query-string) - V1 error format.
6646 /// * *access_token* (query-string) - OAuth access token.
6647 /// * *alt* (query-string) - Data format for response.
6648 /// * *callback* (query-string) - JSONP
6649 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6650 /// * *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.
6651 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6652 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6653 /// * *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.
6654 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6655 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6656 pub fn param<T>(mut self, name: T, value: T) -> PersonBatchDeleteContactCall<'a, C>
6657 where
6658 T: AsRef<str>,
6659 {
6660 self._additional_params
6661 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6662 self
6663 }
6664
6665 /// Identifies the authorization scope for the method you are building.
6666 ///
6667 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6668 /// [`Scope::Contact`].
6669 ///
6670 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6671 /// tokens for more than one scope.
6672 ///
6673 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6674 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6675 /// sufficient, a read-write scope will do as well.
6676 pub fn add_scope<St>(mut self, scope: St) -> PersonBatchDeleteContactCall<'a, C>
6677 where
6678 St: AsRef<str>,
6679 {
6680 self._scopes.insert(String::from(scope.as_ref()));
6681 self
6682 }
6683 /// Identifies the authorization scope(s) for the method you are building.
6684 ///
6685 /// See [`Self::add_scope()`] for details.
6686 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonBatchDeleteContactCall<'a, C>
6687 where
6688 I: IntoIterator<Item = St>,
6689 St: AsRef<str>,
6690 {
6691 self._scopes
6692 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6693 self
6694 }
6695
6696 /// Removes all scopes, and no default scope will be used either.
6697 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6698 /// for details).
6699 pub fn clear_scopes(mut self) -> PersonBatchDeleteContactCall<'a, C> {
6700 self._scopes.clear();
6701 self
6702 }
6703}
6704
6705/// Update a batch of contacts and return a map of resource names to PersonResponses for the updated contacts. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
6706///
6707/// A builder for the *batchUpdateContacts* method supported by a *person* resource.
6708/// It is not used directly, but through a [`PersonMethods`] instance.
6709///
6710/// # Example
6711///
6712/// Instantiate a resource method builder
6713///
6714/// ```test_harness,no_run
6715/// # extern crate hyper;
6716/// # extern crate hyper_rustls;
6717/// # extern crate google_people1 as people1;
6718/// use people1::api::BatchUpdateContactsRequest;
6719/// # async fn dox() {
6720/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6721///
6722/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6723/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6724/// # secret,
6725/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6726/// # ).build().await.unwrap();
6727///
6728/// # let client = hyper_util::client::legacy::Client::builder(
6729/// # hyper_util::rt::TokioExecutor::new()
6730/// # )
6731/// # .build(
6732/// # hyper_rustls::HttpsConnectorBuilder::new()
6733/// # .with_native_roots()
6734/// # .unwrap()
6735/// # .https_or_http()
6736/// # .enable_http1()
6737/// # .build()
6738/// # );
6739/// # let mut hub = PeopleService::new(client, auth);
6740/// // As the method needs a request, you would usually fill it with the desired information
6741/// // into the respective structure. Some of the parts shown here might not be applicable !
6742/// // Values shown here are possibly random and not representative !
6743/// let mut req = BatchUpdateContactsRequest::default();
6744///
6745/// // You can configure optional parameters by calling the respective setters at will, and
6746/// // execute the final call using `doit()`.
6747/// // Values shown here are possibly random and not representative !
6748/// let result = hub.people().batch_update_contacts(req)
6749/// .doit().await;
6750/// # }
6751/// ```
6752pub struct PersonBatchUpdateContactCall<'a, C>
6753where
6754 C: 'a,
6755{
6756 hub: &'a PeopleService<C>,
6757 _request: BatchUpdateContactsRequest,
6758 _delegate: Option<&'a mut dyn common::Delegate>,
6759 _additional_params: HashMap<String, String>,
6760 _scopes: BTreeSet<String>,
6761}
6762
6763impl<'a, C> common::CallBuilder for PersonBatchUpdateContactCall<'a, C> {}
6764
6765impl<'a, C> PersonBatchUpdateContactCall<'a, C>
6766where
6767 C: common::Connector,
6768{
6769 /// Perform the operation you have build so far.
6770 pub async fn doit(mut self) -> common::Result<(common::Response, BatchUpdateContactsResponse)> {
6771 use std::borrow::Cow;
6772 use std::io::{Read, Seek};
6773
6774 use common::{url::Params, ToParts};
6775 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6776
6777 let mut dd = common::DefaultDelegate;
6778 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6779 dlg.begin(common::MethodInfo {
6780 id: "people.people.batchUpdateContacts",
6781 http_method: hyper::Method::POST,
6782 });
6783
6784 for &field in ["alt"].iter() {
6785 if self._additional_params.contains_key(field) {
6786 dlg.finished(false);
6787 return Err(common::Error::FieldClash(field));
6788 }
6789 }
6790
6791 let mut params = Params::with_capacity(3 + self._additional_params.len());
6792
6793 params.extend(self._additional_params.iter());
6794
6795 params.push("alt", "json");
6796 let mut url = self.hub._base_url.clone() + "v1/people:batchUpdateContacts";
6797 if self._scopes.is_empty() {
6798 self._scopes.insert(Scope::Contact.as_ref().to_string());
6799 }
6800
6801 let url = params.parse_with_url(&url);
6802
6803 let mut json_mime_type = mime::APPLICATION_JSON;
6804 let mut request_value_reader = {
6805 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6806 common::remove_json_null_values(&mut value);
6807 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6808 serde_json::to_writer(&mut dst, &value).unwrap();
6809 dst
6810 };
6811 let request_size = request_value_reader
6812 .seek(std::io::SeekFrom::End(0))
6813 .unwrap();
6814 request_value_reader
6815 .seek(std::io::SeekFrom::Start(0))
6816 .unwrap();
6817
6818 loop {
6819 let token = match self
6820 .hub
6821 .auth
6822 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6823 .await
6824 {
6825 Ok(token) => token,
6826 Err(e) => match dlg.token(e) {
6827 Ok(token) => token,
6828 Err(e) => {
6829 dlg.finished(false);
6830 return Err(common::Error::MissingToken(e));
6831 }
6832 },
6833 };
6834 request_value_reader
6835 .seek(std::io::SeekFrom::Start(0))
6836 .unwrap();
6837 let mut req_result = {
6838 let client = &self.hub.client;
6839 dlg.pre_request();
6840 let mut req_builder = hyper::Request::builder()
6841 .method(hyper::Method::POST)
6842 .uri(url.as_str())
6843 .header(USER_AGENT, self.hub._user_agent.clone());
6844
6845 if let Some(token) = token.as_ref() {
6846 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6847 }
6848
6849 let request = req_builder
6850 .header(CONTENT_TYPE, json_mime_type.to_string())
6851 .header(CONTENT_LENGTH, request_size as u64)
6852 .body(common::to_body(
6853 request_value_reader.get_ref().clone().into(),
6854 ));
6855
6856 client.request(request.unwrap()).await
6857 };
6858
6859 match req_result {
6860 Err(err) => {
6861 if let common::Retry::After(d) = dlg.http_error(&err) {
6862 sleep(d).await;
6863 continue;
6864 }
6865 dlg.finished(false);
6866 return Err(common::Error::HttpError(err));
6867 }
6868 Ok(res) => {
6869 let (mut parts, body) = res.into_parts();
6870 let mut body = common::Body::new(body);
6871 if !parts.status.is_success() {
6872 let bytes = common::to_bytes(body).await.unwrap_or_default();
6873 let error = serde_json::from_str(&common::to_string(&bytes));
6874 let response = common::to_response(parts, bytes.into());
6875
6876 if let common::Retry::After(d) =
6877 dlg.http_failure(&response, error.as_ref().ok())
6878 {
6879 sleep(d).await;
6880 continue;
6881 }
6882
6883 dlg.finished(false);
6884
6885 return Err(match error {
6886 Ok(value) => common::Error::BadRequest(value),
6887 _ => common::Error::Failure(response),
6888 });
6889 }
6890 let response = {
6891 let bytes = common::to_bytes(body).await.unwrap_or_default();
6892 let encoded = common::to_string(&bytes);
6893 match serde_json::from_str(&encoded) {
6894 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6895 Err(error) => {
6896 dlg.response_json_decode_error(&encoded, &error);
6897 return Err(common::Error::JsonDecodeError(
6898 encoded.to_string(),
6899 error,
6900 ));
6901 }
6902 }
6903 };
6904
6905 dlg.finished(true);
6906 return Ok(response);
6907 }
6908 }
6909 }
6910 }
6911
6912 ///
6913 /// Sets the *request* property to the given value.
6914 ///
6915 /// Even though the property as already been set when instantiating this call,
6916 /// we provide this method for API completeness.
6917 pub fn request(
6918 mut self,
6919 new_value: BatchUpdateContactsRequest,
6920 ) -> PersonBatchUpdateContactCall<'a, C> {
6921 self._request = new_value;
6922 self
6923 }
6924 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6925 /// while executing the actual API request.
6926 ///
6927 /// ````text
6928 /// It should be used to handle progress information, and to implement a certain level of resilience.
6929 /// ````
6930 ///
6931 /// Sets the *delegate* property to the given value.
6932 pub fn delegate(
6933 mut self,
6934 new_value: &'a mut dyn common::Delegate,
6935 ) -> PersonBatchUpdateContactCall<'a, C> {
6936 self._delegate = Some(new_value);
6937 self
6938 }
6939
6940 /// Set any additional parameter of the query string used in the request.
6941 /// It should be used to set parameters which are not yet available through their own
6942 /// setters.
6943 ///
6944 /// Please note that this method must not be used to set any of the known parameters
6945 /// which have their own setter method. If done anyway, the request will fail.
6946 ///
6947 /// # Additional Parameters
6948 ///
6949 /// * *$.xgafv* (query-string) - V1 error format.
6950 /// * *access_token* (query-string) - OAuth access token.
6951 /// * *alt* (query-string) - Data format for response.
6952 /// * *callback* (query-string) - JSONP
6953 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6954 /// * *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.
6955 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6956 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6957 /// * *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.
6958 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6959 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6960 pub fn param<T>(mut self, name: T, value: T) -> PersonBatchUpdateContactCall<'a, C>
6961 where
6962 T: AsRef<str>,
6963 {
6964 self._additional_params
6965 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6966 self
6967 }
6968
6969 /// Identifies the authorization scope for the method you are building.
6970 ///
6971 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6972 /// [`Scope::Contact`].
6973 ///
6974 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6975 /// tokens for more than one scope.
6976 ///
6977 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6978 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6979 /// sufficient, a read-write scope will do as well.
6980 pub fn add_scope<St>(mut self, scope: St) -> PersonBatchUpdateContactCall<'a, C>
6981 where
6982 St: AsRef<str>,
6983 {
6984 self._scopes.insert(String::from(scope.as_ref()));
6985 self
6986 }
6987 /// Identifies the authorization scope(s) for the method you are building.
6988 ///
6989 /// See [`Self::add_scope()`] for details.
6990 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonBatchUpdateContactCall<'a, C>
6991 where
6992 I: IntoIterator<Item = St>,
6993 St: AsRef<str>,
6994 {
6995 self._scopes
6996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6997 self
6998 }
6999
7000 /// Removes all scopes, and no default scope will be used either.
7001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7002 /// for details).
7003 pub fn clear_scopes(mut self) -> PersonBatchUpdateContactCall<'a, C> {
7004 self._scopes.clear();
7005 self
7006 }
7007}
7008
7009/// Create a new contact and return the person resource for that contact. The request returns a 400 error if more than one field is specified on a field that is a singleton for contact sources: * biographies * birthdays * genders * names Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
7010///
7011/// A builder for the *createContact* method supported by a *person* resource.
7012/// It is not used directly, but through a [`PersonMethods`] instance.
7013///
7014/// # Example
7015///
7016/// Instantiate a resource method builder
7017///
7018/// ```test_harness,no_run
7019/// # extern crate hyper;
7020/// # extern crate hyper_rustls;
7021/// # extern crate google_people1 as people1;
7022/// use people1::api::Person;
7023/// # async fn dox() {
7024/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7025///
7026/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7027/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7028/// # secret,
7029/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7030/// # ).build().await.unwrap();
7031///
7032/// # let client = hyper_util::client::legacy::Client::builder(
7033/// # hyper_util::rt::TokioExecutor::new()
7034/// # )
7035/// # .build(
7036/// # hyper_rustls::HttpsConnectorBuilder::new()
7037/// # .with_native_roots()
7038/// # .unwrap()
7039/// # .https_or_http()
7040/// # .enable_http1()
7041/// # .build()
7042/// # );
7043/// # let mut hub = PeopleService::new(client, auth);
7044/// // As the method needs a request, you would usually fill it with the desired information
7045/// // into the respective structure. Some of the parts shown here might not be applicable !
7046/// // Values shown here are possibly random and not representative !
7047/// let mut req = Person::default();
7048///
7049/// // You can configure optional parameters by calling the respective setters at will, and
7050/// // execute the final call using `doit()`.
7051/// // Values shown here are possibly random and not representative !
7052/// let result = hub.people().create_contact(req)
7053/// .add_sources("Lorem")
7054/// .person_fields(FieldMask::new::<&str>(&[]))
7055/// .doit().await;
7056/// # }
7057/// ```
7058pub struct PersonCreateContactCall<'a, C>
7059where
7060 C: 'a,
7061{
7062 hub: &'a PeopleService<C>,
7063 _request: Person,
7064 _sources: Vec<String>,
7065 _person_fields: Option<common::FieldMask>,
7066 _delegate: Option<&'a mut dyn common::Delegate>,
7067 _additional_params: HashMap<String, String>,
7068 _scopes: BTreeSet<String>,
7069}
7070
7071impl<'a, C> common::CallBuilder for PersonCreateContactCall<'a, C> {}
7072
7073impl<'a, C> PersonCreateContactCall<'a, C>
7074where
7075 C: common::Connector,
7076{
7077 /// Perform the operation you have build so far.
7078 pub async fn doit(mut self) -> common::Result<(common::Response, Person)> {
7079 use std::borrow::Cow;
7080 use std::io::{Read, Seek};
7081
7082 use common::{url::Params, ToParts};
7083 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7084
7085 let mut dd = common::DefaultDelegate;
7086 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7087 dlg.begin(common::MethodInfo {
7088 id: "people.people.createContact",
7089 http_method: hyper::Method::POST,
7090 });
7091
7092 for &field in ["alt", "sources", "personFields"].iter() {
7093 if self._additional_params.contains_key(field) {
7094 dlg.finished(false);
7095 return Err(common::Error::FieldClash(field));
7096 }
7097 }
7098
7099 let mut params = Params::with_capacity(5 + self._additional_params.len());
7100 if !self._sources.is_empty() {
7101 for f in self._sources.iter() {
7102 params.push("sources", f);
7103 }
7104 }
7105 if let Some(value) = self._person_fields.as_ref() {
7106 params.push("personFields", value.to_string());
7107 }
7108
7109 params.extend(self._additional_params.iter());
7110
7111 params.push("alt", "json");
7112 let mut url = self.hub._base_url.clone() + "v1/people:createContact";
7113 if self._scopes.is_empty() {
7114 self._scopes.insert(Scope::Contact.as_ref().to_string());
7115 }
7116
7117 let url = params.parse_with_url(&url);
7118
7119 let mut json_mime_type = mime::APPLICATION_JSON;
7120 let mut request_value_reader = {
7121 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7122 common::remove_json_null_values(&mut value);
7123 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7124 serde_json::to_writer(&mut dst, &value).unwrap();
7125 dst
7126 };
7127 let request_size = request_value_reader
7128 .seek(std::io::SeekFrom::End(0))
7129 .unwrap();
7130 request_value_reader
7131 .seek(std::io::SeekFrom::Start(0))
7132 .unwrap();
7133
7134 loop {
7135 let token = match self
7136 .hub
7137 .auth
7138 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7139 .await
7140 {
7141 Ok(token) => token,
7142 Err(e) => match dlg.token(e) {
7143 Ok(token) => token,
7144 Err(e) => {
7145 dlg.finished(false);
7146 return Err(common::Error::MissingToken(e));
7147 }
7148 },
7149 };
7150 request_value_reader
7151 .seek(std::io::SeekFrom::Start(0))
7152 .unwrap();
7153 let mut req_result = {
7154 let client = &self.hub.client;
7155 dlg.pre_request();
7156 let mut req_builder = hyper::Request::builder()
7157 .method(hyper::Method::POST)
7158 .uri(url.as_str())
7159 .header(USER_AGENT, self.hub._user_agent.clone());
7160
7161 if let Some(token) = token.as_ref() {
7162 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7163 }
7164
7165 let request = req_builder
7166 .header(CONTENT_TYPE, json_mime_type.to_string())
7167 .header(CONTENT_LENGTH, request_size as u64)
7168 .body(common::to_body(
7169 request_value_reader.get_ref().clone().into(),
7170 ));
7171
7172 client.request(request.unwrap()).await
7173 };
7174
7175 match req_result {
7176 Err(err) => {
7177 if let common::Retry::After(d) = dlg.http_error(&err) {
7178 sleep(d).await;
7179 continue;
7180 }
7181 dlg.finished(false);
7182 return Err(common::Error::HttpError(err));
7183 }
7184 Ok(res) => {
7185 let (mut parts, body) = res.into_parts();
7186 let mut body = common::Body::new(body);
7187 if !parts.status.is_success() {
7188 let bytes = common::to_bytes(body).await.unwrap_or_default();
7189 let error = serde_json::from_str(&common::to_string(&bytes));
7190 let response = common::to_response(parts, bytes.into());
7191
7192 if let common::Retry::After(d) =
7193 dlg.http_failure(&response, error.as_ref().ok())
7194 {
7195 sleep(d).await;
7196 continue;
7197 }
7198
7199 dlg.finished(false);
7200
7201 return Err(match error {
7202 Ok(value) => common::Error::BadRequest(value),
7203 _ => common::Error::Failure(response),
7204 });
7205 }
7206 let response = {
7207 let bytes = common::to_bytes(body).await.unwrap_or_default();
7208 let encoded = common::to_string(&bytes);
7209 match serde_json::from_str(&encoded) {
7210 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7211 Err(error) => {
7212 dlg.response_json_decode_error(&encoded, &error);
7213 return Err(common::Error::JsonDecodeError(
7214 encoded.to_string(),
7215 error,
7216 ));
7217 }
7218 }
7219 };
7220
7221 dlg.finished(true);
7222 return Ok(response);
7223 }
7224 }
7225 }
7226 }
7227
7228 ///
7229 /// Sets the *request* property to the given value.
7230 ///
7231 /// Even though the property as already been set when instantiating this call,
7232 /// we provide this method for API completeness.
7233 pub fn request(mut self, new_value: Person) -> PersonCreateContactCall<'a, C> {
7234 self._request = new_value;
7235 self
7236 }
7237 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
7238 ///
7239 /// Append the given value to the *sources* query property.
7240 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7241 pub fn add_sources(mut self, new_value: &str) -> PersonCreateContactCall<'a, C> {
7242 self._sources.push(new_value.to_string());
7243 self
7244 }
7245 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. Defaults to all fields if not set. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
7246 ///
7247 /// Sets the *person fields* query property to the given value.
7248 pub fn person_fields(mut self, new_value: common::FieldMask) -> PersonCreateContactCall<'a, C> {
7249 self._person_fields = Some(new_value);
7250 self
7251 }
7252 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7253 /// while executing the actual API request.
7254 ///
7255 /// ````text
7256 /// It should be used to handle progress information, and to implement a certain level of resilience.
7257 /// ````
7258 ///
7259 /// Sets the *delegate* property to the given value.
7260 pub fn delegate(
7261 mut self,
7262 new_value: &'a mut dyn common::Delegate,
7263 ) -> PersonCreateContactCall<'a, C> {
7264 self._delegate = Some(new_value);
7265 self
7266 }
7267
7268 /// Set any additional parameter of the query string used in the request.
7269 /// It should be used to set parameters which are not yet available through their own
7270 /// setters.
7271 ///
7272 /// Please note that this method must not be used to set any of the known parameters
7273 /// which have their own setter method. If done anyway, the request will fail.
7274 ///
7275 /// # Additional Parameters
7276 ///
7277 /// * *$.xgafv* (query-string) - V1 error format.
7278 /// * *access_token* (query-string) - OAuth access token.
7279 /// * *alt* (query-string) - Data format for response.
7280 /// * *callback* (query-string) - JSONP
7281 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7282 /// * *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.
7283 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7284 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7285 /// * *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.
7286 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7287 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7288 pub fn param<T>(mut self, name: T, value: T) -> PersonCreateContactCall<'a, C>
7289 where
7290 T: AsRef<str>,
7291 {
7292 self._additional_params
7293 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7294 self
7295 }
7296
7297 /// Identifies the authorization scope for the method you are building.
7298 ///
7299 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7300 /// [`Scope::Contact`].
7301 ///
7302 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7303 /// tokens for more than one scope.
7304 ///
7305 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7306 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7307 /// sufficient, a read-write scope will do as well.
7308 pub fn add_scope<St>(mut self, scope: St) -> PersonCreateContactCall<'a, C>
7309 where
7310 St: AsRef<str>,
7311 {
7312 self._scopes.insert(String::from(scope.as_ref()));
7313 self
7314 }
7315 /// Identifies the authorization scope(s) for the method you are building.
7316 ///
7317 /// See [`Self::add_scope()`] for details.
7318 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonCreateContactCall<'a, C>
7319 where
7320 I: IntoIterator<Item = St>,
7321 St: AsRef<str>,
7322 {
7323 self._scopes
7324 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7325 self
7326 }
7327
7328 /// Removes all scopes, and no default scope will be used either.
7329 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7330 /// for details).
7331 pub fn clear_scopes(mut self) -> PersonCreateContactCall<'a, C> {
7332 self._scopes.clear();
7333 self
7334 }
7335}
7336
7337/// Delete a contact person. Any non-contact data will not be deleted. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
7338///
7339/// A builder for the *deleteContact* method supported by a *person* resource.
7340/// It is not used directly, but through a [`PersonMethods`] instance.
7341///
7342/// # Example
7343///
7344/// Instantiate a resource method builder
7345///
7346/// ```test_harness,no_run
7347/// # extern crate hyper;
7348/// # extern crate hyper_rustls;
7349/// # extern crate google_people1 as people1;
7350/// # async fn dox() {
7351/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7352///
7353/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7354/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7355/// # secret,
7356/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7357/// # ).build().await.unwrap();
7358///
7359/// # let client = hyper_util::client::legacy::Client::builder(
7360/// # hyper_util::rt::TokioExecutor::new()
7361/// # )
7362/// # .build(
7363/// # hyper_rustls::HttpsConnectorBuilder::new()
7364/// # .with_native_roots()
7365/// # .unwrap()
7366/// # .https_or_http()
7367/// # .enable_http1()
7368/// # .build()
7369/// # );
7370/// # let mut hub = PeopleService::new(client, auth);
7371/// // You can configure optional parameters by calling the respective setters at will, and
7372/// // execute the final call using `doit()`.
7373/// // Values shown here are possibly random and not representative !
7374/// let result = hub.people().delete_contact("resourceName")
7375/// .doit().await;
7376/// # }
7377/// ```
7378pub struct PersonDeleteContactCall<'a, C>
7379where
7380 C: 'a,
7381{
7382 hub: &'a PeopleService<C>,
7383 _resource_name: String,
7384 _delegate: Option<&'a mut dyn common::Delegate>,
7385 _additional_params: HashMap<String, String>,
7386 _scopes: BTreeSet<String>,
7387}
7388
7389impl<'a, C> common::CallBuilder for PersonDeleteContactCall<'a, C> {}
7390
7391impl<'a, C> PersonDeleteContactCall<'a, C>
7392where
7393 C: common::Connector,
7394{
7395 /// Perform the operation you have build so far.
7396 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7397 use std::borrow::Cow;
7398 use std::io::{Read, Seek};
7399
7400 use common::{url::Params, ToParts};
7401 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7402
7403 let mut dd = common::DefaultDelegate;
7404 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7405 dlg.begin(common::MethodInfo {
7406 id: "people.people.deleteContact",
7407 http_method: hyper::Method::DELETE,
7408 });
7409
7410 for &field in ["alt", "resourceName"].iter() {
7411 if self._additional_params.contains_key(field) {
7412 dlg.finished(false);
7413 return Err(common::Error::FieldClash(field));
7414 }
7415 }
7416
7417 let mut params = Params::with_capacity(3 + self._additional_params.len());
7418 params.push("resourceName", self._resource_name);
7419
7420 params.extend(self._additional_params.iter());
7421
7422 params.push("alt", "json");
7423 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}:deleteContact";
7424 if self._scopes.is_empty() {
7425 self._scopes.insert(Scope::Contact.as_ref().to_string());
7426 }
7427
7428 #[allow(clippy::single_element_loop)]
7429 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
7430 url = params.uri_replacement(url, param_name, find_this, true);
7431 }
7432 {
7433 let to_remove = ["resourceName"];
7434 params.remove_params(&to_remove);
7435 }
7436
7437 let url = params.parse_with_url(&url);
7438
7439 loop {
7440 let token = match self
7441 .hub
7442 .auth
7443 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7444 .await
7445 {
7446 Ok(token) => token,
7447 Err(e) => match dlg.token(e) {
7448 Ok(token) => token,
7449 Err(e) => {
7450 dlg.finished(false);
7451 return Err(common::Error::MissingToken(e));
7452 }
7453 },
7454 };
7455 let mut req_result = {
7456 let client = &self.hub.client;
7457 dlg.pre_request();
7458 let mut req_builder = hyper::Request::builder()
7459 .method(hyper::Method::DELETE)
7460 .uri(url.as_str())
7461 .header(USER_AGENT, self.hub._user_agent.clone());
7462
7463 if let Some(token) = token.as_ref() {
7464 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7465 }
7466
7467 let request = req_builder
7468 .header(CONTENT_LENGTH, 0_u64)
7469 .body(common::to_body::<String>(None));
7470
7471 client.request(request.unwrap()).await
7472 };
7473
7474 match req_result {
7475 Err(err) => {
7476 if let common::Retry::After(d) = dlg.http_error(&err) {
7477 sleep(d).await;
7478 continue;
7479 }
7480 dlg.finished(false);
7481 return Err(common::Error::HttpError(err));
7482 }
7483 Ok(res) => {
7484 let (mut parts, body) = res.into_parts();
7485 let mut body = common::Body::new(body);
7486 if !parts.status.is_success() {
7487 let bytes = common::to_bytes(body).await.unwrap_or_default();
7488 let error = serde_json::from_str(&common::to_string(&bytes));
7489 let response = common::to_response(parts, bytes.into());
7490
7491 if let common::Retry::After(d) =
7492 dlg.http_failure(&response, error.as_ref().ok())
7493 {
7494 sleep(d).await;
7495 continue;
7496 }
7497
7498 dlg.finished(false);
7499
7500 return Err(match error {
7501 Ok(value) => common::Error::BadRequest(value),
7502 _ => common::Error::Failure(response),
7503 });
7504 }
7505 let response = {
7506 let bytes = common::to_bytes(body).await.unwrap_or_default();
7507 let encoded = common::to_string(&bytes);
7508 match serde_json::from_str(&encoded) {
7509 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7510 Err(error) => {
7511 dlg.response_json_decode_error(&encoded, &error);
7512 return Err(common::Error::JsonDecodeError(
7513 encoded.to_string(),
7514 error,
7515 ));
7516 }
7517 }
7518 };
7519
7520 dlg.finished(true);
7521 return Ok(response);
7522 }
7523 }
7524 }
7525 }
7526
7527 /// Required. The resource name of the contact to delete.
7528 ///
7529 /// Sets the *resource name* path property to the given value.
7530 ///
7531 /// Even though the property as already been set when instantiating this call,
7532 /// we provide this method for API completeness.
7533 pub fn resource_name(mut self, new_value: &str) -> PersonDeleteContactCall<'a, C> {
7534 self._resource_name = new_value.to_string();
7535 self
7536 }
7537 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7538 /// while executing the actual API request.
7539 ///
7540 /// ````text
7541 /// It should be used to handle progress information, and to implement a certain level of resilience.
7542 /// ````
7543 ///
7544 /// Sets the *delegate* property to the given value.
7545 pub fn delegate(
7546 mut self,
7547 new_value: &'a mut dyn common::Delegate,
7548 ) -> PersonDeleteContactCall<'a, C> {
7549 self._delegate = Some(new_value);
7550 self
7551 }
7552
7553 /// Set any additional parameter of the query string used in the request.
7554 /// It should be used to set parameters which are not yet available through their own
7555 /// setters.
7556 ///
7557 /// Please note that this method must not be used to set any of the known parameters
7558 /// which have their own setter method. If done anyway, the request will fail.
7559 ///
7560 /// # Additional Parameters
7561 ///
7562 /// * *$.xgafv* (query-string) - V1 error format.
7563 /// * *access_token* (query-string) - OAuth access token.
7564 /// * *alt* (query-string) - Data format for response.
7565 /// * *callback* (query-string) - JSONP
7566 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7567 /// * *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.
7568 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7569 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7570 /// * *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.
7571 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7572 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7573 pub fn param<T>(mut self, name: T, value: T) -> PersonDeleteContactCall<'a, C>
7574 where
7575 T: AsRef<str>,
7576 {
7577 self._additional_params
7578 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7579 self
7580 }
7581
7582 /// Identifies the authorization scope for the method you are building.
7583 ///
7584 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7585 /// [`Scope::Contact`].
7586 ///
7587 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7588 /// tokens for more than one scope.
7589 ///
7590 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7591 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7592 /// sufficient, a read-write scope will do as well.
7593 pub fn add_scope<St>(mut self, scope: St) -> PersonDeleteContactCall<'a, C>
7594 where
7595 St: AsRef<str>,
7596 {
7597 self._scopes.insert(String::from(scope.as_ref()));
7598 self
7599 }
7600 /// Identifies the authorization scope(s) for the method you are building.
7601 ///
7602 /// See [`Self::add_scope()`] for details.
7603 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonDeleteContactCall<'a, C>
7604 where
7605 I: IntoIterator<Item = St>,
7606 St: AsRef<str>,
7607 {
7608 self._scopes
7609 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7610 self
7611 }
7612
7613 /// Removes all scopes, and no default scope will be used either.
7614 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7615 /// for details).
7616 pub fn clear_scopes(mut self) -> PersonDeleteContactCall<'a, C> {
7617 self._scopes.clear();
7618 self
7619 }
7620}
7621
7622/// Delete a contact's photo. Mutate requests for the same user should be done sequentially to avoid // lock contention.
7623///
7624/// A builder for the *deleteContactPhoto* method supported by a *person* resource.
7625/// It is not used directly, but through a [`PersonMethods`] instance.
7626///
7627/// # Example
7628///
7629/// Instantiate a resource method builder
7630///
7631/// ```test_harness,no_run
7632/// # extern crate hyper;
7633/// # extern crate hyper_rustls;
7634/// # extern crate google_people1 as people1;
7635/// # async fn dox() {
7636/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7637///
7638/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7639/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7640/// # secret,
7641/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7642/// # ).build().await.unwrap();
7643///
7644/// # let client = hyper_util::client::legacy::Client::builder(
7645/// # hyper_util::rt::TokioExecutor::new()
7646/// # )
7647/// # .build(
7648/// # hyper_rustls::HttpsConnectorBuilder::new()
7649/// # .with_native_roots()
7650/// # .unwrap()
7651/// # .https_or_http()
7652/// # .enable_http1()
7653/// # .build()
7654/// # );
7655/// # let mut hub = PeopleService::new(client, auth);
7656/// // You can configure optional parameters by calling the respective setters at will, and
7657/// // execute the final call using `doit()`.
7658/// // Values shown here are possibly random and not representative !
7659/// let result = hub.people().delete_contact_photo("resourceName")
7660/// .add_sources("sed")
7661/// .person_fields(FieldMask::new::<&str>(&[]))
7662/// .doit().await;
7663/// # }
7664/// ```
7665pub struct PersonDeleteContactPhotoCall<'a, C>
7666where
7667 C: 'a,
7668{
7669 hub: &'a PeopleService<C>,
7670 _resource_name: String,
7671 _sources: Vec<String>,
7672 _person_fields: Option<common::FieldMask>,
7673 _delegate: Option<&'a mut dyn common::Delegate>,
7674 _additional_params: HashMap<String, String>,
7675 _scopes: BTreeSet<String>,
7676}
7677
7678impl<'a, C> common::CallBuilder for PersonDeleteContactPhotoCall<'a, C> {}
7679
7680impl<'a, C> PersonDeleteContactPhotoCall<'a, C>
7681where
7682 C: common::Connector,
7683{
7684 /// Perform the operation you have build so far.
7685 pub async fn doit(mut self) -> common::Result<(common::Response, DeleteContactPhotoResponse)> {
7686 use std::borrow::Cow;
7687 use std::io::{Read, Seek};
7688
7689 use common::{url::Params, ToParts};
7690 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7691
7692 let mut dd = common::DefaultDelegate;
7693 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7694 dlg.begin(common::MethodInfo {
7695 id: "people.people.deleteContactPhoto",
7696 http_method: hyper::Method::DELETE,
7697 });
7698
7699 for &field in ["alt", "resourceName", "sources", "personFields"].iter() {
7700 if self._additional_params.contains_key(field) {
7701 dlg.finished(false);
7702 return Err(common::Error::FieldClash(field));
7703 }
7704 }
7705
7706 let mut params = Params::with_capacity(5 + self._additional_params.len());
7707 params.push("resourceName", self._resource_name);
7708 if !self._sources.is_empty() {
7709 for f in self._sources.iter() {
7710 params.push("sources", f);
7711 }
7712 }
7713 if let Some(value) = self._person_fields.as_ref() {
7714 params.push("personFields", value.to_string());
7715 }
7716
7717 params.extend(self._additional_params.iter());
7718
7719 params.push("alt", "json");
7720 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}:deleteContactPhoto";
7721 if self._scopes.is_empty() {
7722 self._scopes.insert(Scope::Contact.as_ref().to_string());
7723 }
7724
7725 #[allow(clippy::single_element_loop)]
7726 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
7727 url = params.uri_replacement(url, param_name, find_this, true);
7728 }
7729 {
7730 let to_remove = ["resourceName"];
7731 params.remove_params(&to_remove);
7732 }
7733
7734 let url = params.parse_with_url(&url);
7735
7736 loop {
7737 let token = match self
7738 .hub
7739 .auth
7740 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7741 .await
7742 {
7743 Ok(token) => token,
7744 Err(e) => match dlg.token(e) {
7745 Ok(token) => token,
7746 Err(e) => {
7747 dlg.finished(false);
7748 return Err(common::Error::MissingToken(e));
7749 }
7750 },
7751 };
7752 let mut req_result = {
7753 let client = &self.hub.client;
7754 dlg.pre_request();
7755 let mut req_builder = hyper::Request::builder()
7756 .method(hyper::Method::DELETE)
7757 .uri(url.as_str())
7758 .header(USER_AGENT, self.hub._user_agent.clone());
7759
7760 if let Some(token) = token.as_ref() {
7761 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7762 }
7763
7764 let request = req_builder
7765 .header(CONTENT_LENGTH, 0_u64)
7766 .body(common::to_body::<String>(None));
7767
7768 client.request(request.unwrap()).await
7769 };
7770
7771 match req_result {
7772 Err(err) => {
7773 if let common::Retry::After(d) = dlg.http_error(&err) {
7774 sleep(d).await;
7775 continue;
7776 }
7777 dlg.finished(false);
7778 return Err(common::Error::HttpError(err));
7779 }
7780 Ok(res) => {
7781 let (mut parts, body) = res.into_parts();
7782 let mut body = common::Body::new(body);
7783 if !parts.status.is_success() {
7784 let bytes = common::to_bytes(body).await.unwrap_or_default();
7785 let error = serde_json::from_str(&common::to_string(&bytes));
7786 let response = common::to_response(parts, bytes.into());
7787
7788 if let common::Retry::After(d) =
7789 dlg.http_failure(&response, error.as_ref().ok())
7790 {
7791 sleep(d).await;
7792 continue;
7793 }
7794
7795 dlg.finished(false);
7796
7797 return Err(match error {
7798 Ok(value) => common::Error::BadRequest(value),
7799 _ => common::Error::Failure(response),
7800 });
7801 }
7802 let response = {
7803 let bytes = common::to_bytes(body).await.unwrap_or_default();
7804 let encoded = common::to_string(&bytes);
7805 match serde_json::from_str(&encoded) {
7806 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7807 Err(error) => {
7808 dlg.response_json_decode_error(&encoded, &error);
7809 return Err(common::Error::JsonDecodeError(
7810 encoded.to_string(),
7811 error,
7812 ));
7813 }
7814 }
7815 };
7816
7817 dlg.finished(true);
7818 return Ok(response);
7819 }
7820 }
7821 }
7822 }
7823
7824 /// Required. The resource name of the contact whose photo will be deleted.
7825 ///
7826 /// Sets the *resource name* path property to the given value.
7827 ///
7828 /// Even though the property as already been set when instantiating this call,
7829 /// we provide this method for API completeness.
7830 pub fn resource_name(mut self, new_value: &str) -> PersonDeleteContactPhotoCall<'a, C> {
7831 self._resource_name = new_value.to_string();
7832 self
7833 }
7834 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
7835 ///
7836 /// Append the given value to the *sources* query property.
7837 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7838 pub fn add_sources(mut self, new_value: &str) -> PersonDeleteContactPhotoCall<'a, C> {
7839 self._sources.push(new_value.to_string());
7840 self
7841 }
7842 /// Optional. A field mask to restrict which fields on the person are returned. Multiple fields can be specified by separating them with commas. Defaults to empty if not set, which will skip the post mutate get. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
7843 ///
7844 /// Sets the *person fields* query property to the given value.
7845 pub fn person_fields(
7846 mut self,
7847 new_value: common::FieldMask,
7848 ) -> PersonDeleteContactPhotoCall<'a, C> {
7849 self._person_fields = Some(new_value);
7850 self
7851 }
7852 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7853 /// while executing the actual API request.
7854 ///
7855 /// ````text
7856 /// It should be used to handle progress information, and to implement a certain level of resilience.
7857 /// ````
7858 ///
7859 /// Sets the *delegate* property to the given value.
7860 pub fn delegate(
7861 mut self,
7862 new_value: &'a mut dyn common::Delegate,
7863 ) -> PersonDeleteContactPhotoCall<'a, C> {
7864 self._delegate = Some(new_value);
7865 self
7866 }
7867
7868 /// Set any additional parameter of the query string used in the request.
7869 /// It should be used to set parameters which are not yet available through their own
7870 /// setters.
7871 ///
7872 /// Please note that this method must not be used to set any of the known parameters
7873 /// which have their own setter method. If done anyway, the request will fail.
7874 ///
7875 /// # Additional Parameters
7876 ///
7877 /// * *$.xgafv* (query-string) - V1 error format.
7878 /// * *access_token* (query-string) - OAuth access token.
7879 /// * *alt* (query-string) - Data format for response.
7880 /// * *callback* (query-string) - JSONP
7881 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7882 /// * *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.
7883 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7884 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7885 /// * *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.
7886 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7887 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7888 pub fn param<T>(mut self, name: T, value: T) -> PersonDeleteContactPhotoCall<'a, C>
7889 where
7890 T: AsRef<str>,
7891 {
7892 self._additional_params
7893 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7894 self
7895 }
7896
7897 /// Identifies the authorization scope for the method you are building.
7898 ///
7899 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7900 /// [`Scope::Contact`].
7901 ///
7902 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7903 /// tokens for more than one scope.
7904 ///
7905 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7906 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7907 /// sufficient, a read-write scope will do as well.
7908 pub fn add_scope<St>(mut self, scope: St) -> PersonDeleteContactPhotoCall<'a, C>
7909 where
7910 St: AsRef<str>,
7911 {
7912 self._scopes.insert(String::from(scope.as_ref()));
7913 self
7914 }
7915 /// Identifies the authorization scope(s) for the method you are building.
7916 ///
7917 /// See [`Self::add_scope()`] for details.
7918 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonDeleteContactPhotoCall<'a, C>
7919 where
7920 I: IntoIterator<Item = St>,
7921 St: AsRef<str>,
7922 {
7923 self._scopes
7924 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7925 self
7926 }
7927
7928 /// Removes all scopes, and no default scope will be used either.
7929 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7930 /// for details).
7931 pub fn clear_scopes(mut self) -> PersonDeleteContactPhotoCall<'a, C> {
7932 self._scopes.clear();
7933 self
7934 }
7935}
7936
7937/// Provides information about a person by specifying a resource name. Use `people/me` to indicate the authenticated user. The request returns a 400 error if 'personFields' is not specified.
7938///
7939/// A builder for the *get* method supported by a *person* resource.
7940/// It is not used directly, but through a [`PersonMethods`] instance.
7941///
7942/// # Example
7943///
7944/// Instantiate a resource method builder
7945///
7946/// ```test_harness,no_run
7947/// # extern crate hyper;
7948/// # extern crate hyper_rustls;
7949/// # extern crate google_people1 as people1;
7950/// # async fn dox() {
7951/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7952///
7953/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7954/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7955/// # secret,
7956/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7957/// # ).build().await.unwrap();
7958///
7959/// # let client = hyper_util::client::legacy::Client::builder(
7960/// # hyper_util::rt::TokioExecutor::new()
7961/// # )
7962/// # .build(
7963/// # hyper_rustls::HttpsConnectorBuilder::new()
7964/// # .with_native_roots()
7965/// # .unwrap()
7966/// # .https_or_http()
7967/// # .enable_http1()
7968/// # .build()
7969/// # );
7970/// # let mut hub = PeopleService::new(client, auth);
7971/// // You can configure optional parameters by calling the respective setters at will, and
7972/// // execute the final call using `doit()`.
7973/// // Values shown here are possibly random and not representative !
7974/// let result = hub.people().get("resourceName")
7975/// .add_sources("sed")
7976/// .request_mask_include_field(FieldMask::new::<&str>(&[]))
7977/// .person_fields(FieldMask::new::<&str>(&[]))
7978/// .doit().await;
7979/// # }
7980/// ```
7981pub struct PersonGetCall<'a, C>
7982where
7983 C: 'a,
7984{
7985 hub: &'a PeopleService<C>,
7986 _resource_name: String,
7987 _sources: Vec<String>,
7988 _request_mask_include_field: Option<common::FieldMask>,
7989 _person_fields: Option<common::FieldMask>,
7990 _delegate: Option<&'a mut dyn common::Delegate>,
7991 _additional_params: HashMap<String, String>,
7992 _scopes: BTreeSet<String>,
7993}
7994
7995impl<'a, C> common::CallBuilder for PersonGetCall<'a, C> {}
7996
7997impl<'a, C> PersonGetCall<'a, C>
7998where
7999 C: common::Connector,
8000{
8001 /// Perform the operation you have build so far.
8002 pub async fn doit(mut self) -> common::Result<(common::Response, Person)> {
8003 use std::borrow::Cow;
8004 use std::io::{Read, Seek};
8005
8006 use common::{url::Params, ToParts};
8007 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8008
8009 let mut dd = common::DefaultDelegate;
8010 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8011 dlg.begin(common::MethodInfo {
8012 id: "people.people.get",
8013 http_method: hyper::Method::GET,
8014 });
8015
8016 for &field in [
8017 "alt",
8018 "resourceName",
8019 "sources",
8020 "requestMask.includeField",
8021 "personFields",
8022 ]
8023 .iter()
8024 {
8025 if self._additional_params.contains_key(field) {
8026 dlg.finished(false);
8027 return Err(common::Error::FieldClash(field));
8028 }
8029 }
8030
8031 let mut params = Params::with_capacity(6 + self._additional_params.len());
8032 params.push("resourceName", self._resource_name);
8033 if !self._sources.is_empty() {
8034 for f in self._sources.iter() {
8035 params.push("sources", f);
8036 }
8037 }
8038 if let Some(value) = self._request_mask_include_field.as_ref() {
8039 params.push("requestMask.includeField", value.to_string());
8040 }
8041 if let Some(value) = self._person_fields.as_ref() {
8042 params.push("personFields", value.to_string());
8043 }
8044
8045 params.extend(self._additional_params.iter());
8046
8047 params.push("alt", "json");
8048 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}";
8049 if self._scopes.is_empty() {
8050 self._scopes
8051 .insert(Scope::ContactOtherReadonly.as_ref().to_string());
8052 }
8053
8054 #[allow(clippy::single_element_loop)]
8055 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
8056 url = params.uri_replacement(url, param_name, find_this, true);
8057 }
8058 {
8059 let to_remove = ["resourceName"];
8060 params.remove_params(&to_remove);
8061 }
8062
8063 let url = params.parse_with_url(&url);
8064
8065 loop {
8066 let token = match self
8067 .hub
8068 .auth
8069 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8070 .await
8071 {
8072 Ok(token) => token,
8073 Err(e) => match dlg.token(e) {
8074 Ok(token) => token,
8075 Err(e) => {
8076 dlg.finished(false);
8077 return Err(common::Error::MissingToken(e));
8078 }
8079 },
8080 };
8081 let mut req_result = {
8082 let client = &self.hub.client;
8083 dlg.pre_request();
8084 let mut req_builder = hyper::Request::builder()
8085 .method(hyper::Method::GET)
8086 .uri(url.as_str())
8087 .header(USER_AGENT, self.hub._user_agent.clone());
8088
8089 if let Some(token) = token.as_ref() {
8090 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8091 }
8092
8093 let request = req_builder
8094 .header(CONTENT_LENGTH, 0_u64)
8095 .body(common::to_body::<String>(None));
8096
8097 client.request(request.unwrap()).await
8098 };
8099
8100 match req_result {
8101 Err(err) => {
8102 if let common::Retry::After(d) = dlg.http_error(&err) {
8103 sleep(d).await;
8104 continue;
8105 }
8106 dlg.finished(false);
8107 return Err(common::Error::HttpError(err));
8108 }
8109 Ok(res) => {
8110 let (mut parts, body) = res.into_parts();
8111 let mut body = common::Body::new(body);
8112 if !parts.status.is_success() {
8113 let bytes = common::to_bytes(body).await.unwrap_or_default();
8114 let error = serde_json::from_str(&common::to_string(&bytes));
8115 let response = common::to_response(parts, bytes.into());
8116
8117 if let common::Retry::After(d) =
8118 dlg.http_failure(&response, error.as_ref().ok())
8119 {
8120 sleep(d).await;
8121 continue;
8122 }
8123
8124 dlg.finished(false);
8125
8126 return Err(match error {
8127 Ok(value) => common::Error::BadRequest(value),
8128 _ => common::Error::Failure(response),
8129 });
8130 }
8131 let response = {
8132 let bytes = common::to_bytes(body).await.unwrap_or_default();
8133 let encoded = common::to_string(&bytes);
8134 match serde_json::from_str(&encoded) {
8135 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8136 Err(error) => {
8137 dlg.response_json_decode_error(&encoded, &error);
8138 return Err(common::Error::JsonDecodeError(
8139 encoded.to_string(),
8140 error,
8141 ));
8142 }
8143 }
8144 };
8145
8146 dlg.finished(true);
8147 return Ok(response);
8148 }
8149 }
8150 }
8151 }
8152
8153 /// Required. The resource name of the person to provide information about. - To get information about the authenticated user, specify `people/me`. - To get information about a google account, specify `people/{account_id}`. - To get information about a contact, specify the resource name that identifies the contact as returned by `people.connections.list`.
8154 ///
8155 /// Sets the *resource name* path property to the given value.
8156 ///
8157 /// Even though the property as already been set when instantiating this call,
8158 /// we provide this method for API completeness.
8159 pub fn resource_name(mut self, new_value: &str) -> PersonGetCall<'a, C> {
8160 self._resource_name = new_value.to_string();
8161 self
8162 }
8163 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_PROFILE and READ_SOURCE_TYPE_CONTACT if not set.
8164 ///
8165 /// Append the given value to the *sources* query property.
8166 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8167 pub fn add_sources(mut self, new_value: &str) -> PersonGetCall<'a, C> {
8168 self._sources.push(new_value.to_string());
8169 self
8170 }
8171 /// Required. Comma-separated list of person fields to be included in the response. Each path should start with `person.`: for example, `person.names` or `person.photos`.
8172 ///
8173 /// Sets the *request mask.include field* query property to the given value.
8174 pub fn request_mask_include_field(
8175 mut self,
8176 new_value: common::FieldMask,
8177 ) -> PersonGetCall<'a, C> {
8178 self._request_mask_include_field = Some(new_value);
8179 self
8180 }
8181 /// Required. A field mask to restrict which fields on the person are returned. Multiple fields can be specified by separating them with commas. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
8182 ///
8183 /// Sets the *person fields* query property to the given value.
8184 pub fn person_fields(mut self, new_value: common::FieldMask) -> PersonGetCall<'a, C> {
8185 self._person_fields = Some(new_value);
8186 self
8187 }
8188 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8189 /// while executing the actual API request.
8190 ///
8191 /// ````text
8192 /// It should be used to handle progress information, and to implement a certain level of resilience.
8193 /// ````
8194 ///
8195 /// Sets the *delegate* property to the given value.
8196 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PersonGetCall<'a, C> {
8197 self._delegate = Some(new_value);
8198 self
8199 }
8200
8201 /// Set any additional parameter of the query string used in the request.
8202 /// It should be used to set parameters which are not yet available through their own
8203 /// setters.
8204 ///
8205 /// Please note that this method must not be used to set any of the known parameters
8206 /// which have their own setter method. If done anyway, the request will fail.
8207 ///
8208 /// # Additional Parameters
8209 ///
8210 /// * *$.xgafv* (query-string) - V1 error format.
8211 /// * *access_token* (query-string) - OAuth access token.
8212 /// * *alt* (query-string) - Data format for response.
8213 /// * *callback* (query-string) - JSONP
8214 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8215 /// * *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.
8216 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8217 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8218 /// * *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.
8219 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8220 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8221 pub fn param<T>(mut self, name: T, value: T) -> PersonGetCall<'a, C>
8222 where
8223 T: AsRef<str>,
8224 {
8225 self._additional_params
8226 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8227 self
8228 }
8229
8230 /// Identifies the authorization scope for the method you are building.
8231 ///
8232 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8233 /// [`Scope::ContactOtherReadonly`].
8234 ///
8235 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8236 /// tokens for more than one scope.
8237 ///
8238 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8239 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8240 /// sufficient, a read-write scope will do as well.
8241 pub fn add_scope<St>(mut self, scope: St) -> PersonGetCall<'a, C>
8242 where
8243 St: AsRef<str>,
8244 {
8245 self._scopes.insert(String::from(scope.as_ref()));
8246 self
8247 }
8248 /// Identifies the authorization scope(s) for the method you are building.
8249 ///
8250 /// See [`Self::add_scope()`] for details.
8251 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonGetCall<'a, C>
8252 where
8253 I: IntoIterator<Item = St>,
8254 St: AsRef<str>,
8255 {
8256 self._scopes
8257 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8258 self
8259 }
8260
8261 /// Removes all scopes, and no default scope will be used either.
8262 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8263 /// for details).
8264 pub fn clear_scopes(mut self) -> PersonGetCall<'a, C> {
8265 self._scopes.clear();
8266 self
8267 }
8268}
8269
8270/// Provides information about a list of specific people by specifying a list of requested resource names. Use `people/me` to indicate the authenticated user. The request returns a 400 error if 'personFields' is not specified.
8271///
8272/// A builder for the *getBatchGet* method supported by a *person* resource.
8273/// It is not used directly, but through a [`PersonMethods`] instance.
8274///
8275/// # Example
8276///
8277/// Instantiate a resource method builder
8278///
8279/// ```test_harness,no_run
8280/// # extern crate hyper;
8281/// # extern crate hyper_rustls;
8282/// # extern crate google_people1 as people1;
8283/// # async fn dox() {
8284/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8285///
8286/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8287/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8288/// # secret,
8289/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8290/// # ).build().await.unwrap();
8291///
8292/// # let client = hyper_util::client::legacy::Client::builder(
8293/// # hyper_util::rt::TokioExecutor::new()
8294/// # )
8295/// # .build(
8296/// # hyper_rustls::HttpsConnectorBuilder::new()
8297/// # .with_native_roots()
8298/// # .unwrap()
8299/// # .https_or_http()
8300/// # .enable_http1()
8301/// # .build()
8302/// # );
8303/// # let mut hub = PeopleService::new(client, auth);
8304/// // You can configure optional parameters by calling the respective setters at will, and
8305/// // execute the final call using `doit()`.
8306/// // Values shown here are possibly random and not representative !
8307/// let result = hub.people().get_batch_get()
8308/// .add_sources("no")
8309/// .add_resource_names("Stet")
8310/// .request_mask_include_field(FieldMask::new::<&str>(&[]))
8311/// .person_fields(FieldMask::new::<&str>(&[]))
8312/// .doit().await;
8313/// # }
8314/// ```
8315pub struct PersonGetBatchGetCall<'a, C>
8316where
8317 C: 'a,
8318{
8319 hub: &'a PeopleService<C>,
8320 _sources: Vec<String>,
8321 _resource_names: Vec<String>,
8322 _request_mask_include_field: Option<common::FieldMask>,
8323 _person_fields: Option<common::FieldMask>,
8324 _delegate: Option<&'a mut dyn common::Delegate>,
8325 _additional_params: HashMap<String, String>,
8326 _scopes: BTreeSet<String>,
8327}
8328
8329impl<'a, C> common::CallBuilder for PersonGetBatchGetCall<'a, C> {}
8330
8331impl<'a, C> PersonGetBatchGetCall<'a, C>
8332where
8333 C: common::Connector,
8334{
8335 /// Perform the operation you have build so far.
8336 pub async fn doit(mut self) -> common::Result<(common::Response, GetPeopleResponse)> {
8337 use std::borrow::Cow;
8338 use std::io::{Read, Seek};
8339
8340 use common::{url::Params, ToParts};
8341 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8342
8343 let mut dd = common::DefaultDelegate;
8344 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8345 dlg.begin(common::MethodInfo {
8346 id: "people.people.getBatchGet",
8347 http_method: hyper::Method::GET,
8348 });
8349
8350 for &field in [
8351 "alt",
8352 "sources",
8353 "resourceNames",
8354 "requestMask.includeField",
8355 "personFields",
8356 ]
8357 .iter()
8358 {
8359 if self._additional_params.contains_key(field) {
8360 dlg.finished(false);
8361 return Err(common::Error::FieldClash(field));
8362 }
8363 }
8364
8365 let mut params = Params::with_capacity(6 + self._additional_params.len());
8366 if !self._sources.is_empty() {
8367 for f in self._sources.iter() {
8368 params.push("sources", f);
8369 }
8370 }
8371 if !self._resource_names.is_empty() {
8372 for f in self._resource_names.iter() {
8373 params.push("resourceNames", f);
8374 }
8375 }
8376 if let Some(value) = self._request_mask_include_field.as_ref() {
8377 params.push("requestMask.includeField", value.to_string());
8378 }
8379 if let Some(value) = self._person_fields.as_ref() {
8380 params.push("personFields", value.to_string());
8381 }
8382
8383 params.extend(self._additional_params.iter());
8384
8385 params.push("alt", "json");
8386 let mut url = self.hub._base_url.clone() + "v1/people:batchGet";
8387 if self._scopes.is_empty() {
8388 self._scopes
8389 .insert(Scope::ContactOtherReadonly.as_ref().to_string());
8390 }
8391
8392 let url = params.parse_with_url(&url);
8393
8394 loop {
8395 let token = match self
8396 .hub
8397 .auth
8398 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8399 .await
8400 {
8401 Ok(token) => token,
8402 Err(e) => match dlg.token(e) {
8403 Ok(token) => token,
8404 Err(e) => {
8405 dlg.finished(false);
8406 return Err(common::Error::MissingToken(e));
8407 }
8408 },
8409 };
8410 let mut req_result = {
8411 let client = &self.hub.client;
8412 dlg.pre_request();
8413 let mut req_builder = hyper::Request::builder()
8414 .method(hyper::Method::GET)
8415 .uri(url.as_str())
8416 .header(USER_AGENT, self.hub._user_agent.clone());
8417
8418 if let Some(token) = token.as_ref() {
8419 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8420 }
8421
8422 let request = req_builder
8423 .header(CONTENT_LENGTH, 0_u64)
8424 .body(common::to_body::<String>(None));
8425
8426 client.request(request.unwrap()).await
8427 };
8428
8429 match req_result {
8430 Err(err) => {
8431 if let common::Retry::After(d) = dlg.http_error(&err) {
8432 sleep(d).await;
8433 continue;
8434 }
8435 dlg.finished(false);
8436 return Err(common::Error::HttpError(err));
8437 }
8438 Ok(res) => {
8439 let (mut parts, body) = res.into_parts();
8440 let mut body = common::Body::new(body);
8441 if !parts.status.is_success() {
8442 let bytes = common::to_bytes(body).await.unwrap_or_default();
8443 let error = serde_json::from_str(&common::to_string(&bytes));
8444 let response = common::to_response(parts, bytes.into());
8445
8446 if let common::Retry::After(d) =
8447 dlg.http_failure(&response, error.as_ref().ok())
8448 {
8449 sleep(d).await;
8450 continue;
8451 }
8452
8453 dlg.finished(false);
8454
8455 return Err(match error {
8456 Ok(value) => common::Error::BadRequest(value),
8457 _ => common::Error::Failure(response),
8458 });
8459 }
8460 let response = {
8461 let bytes = common::to_bytes(body).await.unwrap_or_default();
8462 let encoded = common::to_string(&bytes);
8463 match serde_json::from_str(&encoded) {
8464 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8465 Err(error) => {
8466 dlg.response_json_decode_error(&encoded, &error);
8467 return Err(common::Error::JsonDecodeError(
8468 encoded.to_string(),
8469 error,
8470 ));
8471 }
8472 }
8473 };
8474
8475 dlg.finished(true);
8476 return Ok(response);
8477 }
8478 }
8479 }
8480 }
8481
8482 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
8483 ///
8484 /// Append the given value to the *sources* query property.
8485 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8486 pub fn add_sources(mut self, new_value: &str) -> PersonGetBatchGetCall<'a, C> {
8487 self._sources.push(new_value.to_string());
8488 self
8489 }
8490 /// Required. The resource names of the people to provide information about. It's repeatable. The URL query parameter should be resourceNames=<name1>&resourceNames=<name2>&... - To get information about the authenticated user, specify `people/me`. - To get information about a google account, specify `people/{account_id}`. - To get information about a contact, specify the resource name that identifies the contact as returned by `people.connections.list`. There is a maximum of 200 resource names.
8491 ///
8492 /// Append the given value to the *resource names* query property.
8493 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8494 pub fn add_resource_names(mut self, new_value: &str) -> PersonGetBatchGetCall<'a, C> {
8495 self._resource_names.push(new_value.to_string());
8496 self
8497 }
8498 /// Required. Comma-separated list of person fields to be included in the response. Each path should start with `person.`: for example, `person.names` or `person.photos`.
8499 ///
8500 /// Sets the *request mask.include field* query property to the given value.
8501 pub fn request_mask_include_field(
8502 mut self,
8503 new_value: common::FieldMask,
8504 ) -> PersonGetBatchGetCall<'a, C> {
8505 self._request_mask_include_field = Some(new_value);
8506 self
8507 }
8508 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
8509 ///
8510 /// Sets the *person fields* query property to the given value.
8511 pub fn person_fields(mut self, new_value: common::FieldMask) -> PersonGetBatchGetCall<'a, C> {
8512 self._person_fields = Some(new_value);
8513 self
8514 }
8515 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8516 /// while executing the actual API request.
8517 ///
8518 /// ````text
8519 /// It should be used to handle progress information, and to implement a certain level of resilience.
8520 /// ````
8521 ///
8522 /// Sets the *delegate* property to the given value.
8523 pub fn delegate(
8524 mut self,
8525 new_value: &'a mut dyn common::Delegate,
8526 ) -> PersonGetBatchGetCall<'a, C> {
8527 self._delegate = Some(new_value);
8528 self
8529 }
8530
8531 /// Set any additional parameter of the query string used in the request.
8532 /// It should be used to set parameters which are not yet available through their own
8533 /// setters.
8534 ///
8535 /// Please note that this method must not be used to set any of the known parameters
8536 /// which have their own setter method. If done anyway, the request will fail.
8537 ///
8538 /// # Additional Parameters
8539 ///
8540 /// * *$.xgafv* (query-string) - V1 error format.
8541 /// * *access_token* (query-string) - OAuth access token.
8542 /// * *alt* (query-string) - Data format for response.
8543 /// * *callback* (query-string) - JSONP
8544 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8545 /// * *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.
8546 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8547 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8548 /// * *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.
8549 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8550 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8551 pub fn param<T>(mut self, name: T, value: T) -> PersonGetBatchGetCall<'a, C>
8552 where
8553 T: AsRef<str>,
8554 {
8555 self._additional_params
8556 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8557 self
8558 }
8559
8560 /// Identifies the authorization scope for the method you are building.
8561 ///
8562 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8563 /// [`Scope::ContactOtherReadonly`].
8564 ///
8565 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8566 /// tokens for more than one scope.
8567 ///
8568 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8569 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8570 /// sufficient, a read-write scope will do as well.
8571 pub fn add_scope<St>(mut self, scope: St) -> PersonGetBatchGetCall<'a, C>
8572 where
8573 St: AsRef<str>,
8574 {
8575 self._scopes.insert(String::from(scope.as_ref()));
8576 self
8577 }
8578 /// Identifies the authorization scope(s) for the method you are building.
8579 ///
8580 /// See [`Self::add_scope()`] for details.
8581 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonGetBatchGetCall<'a, C>
8582 where
8583 I: IntoIterator<Item = St>,
8584 St: AsRef<str>,
8585 {
8586 self._scopes
8587 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8588 self
8589 }
8590
8591 /// Removes all scopes, and no default scope will be used either.
8592 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8593 /// for details).
8594 pub fn clear_scopes(mut self) -> PersonGetBatchGetCall<'a, C> {
8595 self._scopes.clear();
8596 self
8597 }
8598}
8599
8600/// Provides a list of domain profiles and domain contacts in the authenticated user’s domain directory. When the `sync_token` is specified, resources deleted since the last sync will be returned as a person with `PersonMetadata.deleted` set to true. When the `page_token` or `sync_token` is specified, all other request parameters must match the first call. Writes may have a propagation delay of several minutes for sync requests. Incremental syncs are not intended for read-after-write use cases. See example usage at [List the directory people that have changed](https://developers.google.com/people/v1/directory#list_the_directory_people_that_have_changed).
8601///
8602/// A builder for the *listDirectoryPeople* method supported by a *person* resource.
8603/// It is not used directly, but through a [`PersonMethods`] instance.
8604///
8605/// # Example
8606///
8607/// Instantiate a resource method builder
8608///
8609/// ```test_harness,no_run
8610/// # extern crate hyper;
8611/// # extern crate hyper_rustls;
8612/// # extern crate google_people1 as people1;
8613/// # async fn dox() {
8614/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8615///
8616/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8617/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8618/// # secret,
8619/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8620/// # ).build().await.unwrap();
8621///
8622/// # let client = hyper_util::client::legacy::Client::builder(
8623/// # hyper_util::rt::TokioExecutor::new()
8624/// # )
8625/// # .build(
8626/// # hyper_rustls::HttpsConnectorBuilder::new()
8627/// # .with_native_roots()
8628/// # .unwrap()
8629/// # .https_or_http()
8630/// # .enable_http1()
8631/// # .build()
8632/// # );
8633/// # let mut hub = PeopleService::new(client, auth);
8634/// // You can configure optional parameters by calling the respective setters at will, and
8635/// // execute the final call using `doit()`.
8636/// // Values shown here are possibly random and not representative !
8637/// let result = hub.people().list_directory_people()
8638/// .sync_token("kasd")
8639/// .add_sources("et")
8640/// .request_sync_token(true)
8641/// .read_mask(FieldMask::new::<&str>(&[]))
8642/// .page_token("et")
8643/// .page_size(-68)
8644/// .add_merge_sources("vero")
8645/// .doit().await;
8646/// # }
8647/// ```
8648pub struct PersonListDirectoryPersonCall<'a, C>
8649where
8650 C: 'a,
8651{
8652 hub: &'a PeopleService<C>,
8653 _sync_token: Option<String>,
8654 _sources: Vec<String>,
8655 _request_sync_token: Option<bool>,
8656 _read_mask: Option<common::FieldMask>,
8657 _page_token: Option<String>,
8658 _page_size: Option<i32>,
8659 _merge_sources: Vec<String>,
8660 _delegate: Option<&'a mut dyn common::Delegate>,
8661 _additional_params: HashMap<String, String>,
8662 _scopes: BTreeSet<String>,
8663}
8664
8665impl<'a, C> common::CallBuilder for PersonListDirectoryPersonCall<'a, C> {}
8666
8667impl<'a, C> PersonListDirectoryPersonCall<'a, C>
8668where
8669 C: common::Connector,
8670{
8671 /// Perform the operation you have build so far.
8672 pub async fn doit(mut self) -> common::Result<(common::Response, ListDirectoryPeopleResponse)> {
8673 use std::borrow::Cow;
8674 use std::io::{Read, Seek};
8675
8676 use common::{url::Params, ToParts};
8677 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8678
8679 let mut dd = common::DefaultDelegate;
8680 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8681 dlg.begin(common::MethodInfo {
8682 id: "people.people.listDirectoryPeople",
8683 http_method: hyper::Method::GET,
8684 });
8685
8686 for &field in [
8687 "alt",
8688 "syncToken",
8689 "sources",
8690 "requestSyncToken",
8691 "readMask",
8692 "pageToken",
8693 "pageSize",
8694 "mergeSources",
8695 ]
8696 .iter()
8697 {
8698 if self._additional_params.contains_key(field) {
8699 dlg.finished(false);
8700 return Err(common::Error::FieldClash(field));
8701 }
8702 }
8703
8704 let mut params = Params::with_capacity(9 + self._additional_params.len());
8705 if let Some(value) = self._sync_token.as_ref() {
8706 params.push("syncToken", value);
8707 }
8708 if !self._sources.is_empty() {
8709 for f in self._sources.iter() {
8710 params.push("sources", f);
8711 }
8712 }
8713 if let Some(value) = self._request_sync_token.as_ref() {
8714 params.push("requestSyncToken", value.to_string());
8715 }
8716 if let Some(value) = self._read_mask.as_ref() {
8717 params.push("readMask", value.to_string());
8718 }
8719 if let Some(value) = self._page_token.as_ref() {
8720 params.push("pageToken", value);
8721 }
8722 if let Some(value) = self._page_size.as_ref() {
8723 params.push("pageSize", value.to_string());
8724 }
8725 if !self._merge_sources.is_empty() {
8726 for f in self._merge_sources.iter() {
8727 params.push("mergeSources", f);
8728 }
8729 }
8730
8731 params.extend(self._additional_params.iter());
8732
8733 params.push("alt", "json");
8734 let mut url = self.hub._base_url.clone() + "v1/people:listDirectoryPeople";
8735 if self._scopes.is_empty() {
8736 self._scopes
8737 .insert(Scope::DirectoryReadonly.as_ref().to_string());
8738 }
8739
8740 let url = params.parse_with_url(&url);
8741
8742 loop {
8743 let token = match self
8744 .hub
8745 .auth
8746 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8747 .await
8748 {
8749 Ok(token) => token,
8750 Err(e) => match dlg.token(e) {
8751 Ok(token) => token,
8752 Err(e) => {
8753 dlg.finished(false);
8754 return Err(common::Error::MissingToken(e));
8755 }
8756 },
8757 };
8758 let mut req_result = {
8759 let client = &self.hub.client;
8760 dlg.pre_request();
8761 let mut req_builder = hyper::Request::builder()
8762 .method(hyper::Method::GET)
8763 .uri(url.as_str())
8764 .header(USER_AGENT, self.hub._user_agent.clone());
8765
8766 if let Some(token) = token.as_ref() {
8767 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8768 }
8769
8770 let request = req_builder
8771 .header(CONTENT_LENGTH, 0_u64)
8772 .body(common::to_body::<String>(None));
8773
8774 client.request(request.unwrap()).await
8775 };
8776
8777 match req_result {
8778 Err(err) => {
8779 if let common::Retry::After(d) = dlg.http_error(&err) {
8780 sleep(d).await;
8781 continue;
8782 }
8783 dlg.finished(false);
8784 return Err(common::Error::HttpError(err));
8785 }
8786 Ok(res) => {
8787 let (mut parts, body) = res.into_parts();
8788 let mut body = common::Body::new(body);
8789 if !parts.status.is_success() {
8790 let bytes = common::to_bytes(body).await.unwrap_or_default();
8791 let error = serde_json::from_str(&common::to_string(&bytes));
8792 let response = common::to_response(parts, bytes.into());
8793
8794 if let common::Retry::After(d) =
8795 dlg.http_failure(&response, error.as_ref().ok())
8796 {
8797 sleep(d).await;
8798 continue;
8799 }
8800
8801 dlg.finished(false);
8802
8803 return Err(match error {
8804 Ok(value) => common::Error::BadRequest(value),
8805 _ => common::Error::Failure(response),
8806 });
8807 }
8808 let response = {
8809 let bytes = common::to_bytes(body).await.unwrap_or_default();
8810 let encoded = common::to_string(&bytes);
8811 match serde_json::from_str(&encoded) {
8812 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8813 Err(error) => {
8814 dlg.response_json_decode_error(&encoded, &error);
8815 return Err(common::Error::JsonDecodeError(
8816 encoded.to_string(),
8817 error,
8818 ));
8819 }
8820 }
8821 };
8822
8823 dlg.finished(true);
8824 return Ok(response);
8825 }
8826 }
8827 }
8828 }
8829
8830 /// Optional. A sync token, received from a previous response `next_sync_token` Provide this to retrieve only the resources changed since the last request. When syncing, all other parameters provided to `people.listDirectoryPeople` must match the first call that provided the sync token. More details about sync behavior at `people.listDirectoryPeople`.
8831 ///
8832 /// Sets the *sync token* query property to the given value.
8833 pub fn sync_token(mut self, new_value: &str) -> PersonListDirectoryPersonCall<'a, C> {
8834 self._sync_token = Some(new_value.to_string());
8835 self
8836 }
8837 /// Required. Directory sources to return.
8838 ///
8839 /// Append the given value to the *sources* query property.
8840 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8841 pub fn add_sources(mut self, new_value: &str) -> PersonListDirectoryPersonCall<'a, C> {
8842 self._sources.push(new_value.to_string());
8843 self
8844 }
8845 /// Optional. Whether the response should return `next_sync_token`. It can be used to get incremental changes since the last request by setting it on the request `sync_token`. More details about sync behavior at `people.listDirectoryPeople`.
8846 ///
8847 /// Sets the *request sync token* query property to the given value.
8848 pub fn request_sync_token(mut self, new_value: bool) -> PersonListDirectoryPersonCall<'a, C> {
8849 self._request_sync_token = Some(new_value);
8850 self
8851 }
8852 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
8853 ///
8854 /// Sets the *read mask* query property to the given value.
8855 pub fn read_mask(
8856 mut self,
8857 new_value: common::FieldMask,
8858 ) -> PersonListDirectoryPersonCall<'a, C> {
8859 self._read_mask = Some(new_value);
8860 self
8861 }
8862 /// Optional. A page token, received from a previous response `next_page_token`. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `people.listDirectoryPeople` must match the first call that provided the page token.
8863 ///
8864 /// Sets the *page token* query property to the given value.
8865 pub fn page_token(mut self, new_value: &str) -> PersonListDirectoryPersonCall<'a, C> {
8866 self._page_token = Some(new_value.to_string());
8867 self
8868 }
8869 /// Optional. The number of people to include in the response. Valid values are between 1 and 1000, inclusive. Defaults to 100 if not set or set to 0.
8870 ///
8871 /// Sets the *page size* query property to the given value.
8872 pub fn page_size(mut self, new_value: i32) -> PersonListDirectoryPersonCall<'a, C> {
8873 self._page_size = Some(new_value);
8874 self
8875 }
8876 /// Optional. Additional data to merge into the directory sources if they are connected through verified join keys such as email addresses or phone numbers.
8877 ///
8878 /// Append the given value to the *merge sources* query property.
8879 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
8880 pub fn add_merge_sources(mut self, new_value: &str) -> PersonListDirectoryPersonCall<'a, C> {
8881 self._merge_sources.push(new_value.to_string());
8882 self
8883 }
8884 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8885 /// while executing the actual API request.
8886 ///
8887 /// ````text
8888 /// It should be used to handle progress information, and to implement a certain level of resilience.
8889 /// ````
8890 ///
8891 /// Sets the *delegate* property to the given value.
8892 pub fn delegate(
8893 mut self,
8894 new_value: &'a mut dyn common::Delegate,
8895 ) -> PersonListDirectoryPersonCall<'a, C> {
8896 self._delegate = Some(new_value);
8897 self
8898 }
8899
8900 /// Set any additional parameter of the query string used in the request.
8901 /// It should be used to set parameters which are not yet available through their own
8902 /// setters.
8903 ///
8904 /// Please note that this method must not be used to set any of the known parameters
8905 /// which have their own setter method. If done anyway, the request will fail.
8906 ///
8907 /// # Additional Parameters
8908 ///
8909 /// * *$.xgafv* (query-string) - V1 error format.
8910 /// * *access_token* (query-string) - OAuth access token.
8911 /// * *alt* (query-string) - Data format for response.
8912 /// * *callback* (query-string) - JSONP
8913 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8914 /// * *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.
8915 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8916 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8917 /// * *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.
8918 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8919 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8920 pub fn param<T>(mut self, name: T, value: T) -> PersonListDirectoryPersonCall<'a, C>
8921 where
8922 T: AsRef<str>,
8923 {
8924 self._additional_params
8925 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8926 self
8927 }
8928
8929 /// Identifies the authorization scope for the method you are building.
8930 ///
8931 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8932 /// [`Scope::DirectoryReadonly`].
8933 ///
8934 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8935 /// tokens for more than one scope.
8936 ///
8937 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8938 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8939 /// sufficient, a read-write scope will do as well.
8940 pub fn add_scope<St>(mut self, scope: St) -> PersonListDirectoryPersonCall<'a, C>
8941 where
8942 St: AsRef<str>,
8943 {
8944 self._scopes.insert(String::from(scope.as_ref()));
8945 self
8946 }
8947 /// Identifies the authorization scope(s) for the method you are building.
8948 ///
8949 /// See [`Self::add_scope()`] for details.
8950 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonListDirectoryPersonCall<'a, C>
8951 where
8952 I: IntoIterator<Item = St>,
8953 St: AsRef<str>,
8954 {
8955 self._scopes
8956 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8957 self
8958 }
8959
8960 /// Removes all scopes, and no default scope will be used either.
8961 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8962 /// for details).
8963 pub fn clear_scopes(mut self) -> PersonListDirectoryPersonCall<'a, C> {
8964 self._scopes.clear();
8965 self
8966 }
8967}
8968
8969/// Provides a list of contacts in the authenticated user's grouped contacts that matches the search query. The query matches on a contact's `names`, `nickNames`, `emailAddresses`, `phoneNumbers`, and `organizations` fields that are from the CONTACT source. **IMPORTANT**: Before searching, clients should send a warmup request with an empty query to update the cache. See https://developers.google.com/people/v1/contacts#search_the_users_contacts
8970///
8971/// A builder for the *searchContacts* method supported by a *person* resource.
8972/// It is not used directly, but through a [`PersonMethods`] instance.
8973///
8974/// # Example
8975///
8976/// Instantiate a resource method builder
8977///
8978/// ```test_harness,no_run
8979/// # extern crate hyper;
8980/// # extern crate hyper_rustls;
8981/// # extern crate google_people1 as people1;
8982/// # async fn dox() {
8983/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8984///
8985/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8986/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8987/// # secret,
8988/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8989/// # ).build().await.unwrap();
8990///
8991/// # let client = hyper_util::client::legacy::Client::builder(
8992/// # hyper_util::rt::TokioExecutor::new()
8993/// # )
8994/// # .build(
8995/// # hyper_rustls::HttpsConnectorBuilder::new()
8996/// # .with_native_roots()
8997/// # .unwrap()
8998/// # .https_or_http()
8999/// # .enable_http1()
9000/// # .build()
9001/// # );
9002/// # let mut hub = PeopleService::new(client, auth);
9003/// // You can configure optional parameters by calling the respective setters at will, and
9004/// // execute the final call using `doit()`.
9005/// // Values shown here are possibly random and not representative !
9006/// let result = hub.people().search_contacts()
9007/// .add_sources("erat")
9008/// .read_mask(FieldMask::new::<&str>(&[]))
9009/// .query("sed")
9010/// .page_size(-20)
9011/// .doit().await;
9012/// # }
9013/// ```
9014pub struct PersonSearchContactCall<'a, C>
9015where
9016 C: 'a,
9017{
9018 hub: &'a PeopleService<C>,
9019 _sources: Vec<String>,
9020 _read_mask: Option<common::FieldMask>,
9021 _query: Option<String>,
9022 _page_size: Option<i32>,
9023 _delegate: Option<&'a mut dyn common::Delegate>,
9024 _additional_params: HashMap<String, String>,
9025 _scopes: BTreeSet<String>,
9026}
9027
9028impl<'a, C> common::CallBuilder for PersonSearchContactCall<'a, C> {}
9029
9030impl<'a, C> PersonSearchContactCall<'a, C>
9031where
9032 C: common::Connector,
9033{
9034 /// Perform the operation you have build so far.
9035 pub async fn doit(mut self) -> common::Result<(common::Response, SearchResponse)> {
9036 use std::borrow::Cow;
9037 use std::io::{Read, Seek};
9038
9039 use common::{url::Params, ToParts};
9040 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9041
9042 let mut dd = common::DefaultDelegate;
9043 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9044 dlg.begin(common::MethodInfo {
9045 id: "people.people.searchContacts",
9046 http_method: hyper::Method::GET,
9047 });
9048
9049 for &field in ["alt", "sources", "readMask", "query", "pageSize"].iter() {
9050 if self._additional_params.contains_key(field) {
9051 dlg.finished(false);
9052 return Err(common::Error::FieldClash(field));
9053 }
9054 }
9055
9056 let mut params = Params::with_capacity(6 + self._additional_params.len());
9057 if !self._sources.is_empty() {
9058 for f in self._sources.iter() {
9059 params.push("sources", f);
9060 }
9061 }
9062 if let Some(value) = self._read_mask.as_ref() {
9063 params.push("readMask", value.to_string());
9064 }
9065 if let Some(value) = self._query.as_ref() {
9066 params.push("query", value);
9067 }
9068 if let Some(value) = self._page_size.as_ref() {
9069 params.push("pageSize", value.to_string());
9070 }
9071
9072 params.extend(self._additional_params.iter());
9073
9074 params.push("alt", "json");
9075 let mut url = self.hub._base_url.clone() + "v1/people:searchContacts";
9076 if self._scopes.is_empty() {
9077 self._scopes
9078 .insert(Scope::ContactReadonly.as_ref().to_string());
9079 }
9080
9081 let url = params.parse_with_url(&url);
9082
9083 loop {
9084 let token = match self
9085 .hub
9086 .auth
9087 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9088 .await
9089 {
9090 Ok(token) => token,
9091 Err(e) => match dlg.token(e) {
9092 Ok(token) => token,
9093 Err(e) => {
9094 dlg.finished(false);
9095 return Err(common::Error::MissingToken(e));
9096 }
9097 },
9098 };
9099 let mut req_result = {
9100 let client = &self.hub.client;
9101 dlg.pre_request();
9102 let mut req_builder = hyper::Request::builder()
9103 .method(hyper::Method::GET)
9104 .uri(url.as_str())
9105 .header(USER_AGENT, self.hub._user_agent.clone());
9106
9107 if let Some(token) = token.as_ref() {
9108 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9109 }
9110
9111 let request = req_builder
9112 .header(CONTENT_LENGTH, 0_u64)
9113 .body(common::to_body::<String>(None));
9114
9115 client.request(request.unwrap()).await
9116 };
9117
9118 match req_result {
9119 Err(err) => {
9120 if let common::Retry::After(d) = dlg.http_error(&err) {
9121 sleep(d).await;
9122 continue;
9123 }
9124 dlg.finished(false);
9125 return Err(common::Error::HttpError(err));
9126 }
9127 Ok(res) => {
9128 let (mut parts, body) = res.into_parts();
9129 let mut body = common::Body::new(body);
9130 if !parts.status.is_success() {
9131 let bytes = common::to_bytes(body).await.unwrap_or_default();
9132 let error = serde_json::from_str(&common::to_string(&bytes));
9133 let response = common::to_response(parts, bytes.into());
9134
9135 if let common::Retry::After(d) =
9136 dlg.http_failure(&response, error.as_ref().ok())
9137 {
9138 sleep(d).await;
9139 continue;
9140 }
9141
9142 dlg.finished(false);
9143
9144 return Err(match error {
9145 Ok(value) => common::Error::BadRequest(value),
9146 _ => common::Error::Failure(response),
9147 });
9148 }
9149 let response = {
9150 let bytes = common::to_bytes(body).await.unwrap_or_default();
9151 let encoded = common::to_string(&bytes);
9152 match serde_json::from_str(&encoded) {
9153 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9154 Err(error) => {
9155 dlg.response_json_decode_error(&encoded, &error);
9156 return Err(common::Error::JsonDecodeError(
9157 encoded.to_string(),
9158 error,
9159 ));
9160 }
9161 }
9162 };
9163
9164 dlg.finished(true);
9165 return Ok(response);
9166 }
9167 }
9168 }
9169 }
9170
9171 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT if not set.
9172 ///
9173 /// Append the given value to the *sources* query property.
9174 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9175 pub fn add_sources(mut self, new_value: &str) -> PersonSearchContactCall<'a, C> {
9176 self._sources.push(new_value.to_string());
9177 self
9178 }
9179 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
9180 ///
9181 /// Sets the *read mask* query property to the given value.
9182 pub fn read_mask(mut self, new_value: common::FieldMask) -> PersonSearchContactCall<'a, C> {
9183 self._read_mask = Some(new_value);
9184 self
9185 }
9186 /// Required. The plain-text query for the request. The query is used to match prefix phrases of the fields on a person. For example, a person with name "foo name" matches queries such as "f", "fo", "foo", "foo n", "nam", etc., but not "oo n".
9187 ///
9188 /// Sets the *query* query property to the given value.
9189 pub fn query(mut self, new_value: &str) -> PersonSearchContactCall<'a, C> {
9190 self._query = Some(new_value.to_string());
9191 self
9192 }
9193 /// Optional. The number of results to return. Defaults to 10 if field is not set, or set to 0. Values greater than 30 will be capped to 30.
9194 ///
9195 /// Sets the *page size* query property to the given value.
9196 pub fn page_size(mut self, new_value: i32) -> PersonSearchContactCall<'a, C> {
9197 self._page_size = Some(new_value);
9198 self
9199 }
9200 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9201 /// while executing the actual API request.
9202 ///
9203 /// ````text
9204 /// It should be used to handle progress information, and to implement a certain level of resilience.
9205 /// ````
9206 ///
9207 /// Sets the *delegate* property to the given value.
9208 pub fn delegate(
9209 mut self,
9210 new_value: &'a mut dyn common::Delegate,
9211 ) -> PersonSearchContactCall<'a, C> {
9212 self._delegate = Some(new_value);
9213 self
9214 }
9215
9216 /// Set any additional parameter of the query string used in the request.
9217 /// It should be used to set parameters which are not yet available through their own
9218 /// setters.
9219 ///
9220 /// Please note that this method must not be used to set any of the known parameters
9221 /// which have their own setter method. If done anyway, the request will fail.
9222 ///
9223 /// # Additional Parameters
9224 ///
9225 /// * *$.xgafv* (query-string) - V1 error format.
9226 /// * *access_token* (query-string) - OAuth access token.
9227 /// * *alt* (query-string) - Data format for response.
9228 /// * *callback* (query-string) - JSONP
9229 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9230 /// * *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.
9231 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9232 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9233 /// * *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.
9234 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9235 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9236 pub fn param<T>(mut self, name: T, value: T) -> PersonSearchContactCall<'a, C>
9237 where
9238 T: AsRef<str>,
9239 {
9240 self._additional_params
9241 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9242 self
9243 }
9244
9245 /// Identifies the authorization scope for the method you are building.
9246 ///
9247 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9248 /// [`Scope::ContactReadonly`].
9249 ///
9250 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9251 /// tokens for more than one scope.
9252 ///
9253 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9254 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9255 /// sufficient, a read-write scope will do as well.
9256 pub fn add_scope<St>(mut self, scope: St) -> PersonSearchContactCall<'a, C>
9257 where
9258 St: AsRef<str>,
9259 {
9260 self._scopes.insert(String::from(scope.as_ref()));
9261 self
9262 }
9263 /// Identifies the authorization scope(s) for the method you are building.
9264 ///
9265 /// See [`Self::add_scope()`] for details.
9266 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonSearchContactCall<'a, C>
9267 where
9268 I: IntoIterator<Item = St>,
9269 St: AsRef<str>,
9270 {
9271 self._scopes
9272 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9273 self
9274 }
9275
9276 /// Removes all scopes, and no default scope will be used either.
9277 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9278 /// for details).
9279 pub fn clear_scopes(mut self) -> PersonSearchContactCall<'a, C> {
9280 self._scopes.clear();
9281 self
9282 }
9283}
9284
9285/// Provides a list of domain profiles and domain contacts in the authenticated user's domain directory that match the search query.
9286///
9287/// A builder for the *searchDirectoryPeople* method supported by a *person* resource.
9288/// It is not used directly, but through a [`PersonMethods`] instance.
9289///
9290/// # Example
9291///
9292/// Instantiate a resource method builder
9293///
9294/// ```test_harness,no_run
9295/// # extern crate hyper;
9296/// # extern crate hyper_rustls;
9297/// # extern crate google_people1 as people1;
9298/// # async fn dox() {
9299/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9300///
9301/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9302/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9303/// # secret,
9304/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9305/// # ).build().await.unwrap();
9306///
9307/// # let client = hyper_util::client::legacy::Client::builder(
9308/// # hyper_util::rt::TokioExecutor::new()
9309/// # )
9310/// # .build(
9311/// # hyper_rustls::HttpsConnectorBuilder::new()
9312/// # .with_native_roots()
9313/// # .unwrap()
9314/// # .https_or_http()
9315/// # .enable_http1()
9316/// # .build()
9317/// # );
9318/// # let mut hub = PeopleService::new(client, auth);
9319/// // You can configure optional parameters by calling the respective setters at will, and
9320/// // execute the final call using `doit()`.
9321/// // Values shown here are possibly random and not representative !
9322/// let result = hub.people().search_directory_people()
9323/// .add_sources("dolore")
9324/// .read_mask(FieldMask::new::<&str>(&[]))
9325/// .query("et")
9326/// .page_token("voluptua.")
9327/// .page_size(-2)
9328/// .add_merge_sources("consetetur")
9329/// .doit().await;
9330/// # }
9331/// ```
9332pub struct PersonSearchDirectoryPersonCall<'a, C>
9333where
9334 C: 'a,
9335{
9336 hub: &'a PeopleService<C>,
9337 _sources: Vec<String>,
9338 _read_mask: Option<common::FieldMask>,
9339 _query: Option<String>,
9340 _page_token: Option<String>,
9341 _page_size: Option<i32>,
9342 _merge_sources: Vec<String>,
9343 _delegate: Option<&'a mut dyn common::Delegate>,
9344 _additional_params: HashMap<String, String>,
9345 _scopes: BTreeSet<String>,
9346}
9347
9348impl<'a, C> common::CallBuilder for PersonSearchDirectoryPersonCall<'a, C> {}
9349
9350impl<'a, C> PersonSearchDirectoryPersonCall<'a, C>
9351where
9352 C: common::Connector,
9353{
9354 /// Perform the operation you have build so far.
9355 pub async fn doit(
9356 mut self,
9357 ) -> common::Result<(common::Response, SearchDirectoryPeopleResponse)> {
9358 use std::borrow::Cow;
9359 use std::io::{Read, Seek};
9360
9361 use common::{url::Params, ToParts};
9362 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9363
9364 let mut dd = common::DefaultDelegate;
9365 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9366 dlg.begin(common::MethodInfo {
9367 id: "people.people.searchDirectoryPeople",
9368 http_method: hyper::Method::GET,
9369 });
9370
9371 for &field in [
9372 "alt",
9373 "sources",
9374 "readMask",
9375 "query",
9376 "pageToken",
9377 "pageSize",
9378 "mergeSources",
9379 ]
9380 .iter()
9381 {
9382 if self._additional_params.contains_key(field) {
9383 dlg.finished(false);
9384 return Err(common::Error::FieldClash(field));
9385 }
9386 }
9387
9388 let mut params = Params::with_capacity(8 + self._additional_params.len());
9389 if !self._sources.is_empty() {
9390 for f in self._sources.iter() {
9391 params.push("sources", f);
9392 }
9393 }
9394 if let Some(value) = self._read_mask.as_ref() {
9395 params.push("readMask", value.to_string());
9396 }
9397 if let Some(value) = self._query.as_ref() {
9398 params.push("query", value);
9399 }
9400 if let Some(value) = self._page_token.as_ref() {
9401 params.push("pageToken", value);
9402 }
9403 if let Some(value) = self._page_size.as_ref() {
9404 params.push("pageSize", value.to_string());
9405 }
9406 if !self._merge_sources.is_empty() {
9407 for f in self._merge_sources.iter() {
9408 params.push("mergeSources", f);
9409 }
9410 }
9411
9412 params.extend(self._additional_params.iter());
9413
9414 params.push("alt", "json");
9415 let mut url = self.hub._base_url.clone() + "v1/people:searchDirectoryPeople";
9416 if self._scopes.is_empty() {
9417 self._scopes
9418 .insert(Scope::DirectoryReadonly.as_ref().to_string());
9419 }
9420
9421 let url = params.parse_with_url(&url);
9422
9423 loop {
9424 let token = match self
9425 .hub
9426 .auth
9427 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9428 .await
9429 {
9430 Ok(token) => token,
9431 Err(e) => match dlg.token(e) {
9432 Ok(token) => token,
9433 Err(e) => {
9434 dlg.finished(false);
9435 return Err(common::Error::MissingToken(e));
9436 }
9437 },
9438 };
9439 let mut req_result = {
9440 let client = &self.hub.client;
9441 dlg.pre_request();
9442 let mut req_builder = hyper::Request::builder()
9443 .method(hyper::Method::GET)
9444 .uri(url.as_str())
9445 .header(USER_AGENT, self.hub._user_agent.clone());
9446
9447 if let Some(token) = token.as_ref() {
9448 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9449 }
9450
9451 let request = req_builder
9452 .header(CONTENT_LENGTH, 0_u64)
9453 .body(common::to_body::<String>(None));
9454
9455 client.request(request.unwrap()).await
9456 };
9457
9458 match req_result {
9459 Err(err) => {
9460 if let common::Retry::After(d) = dlg.http_error(&err) {
9461 sleep(d).await;
9462 continue;
9463 }
9464 dlg.finished(false);
9465 return Err(common::Error::HttpError(err));
9466 }
9467 Ok(res) => {
9468 let (mut parts, body) = res.into_parts();
9469 let mut body = common::Body::new(body);
9470 if !parts.status.is_success() {
9471 let bytes = common::to_bytes(body).await.unwrap_or_default();
9472 let error = serde_json::from_str(&common::to_string(&bytes));
9473 let response = common::to_response(parts, bytes.into());
9474
9475 if let common::Retry::After(d) =
9476 dlg.http_failure(&response, error.as_ref().ok())
9477 {
9478 sleep(d).await;
9479 continue;
9480 }
9481
9482 dlg.finished(false);
9483
9484 return Err(match error {
9485 Ok(value) => common::Error::BadRequest(value),
9486 _ => common::Error::Failure(response),
9487 });
9488 }
9489 let response = {
9490 let bytes = common::to_bytes(body).await.unwrap_or_default();
9491 let encoded = common::to_string(&bytes);
9492 match serde_json::from_str(&encoded) {
9493 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9494 Err(error) => {
9495 dlg.response_json_decode_error(&encoded, &error);
9496 return Err(common::Error::JsonDecodeError(
9497 encoded.to_string(),
9498 error,
9499 ));
9500 }
9501 }
9502 };
9503
9504 dlg.finished(true);
9505 return Ok(response);
9506 }
9507 }
9508 }
9509 }
9510
9511 /// Required. Directory sources to return.
9512 ///
9513 /// Append the given value to the *sources* query property.
9514 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9515 pub fn add_sources(mut self, new_value: &str) -> PersonSearchDirectoryPersonCall<'a, C> {
9516 self._sources.push(new_value.to_string());
9517 self
9518 }
9519 /// Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
9520 ///
9521 /// Sets the *read mask* query property to the given value.
9522 pub fn read_mask(
9523 mut self,
9524 new_value: common::FieldMask,
9525 ) -> PersonSearchDirectoryPersonCall<'a, C> {
9526 self._read_mask = Some(new_value);
9527 self
9528 }
9529 /// Required. Prefix query that matches fields in the person. Does NOT use the read_mask for determining what fields to match.
9530 ///
9531 /// Sets the *query* query property to the given value.
9532 pub fn query(mut self, new_value: &str) -> PersonSearchDirectoryPersonCall<'a, C> {
9533 self._query = Some(new_value.to_string());
9534 self
9535 }
9536 /// Optional. A page token, received from a previous response `next_page_token`. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `SearchDirectoryPeople` must match the first call that provided the page token.
9537 ///
9538 /// Sets the *page token* query property to the given value.
9539 pub fn page_token(mut self, new_value: &str) -> PersonSearchDirectoryPersonCall<'a, C> {
9540 self._page_token = Some(new_value.to_string());
9541 self
9542 }
9543 /// Optional. The number of people to include in the response. Valid values are between 1 and 500, inclusive. Defaults to 100 if not set or set to 0.
9544 ///
9545 /// Sets the *page size* query property to the given value.
9546 pub fn page_size(mut self, new_value: i32) -> PersonSearchDirectoryPersonCall<'a, C> {
9547 self._page_size = Some(new_value);
9548 self
9549 }
9550 /// Optional. Additional data to merge into the directory sources if they are connected through verified join keys such as email addresses or phone numbers.
9551 ///
9552 /// Append the given value to the *merge sources* query property.
9553 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9554 pub fn add_merge_sources(mut self, new_value: &str) -> PersonSearchDirectoryPersonCall<'a, C> {
9555 self._merge_sources.push(new_value.to_string());
9556 self
9557 }
9558 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9559 /// while executing the actual API request.
9560 ///
9561 /// ````text
9562 /// It should be used to handle progress information, and to implement a certain level of resilience.
9563 /// ````
9564 ///
9565 /// Sets the *delegate* property to the given value.
9566 pub fn delegate(
9567 mut self,
9568 new_value: &'a mut dyn common::Delegate,
9569 ) -> PersonSearchDirectoryPersonCall<'a, C> {
9570 self._delegate = Some(new_value);
9571 self
9572 }
9573
9574 /// Set any additional parameter of the query string used in the request.
9575 /// It should be used to set parameters which are not yet available through their own
9576 /// setters.
9577 ///
9578 /// Please note that this method must not be used to set any of the known parameters
9579 /// which have their own setter method. If done anyway, the request will fail.
9580 ///
9581 /// # Additional Parameters
9582 ///
9583 /// * *$.xgafv* (query-string) - V1 error format.
9584 /// * *access_token* (query-string) - OAuth access token.
9585 /// * *alt* (query-string) - Data format for response.
9586 /// * *callback* (query-string) - JSONP
9587 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9588 /// * *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.
9589 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9590 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9591 /// * *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.
9592 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9593 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9594 pub fn param<T>(mut self, name: T, value: T) -> PersonSearchDirectoryPersonCall<'a, C>
9595 where
9596 T: AsRef<str>,
9597 {
9598 self._additional_params
9599 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9600 self
9601 }
9602
9603 /// Identifies the authorization scope for the method you are building.
9604 ///
9605 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9606 /// [`Scope::DirectoryReadonly`].
9607 ///
9608 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9609 /// tokens for more than one scope.
9610 ///
9611 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9612 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9613 /// sufficient, a read-write scope will do as well.
9614 pub fn add_scope<St>(mut self, scope: St) -> PersonSearchDirectoryPersonCall<'a, C>
9615 where
9616 St: AsRef<str>,
9617 {
9618 self._scopes.insert(String::from(scope.as_ref()));
9619 self
9620 }
9621 /// Identifies the authorization scope(s) for the method you are building.
9622 ///
9623 /// See [`Self::add_scope()`] for details.
9624 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonSearchDirectoryPersonCall<'a, C>
9625 where
9626 I: IntoIterator<Item = St>,
9627 St: AsRef<str>,
9628 {
9629 self._scopes
9630 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9631 self
9632 }
9633
9634 /// Removes all scopes, and no default scope will be used either.
9635 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9636 /// for details).
9637 pub fn clear_scopes(mut self) -> PersonSearchDirectoryPersonCall<'a, C> {
9638 self._scopes.clear();
9639 self
9640 }
9641}
9642
9643/// Update contact data for an existing contact person. Any non-contact data will not be modified. Any non-contact data in the person to update will be ignored. All fields specified in the `update_mask` will be replaced. The server returns a 400 error if `person.metadata.sources` is not specified for the contact to be updated or if there is no contact source. The server returns a 400 error with reason `"failedPrecondition"` if `person.metadata.sources.etag` is different than the contact's etag, which indicates the contact has changed since its data was read. Clients should get the latest person and merge their updates into the latest person. The server returns a 400 error if `memberships` are being updated and there are no contact group memberships specified on the person. The server returns a 400 error if more than one field is specified on a field that is a singleton for contact sources: * biographies * birthdays * genders * names Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
9644///
9645/// A builder for the *updateContact* method supported by a *person* resource.
9646/// It is not used directly, but through a [`PersonMethods`] instance.
9647///
9648/// # Example
9649///
9650/// Instantiate a resource method builder
9651///
9652/// ```test_harness,no_run
9653/// # extern crate hyper;
9654/// # extern crate hyper_rustls;
9655/// # extern crate google_people1 as people1;
9656/// use people1::api::Person;
9657/// # async fn dox() {
9658/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9659///
9660/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9661/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9662/// # secret,
9663/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9664/// # ).build().await.unwrap();
9665///
9666/// # let client = hyper_util::client::legacy::Client::builder(
9667/// # hyper_util::rt::TokioExecutor::new()
9668/// # )
9669/// # .build(
9670/// # hyper_rustls::HttpsConnectorBuilder::new()
9671/// # .with_native_roots()
9672/// # .unwrap()
9673/// # .https_or_http()
9674/// # .enable_http1()
9675/// # .build()
9676/// # );
9677/// # let mut hub = PeopleService::new(client, auth);
9678/// // As the method needs a request, you would usually fill it with the desired information
9679/// // into the respective structure. Some of the parts shown here might not be applicable !
9680/// // Values shown here are possibly random and not representative !
9681/// let mut req = Person::default();
9682///
9683/// // You can configure optional parameters by calling the respective setters at will, and
9684/// // execute the final call using `doit()`.
9685/// // Values shown here are possibly random and not representative !
9686/// let result = hub.people().update_contact(req, "resourceName")
9687/// .update_person_fields(FieldMask::new::<&str>(&[]))
9688/// .add_sources("dolor")
9689/// .person_fields(FieldMask::new::<&str>(&[]))
9690/// .doit().await;
9691/// # }
9692/// ```
9693pub struct PersonUpdateContactCall<'a, C>
9694where
9695 C: 'a,
9696{
9697 hub: &'a PeopleService<C>,
9698 _request: Person,
9699 _resource_name: String,
9700 _update_person_fields: Option<common::FieldMask>,
9701 _sources: Vec<String>,
9702 _person_fields: Option<common::FieldMask>,
9703 _delegate: Option<&'a mut dyn common::Delegate>,
9704 _additional_params: HashMap<String, String>,
9705 _scopes: BTreeSet<String>,
9706}
9707
9708impl<'a, C> common::CallBuilder for PersonUpdateContactCall<'a, C> {}
9709
9710impl<'a, C> PersonUpdateContactCall<'a, C>
9711where
9712 C: common::Connector,
9713{
9714 /// Perform the operation you have build so far.
9715 pub async fn doit(mut self) -> common::Result<(common::Response, Person)> {
9716 use std::borrow::Cow;
9717 use std::io::{Read, Seek};
9718
9719 use common::{url::Params, ToParts};
9720 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9721
9722 let mut dd = common::DefaultDelegate;
9723 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9724 dlg.begin(common::MethodInfo {
9725 id: "people.people.updateContact",
9726 http_method: hyper::Method::PATCH,
9727 });
9728
9729 for &field in [
9730 "alt",
9731 "resourceName",
9732 "updatePersonFields",
9733 "sources",
9734 "personFields",
9735 ]
9736 .iter()
9737 {
9738 if self._additional_params.contains_key(field) {
9739 dlg.finished(false);
9740 return Err(common::Error::FieldClash(field));
9741 }
9742 }
9743
9744 let mut params = Params::with_capacity(7 + self._additional_params.len());
9745 params.push("resourceName", self._resource_name);
9746 if let Some(value) = self._update_person_fields.as_ref() {
9747 params.push("updatePersonFields", value.to_string());
9748 }
9749 if !self._sources.is_empty() {
9750 for f in self._sources.iter() {
9751 params.push("sources", f);
9752 }
9753 }
9754 if let Some(value) = self._person_fields.as_ref() {
9755 params.push("personFields", value.to_string());
9756 }
9757
9758 params.extend(self._additional_params.iter());
9759
9760 params.push("alt", "json");
9761 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}:updateContact";
9762 if self._scopes.is_empty() {
9763 self._scopes.insert(Scope::Contact.as_ref().to_string());
9764 }
9765
9766 #[allow(clippy::single_element_loop)]
9767 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
9768 url = params.uri_replacement(url, param_name, find_this, true);
9769 }
9770 {
9771 let to_remove = ["resourceName"];
9772 params.remove_params(&to_remove);
9773 }
9774
9775 let url = params.parse_with_url(&url);
9776
9777 let mut json_mime_type = mime::APPLICATION_JSON;
9778 let mut request_value_reader = {
9779 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9780 common::remove_json_null_values(&mut value);
9781 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9782 serde_json::to_writer(&mut dst, &value).unwrap();
9783 dst
9784 };
9785 let request_size = request_value_reader
9786 .seek(std::io::SeekFrom::End(0))
9787 .unwrap();
9788 request_value_reader
9789 .seek(std::io::SeekFrom::Start(0))
9790 .unwrap();
9791
9792 loop {
9793 let token = match self
9794 .hub
9795 .auth
9796 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9797 .await
9798 {
9799 Ok(token) => token,
9800 Err(e) => match dlg.token(e) {
9801 Ok(token) => token,
9802 Err(e) => {
9803 dlg.finished(false);
9804 return Err(common::Error::MissingToken(e));
9805 }
9806 },
9807 };
9808 request_value_reader
9809 .seek(std::io::SeekFrom::Start(0))
9810 .unwrap();
9811 let mut req_result = {
9812 let client = &self.hub.client;
9813 dlg.pre_request();
9814 let mut req_builder = hyper::Request::builder()
9815 .method(hyper::Method::PATCH)
9816 .uri(url.as_str())
9817 .header(USER_AGENT, self.hub._user_agent.clone());
9818
9819 if let Some(token) = token.as_ref() {
9820 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9821 }
9822
9823 let request = req_builder
9824 .header(CONTENT_TYPE, json_mime_type.to_string())
9825 .header(CONTENT_LENGTH, request_size as u64)
9826 .body(common::to_body(
9827 request_value_reader.get_ref().clone().into(),
9828 ));
9829
9830 client.request(request.unwrap()).await
9831 };
9832
9833 match req_result {
9834 Err(err) => {
9835 if let common::Retry::After(d) = dlg.http_error(&err) {
9836 sleep(d).await;
9837 continue;
9838 }
9839 dlg.finished(false);
9840 return Err(common::Error::HttpError(err));
9841 }
9842 Ok(res) => {
9843 let (mut parts, body) = res.into_parts();
9844 let mut body = common::Body::new(body);
9845 if !parts.status.is_success() {
9846 let bytes = common::to_bytes(body).await.unwrap_or_default();
9847 let error = serde_json::from_str(&common::to_string(&bytes));
9848 let response = common::to_response(parts, bytes.into());
9849
9850 if let common::Retry::After(d) =
9851 dlg.http_failure(&response, error.as_ref().ok())
9852 {
9853 sleep(d).await;
9854 continue;
9855 }
9856
9857 dlg.finished(false);
9858
9859 return Err(match error {
9860 Ok(value) => common::Error::BadRequest(value),
9861 _ => common::Error::Failure(response),
9862 });
9863 }
9864 let response = {
9865 let bytes = common::to_bytes(body).await.unwrap_or_default();
9866 let encoded = common::to_string(&bytes);
9867 match serde_json::from_str(&encoded) {
9868 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9869 Err(error) => {
9870 dlg.response_json_decode_error(&encoded, &error);
9871 return Err(common::Error::JsonDecodeError(
9872 encoded.to_string(),
9873 error,
9874 ));
9875 }
9876 }
9877 };
9878
9879 dlg.finished(true);
9880 return Ok(response);
9881 }
9882 }
9883 }
9884 }
9885
9886 ///
9887 /// Sets the *request* property to the given value.
9888 ///
9889 /// Even though the property as already been set when instantiating this call,
9890 /// we provide this method for API completeness.
9891 pub fn request(mut self, new_value: Person) -> PersonUpdateContactCall<'a, C> {
9892 self._request = new_value;
9893 self
9894 }
9895 /// The resource name for the person, assigned by the server. An ASCII string in the form of `people/{person_id}`.
9896 ///
9897 /// Sets the *resource name* path property to the given value.
9898 ///
9899 /// Even though the property as already been set when instantiating this call,
9900 /// we provide this method for API completeness.
9901 pub fn resource_name(mut self, new_value: &str) -> PersonUpdateContactCall<'a, C> {
9902 self._resource_name = new_value.to_string();
9903 self
9904 }
9905 /// Required. A field mask to restrict which fields on the person are updated. Multiple fields can be specified by separating them with commas. All updated fields will be replaced. Valid values are: * addresses * biographies * birthdays * calendarUrls * clientData * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * relations * sipAddresses * urls * userDefined
9906 ///
9907 /// Sets the *update person fields* query property to the given value.
9908 pub fn update_person_fields(
9909 mut self,
9910 new_value: common::FieldMask,
9911 ) -> PersonUpdateContactCall<'a, C> {
9912 self._update_person_fields = Some(new_value);
9913 self
9914 }
9915 /// Optional. A mask of what source types to return. Defaults to READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE if not set.
9916 ///
9917 /// Append the given value to the *sources* query property.
9918 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9919 pub fn add_sources(mut self, new_value: &str) -> PersonUpdateContactCall<'a, C> {
9920 self._sources.push(new_value.to_string());
9921 self
9922 }
9923 /// Optional. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. Defaults to all fields if not set. Valid values are: * addresses * ageRanges * biographies * birthdays * calendarUrls * clientData * coverPhotos * emailAddresses * events * externalIds * genders * imClients * interests * locales * locations * memberships * metadata * miscKeywords * names * nicknames * occupations * organizations * phoneNumbers * photos * relations * sipAddresses * skills * urls * userDefined
9924 ///
9925 /// Sets the *person fields* query property to the given value.
9926 pub fn person_fields(mut self, new_value: common::FieldMask) -> PersonUpdateContactCall<'a, C> {
9927 self._person_fields = Some(new_value);
9928 self
9929 }
9930 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9931 /// while executing the actual API request.
9932 ///
9933 /// ````text
9934 /// It should be used to handle progress information, and to implement a certain level of resilience.
9935 /// ````
9936 ///
9937 /// Sets the *delegate* property to the given value.
9938 pub fn delegate(
9939 mut self,
9940 new_value: &'a mut dyn common::Delegate,
9941 ) -> PersonUpdateContactCall<'a, C> {
9942 self._delegate = Some(new_value);
9943 self
9944 }
9945
9946 /// Set any additional parameter of the query string used in the request.
9947 /// It should be used to set parameters which are not yet available through their own
9948 /// setters.
9949 ///
9950 /// Please note that this method must not be used to set any of the known parameters
9951 /// which have their own setter method. If done anyway, the request will fail.
9952 ///
9953 /// # Additional Parameters
9954 ///
9955 /// * *$.xgafv* (query-string) - V1 error format.
9956 /// * *access_token* (query-string) - OAuth access token.
9957 /// * *alt* (query-string) - Data format for response.
9958 /// * *callback* (query-string) - JSONP
9959 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9960 /// * *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.
9961 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9962 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9963 /// * *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.
9964 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9965 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9966 pub fn param<T>(mut self, name: T, value: T) -> PersonUpdateContactCall<'a, C>
9967 where
9968 T: AsRef<str>,
9969 {
9970 self._additional_params
9971 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9972 self
9973 }
9974
9975 /// Identifies the authorization scope for the method you are building.
9976 ///
9977 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9978 /// [`Scope::Contact`].
9979 ///
9980 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9981 /// tokens for more than one scope.
9982 ///
9983 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9984 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9985 /// sufficient, a read-write scope will do as well.
9986 pub fn add_scope<St>(mut self, scope: St) -> PersonUpdateContactCall<'a, C>
9987 where
9988 St: AsRef<str>,
9989 {
9990 self._scopes.insert(String::from(scope.as_ref()));
9991 self
9992 }
9993 /// Identifies the authorization scope(s) for the method you are building.
9994 ///
9995 /// See [`Self::add_scope()`] for details.
9996 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonUpdateContactCall<'a, C>
9997 where
9998 I: IntoIterator<Item = St>,
9999 St: AsRef<str>,
10000 {
10001 self._scopes
10002 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10003 self
10004 }
10005
10006 /// Removes all scopes, and no default scope will be used either.
10007 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10008 /// for details).
10009 pub fn clear_scopes(mut self) -> PersonUpdateContactCall<'a, C> {
10010 self._scopes.clear();
10011 self
10012 }
10013}
10014
10015/// Update a contact's photo. Mutate requests for the same user should be sent sequentially to avoid increased latency and failures.
10016///
10017/// A builder for the *updateContactPhoto* method supported by a *person* resource.
10018/// It is not used directly, but through a [`PersonMethods`] instance.
10019///
10020/// # Example
10021///
10022/// Instantiate a resource method builder
10023///
10024/// ```test_harness,no_run
10025/// # extern crate hyper;
10026/// # extern crate hyper_rustls;
10027/// # extern crate google_people1 as people1;
10028/// use people1::api::UpdateContactPhotoRequest;
10029/// # async fn dox() {
10030/// # use people1::{PeopleService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10031///
10032/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10033/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10034/// # secret,
10035/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10036/// # ).build().await.unwrap();
10037///
10038/// # let client = hyper_util::client::legacy::Client::builder(
10039/// # hyper_util::rt::TokioExecutor::new()
10040/// # )
10041/// # .build(
10042/// # hyper_rustls::HttpsConnectorBuilder::new()
10043/// # .with_native_roots()
10044/// # .unwrap()
10045/// # .https_or_http()
10046/// # .enable_http1()
10047/// # .build()
10048/// # );
10049/// # let mut hub = PeopleService::new(client, auth);
10050/// // As the method needs a request, you would usually fill it with the desired information
10051/// // into the respective structure. Some of the parts shown here might not be applicable !
10052/// // Values shown here are possibly random and not representative !
10053/// let mut req = UpdateContactPhotoRequest::default();
10054///
10055/// // You can configure optional parameters by calling the respective setters at will, and
10056/// // execute the final call using `doit()`.
10057/// // Values shown here are possibly random and not representative !
10058/// let result = hub.people().update_contact_photo(req, "resourceName")
10059/// .doit().await;
10060/// # }
10061/// ```
10062pub struct PersonUpdateContactPhotoCall<'a, C>
10063where
10064 C: 'a,
10065{
10066 hub: &'a PeopleService<C>,
10067 _request: UpdateContactPhotoRequest,
10068 _resource_name: String,
10069 _delegate: Option<&'a mut dyn common::Delegate>,
10070 _additional_params: HashMap<String, String>,
10071 _scopes: BTreeSet<String>,
10072}
10073
10074impl<'a, C> common::CallBuilder for PersonUpdateContactPhotoCall<'a, C> {}
10075
10076impl<'a, C> PersonUpdateContactPhotoCall<'a, C>
10077where
10078 C: common::Connector,
10079{
10080 /// Perform the operation you have build so far.
10081 pub async fn doit(mut self) -> common::Result<(common::Response, UpdateContactPhotoResponse)> {
10082 use std::borrow::Cow;
10083 use std::io::{Read, Seek};
10084
10085 use common::{url::Params, ToParts};
10086 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10087
10088 let mut dd = common::DefaultDelegate;
10089 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10090 dlg.begin(common::MethodInfo {
10091 id: "people.people.updateContactPhoto",
10092 http_method: hyper::Method::PATCH,
10093 });
10094
10095 for &field in ["alt", "resourceName"].iter() {
10096 if self._additional_params.contains_key(field) {
10097 dlg.finished(false);
10098 return Err(common::Error::FieldClash(field));
10099 }
10100 }
10101
10102 let mut params = Params::with_capacity(4 + self._additional_params.len());
10103 params.push("resourceName", self._resource_name);
10104
10105 params.extend(self._additional_params.iter());
10106
10107 params.push("alt", "json");
10108 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}:updateContactPhoto";
10109 if self._scopes.is_empty() {
10110 self._scopes.insert(Scope::Contact.as_ref().to_string());
10111 }
10112
10113 #[allow(clippy::single_element_loop)]
10114 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
10115 url = params.uri_replacement(url, param_name, find_this, true);
10116 }
10117 {
10118 let to_remove = ["resourceName"];
10119 params.remove_params(&to_remove);
10120 }
10121
10122 let url = params.parse_with_url(&url);
10123
10124 let mut json_mime_type = mime::APPLICATION_JSON;
10125 let mut request_value_reader = {
10126 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10127 common::remove_json_null_values(&mut value);
10128 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10129 serde_json::to_writer(&mut dst, &value).unwrap();
10130 dst
10131 };
10132 let request_size = request_value_reader
10133 .seek(std::io::SeekFrom::End(0))
10134 .unwrap();
10135 request_value_reader
10136 .seek(std::io::SeekFrom::Start(0))
10137 .unwrap();
10138
10139 loop {
10140 let token = match self
10141 .hub
10142 .auth
10143 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10144 .await
10145 {
10146 Ok(token) => token,
10147 Err(e) => match dlg.token(e) {
10148 Ok(token) => token,
10149 Err(e) => {
10150 dlg.finished(false);
10151 return Err(common::Error::MissingToken(e));
10152 }
10153 },
10154 };
10155 request_value_reader
10156 .seek(std::io::SeekFrom::Start(0))
10157 .unwrap();
10158 let mut req_result = {
10159 let client = &self.hub.client;
10160 dlg.pre_request();
10161 let mut req_builder = hyper::Request::builder()
10162 .method(hyper::Method::PATCH)
10163 .uri(url.as_str())
10164 .header(USER_AGENT, self.hub._user_agent.clone());
10165
10166 if let Some(token) = token.as_ref() {
10167 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10168 }
10169
10170 let request = req_builder
10171 .header(CONTENT_TYPE, json_mime_type.to_string())
10172 .header(CONTENT_LENGTH, request_size as u64)
10173 .body(common::to_body(
10174 request_value_reader.get_ref().clone().into(),
10175 ));
10176
10177 client.request(request.unwrap()).await
10178 };
10179
10180 match req_result {
10181 Err(err) => {
10182 if let common::Retry::After(d) = dlg.http_error(&err) {
10183 sleep(d).await;
10184 continue;
10185 }
10186 dlg.finished(false);
10187 return Err(common::Error::HttpError(err));
10188 }
10189 Ok(res) => {
10190 let (mut parts, body) = res.into_parts();
10191 let mut body = common::Body::new(body);
10192 if !parts.status.is_success() {
10193 let bytes = common::to_bytes(body).await.unwrap_or_default();
10194 let error = serde_json::from_str(&common::to_string(&bytes));
10195 let response = common::to_response(parts, bytes.into());
10196
10197 if let common::Retry::After(d) =
10198 dlg.http_failure(&response, error.as_ref().ok())
10199 {
10200 sleep(d).await;
10201 continue;
10202 }
10203
10204 dlg.finished(false);
10205
10206 return Err(match error {
10207 Ok(value) => common::Error::BadRequest(value),
10208 _ => common::Error::Failure(response),
10209 });
10210 }
10211 let response = {
10212 let bytes = common::to_bytes(body).await.unwrap_or_default();
10213 let encoded = common::to_string(&bytes);
10214 match serde_json::from_str(&encoded) {
10215 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10216 Err(error) => {
10217 dlg.response_json_decode_error(&encoded, &error);
10218 return Err(common::Error::JsonDecodeError(
10219 encoded.to_string(),
10220 error,
10221 ));
10222 }
10223 }
10224 };
10225
10226 dlg.finished(true);
10227 return Ok(response);
10228 }
10229 }
10230 }
10231 }
10232
10233 ///
10234 /// Sets the *request* property to the given value.
10235 ///
10236 /// Even though the property as already been set when instantiating this call,
10237 /// we provide this method for API completeness.
10238 pub fn request(
10239 mut self,
10240 new_value: UpdateContactPhotoRequest,
10241 ) -> PersonUpdateContactPhotoCall<'a, C> {
10242 self._request = new_value;
10243 self
10244 }
10245 /// Required. Person resource name
10246 ///
10247 /// Sets the *resource name* path property to the given value.
10248 ///
10249 /// Even though the property as already been set when instantiating this call,
10250 /// we provide this method for API completeness.
10251 pub fn resource_name(mut self, new_value: &str) -> PersonUpdateContactPhotoCall<'a, C> {
10252 self._resource_name = new_value.to_string();
10253 self
10254 }
10255 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10256 /// while executing the actual API request.
10257 ///
10258 /// ````text
10259 /// It should be used to handle progress information, and to implement a certain level of resilience.
10260 /// ````
10261 ///
10262 /// Sets the *delegate* property to the given value.
10263 pub fn delegate(
10264 mut self,
10265 new_value: &'a mut dyn common::Delegate,
10266 ) -> PersonUpdateContactPhotoCall<'a, C> {
10267 self._delegate = Some(new_value);
10268 self
10269 }
10270
10271 /// Set any additional parameter of the query string used in the request.
10272 /// It should be used to set parameters which are not yet available through their own
10273 /// setters.
10274 ///
10275 /// Please note that this method must not be used to set any of the known parameters
10276 /// which have their own setter method. If done anyway, the request will fail.
10277 ///
10278 /// # Additional Parameters
10279 ///
10280 /// * *$.xgafv* (query-string) - V1 error format.
10281 /// * *access_token* (query-string) - OAuth access token.
10282 /// * *alt* (query-string) - Data format for response.
10283 /// * *callback* (query-string) - JSONP
10284 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10285 /// * *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.
10286 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10287 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10288 /// * *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.
10289 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10290 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10291 pub fn param<T>(mut self, name: T, value: T) -> PersonUpdateContactPhotoCall<'a, C>
10292 where
10293 T: AsRef<str>,
10294 {
10295 self._additional_params
10296 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10297 self
10298 }
10299
10300 /// Identifies the authorization scope for the method you are building.
10301 ///
10302 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10303 /// [`Scope::Contact`].
10304 ///
10305 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10306 /// tokens for more than one scope.
10307 ///
10308 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10309 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10310 /// sufficient, a read-write scope will do as well.
10311 pub fn add_scope<St>(mut self, scope: St) -> PersonUpdateContactPhotoCall<'a, C>
10312 where
10313 St: AsRef<str>,
10314 {
10315 self._scopes.insert(String::from(scope.as_ref()));
10316 self
10317 }
10318 /// Identifies the authorization scope(s) for the method you are building.
10319 ///
10320 /// See [`Self::add_scope()`] for details.
10321 pub fn add_scopes<I, St>(mut self, scopes: I) -> PersonUpdateContactPhotoCall<'a, C>
10322 where
10323 I: IntoIterator<Item = St>,
10324 St: AsRef<str>,
10325 {
10326 self._scopes
10327 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10328 self
10329 }
10330
10331 /// Removes all scopes, and no default scope will be used either.
10332 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10333 /// for details).
10334 pub fn clear_scopes(mut self) -> PersonUpdateContactPhotoCall<'a, C> {
10335 self._scopes.clear();
10336 self
10337 }
10338}