google_photoslibrary1/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, upload, and organize items in your Google Photos library
17 Full,
18
19 /// Add to your Google Photos library
20 Appendonly,
21
22 /// Edit the info in your photos, videos, and albums created within this app, including titles, descriptions, and covers
23 EditAppcreateddata,
24
25 /// View your Google Photos library
26 Readonly,
27
28 /// Manage photos added by this app
29 ReadonlyAppcreateddata,
30
31 /// Manage and add to shared albums on your behalf
32 Sharing,
33}
34
35impl AsRef<str> for Scope {
36 fn as_ref(&self) -> &str {
37 match *self {
38 Scope::Full => "https://www.googleapis.com/auth/photoslibrary",
39 Scope::Appendonly => "https://www.googleapis.com/auth/photoslibrary.appendonly",
40 Scope::EditAppcreateddata => {
41 "https://www.googleapis.com/auth/photoslibrary.edit.appcreateddata"
42 }
43 Scope::Readonly => "https://www.googleapis.com/auth/photoslibrary.readonly",
44 Scope::ReadonlyAppcreateddata => {
45 "https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata"
46 }
47 Scope::Sharing => "https://www.googleapis.com/auth/photoslibrary.sharing",
48 }
49 }
50}
51
52#[allow(clippy::derivable_impls)]
53impl Default for Scope {
54 fn default() -> Scope {
55 Scope::Readonly
56 }
57}
58
59// ########
60// HUB ###
61// ######
62
63/// Central instance to access all PhotosLibrary related resource activities
64///
65/// # Examples
66///
67/// Instantiate a new hub
68///
69/// ```test_harness,no_run
70/// extern crate hyper;
71/// extern crate hyper_rustls;
72/// extern crate google_photoslibrary1 as photoslibrary1;
73/// use photoslibrary1::{Result, Error};
74/// # async fn dox() {
75/// use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
76///
77/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
78/// // `client_secret`, among other things.
79/// let secret: yup_oauth2::ApplicationSecret = Default::default();
80/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
81/// // unless you replace `None` with the desired Flow.
82/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
83/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
84/// // retrieve them from storage.
85/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
86/// secret,
87/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
88/// ).build().await.unwrap();
89///
90/// let client = hyper_util::client::legacy::Client::builder(
91/// hyper_util::rt::TokioExecutor::new()
92/// )
93/// .build(
94/// hyper_rustls::HttpsConnectorBuilder::new()
95/// .with_native_roots()
96/// .unwrap()
97/// .https_or_http()
98/// .enable_http1()
99/// .build()
100/// );
101/// let mut hub = PhotosLibrary::new(client, auth);
102/// // You can configure optional parameters by calling the respective setters at will, and
103/// // execute the final call using `doit()`.
104/// // Values shown here are possibly random and not representative !
105/// let result = hub.albums().list()
106/// .page_token("amet.")
107/// .page_size(-59)
108/// .exclude_non_app_created_data(true)
109/// .doit().await;
110///
111/// match result {
112/// Err(e) => match e {
113/// // The Error enum provides details about what exactly happened.
114/// // You can also just use its `Debug`, `Display` or `Error` traits
115/// Error::HttpError(_)
116/// |Error::Io(_)
117/// |Error::MissingAPIKey
118/// |Error::MissingToken(_)
119/// |Error::Cancelled
120/// |Error::UploadSizeLimitExceeded(_, _)
121/// |Error::Failure(_)
122/// |Error::BadRequest(_)
123/// |Error::FieldClash(_)
124/// |Error::JsonDecodeError(_, _) => println!("{}", e),
125/// },
126/// Ok(res) => println!("Success: {:?}", res),
127/// }
128/// # }
129/// ```
130#[derive(Clone)]
131pub struct PhotosLibrary<C> {
132 pub client: common::Client<C>,
133 pub auth: Box<dyn common::GetToken>,
134 _user_agent: String,
135 _base_url: String,
136 _root_url: String,
137}
138
139impl<C> common::Hub for PhotosLibrary<C> {}
140
141impl<'a, C> PhotosLibrary<C> {
142 pub fn new<A: 'static + common::GetToken>(
143 client: common::Client<C>,
144 auth: A,
145 ) -> PhotosLibrary<C> {
146 PhotosLibrary {
147 client,
148 auth: Box::new(auth),
149 _user_agent: "google-api-rust-client/6.0.0".to_string(),
150 _base_url: "https://photoslibrary.googleapis.com/".to_string(),
151 _root_url: "https://photoslibrary.googleapis.com/".to_string(),
152 }
153 }
154
155 pub fn albums(&'a self) -> AlbumMethods<'a, C> {
156 AlbumMethods { hub: self }
157 }
158 pub fn media_items(&'a self) -> MediaItemMethods<'a, C> {
159 MediaItemMethods { hub: self }
160 }
161 pub fn shared_albums(&'a self) -> SharedAlbumMethods<'a, C> {
162 SharedAlbumMethods { hub: self }
163 }
164
165 /// Set the user-agent header field to use in all requests to the server.
166 /// It defaults to `google-api-rust-client/6.0.0`.
167 ///
168 /// Returns the previously set user-agent.
169 pub fn user_agent(&mut self, agent_name: String) -> String {
170 std::mem::replace(&mut self._user_agent, agent_name)
171 }
172
173 /// Set the base url to use in all requests to the server.
174 /// It defaults to `https://photoslibrary.googleapis.com/`.
175 ///
176 /// Returns the previously set base url.
177 pub fn base_url(&mut self, new_base_url: String) -> String {
178 std::mem::replace(&mut self._base_url, new_base_url)
179 }
180
181 /// Set the root url to use in all requests to the server.
182 /// It defaults to `https://photoslibrary.googleapis.com/`.
183 ///
184 /// Returns the previously set root url.
185 pub fn root_url(&mut self, new_root_url: String) -> String {
186 std::mem::replace(&mut self._root_url, new_root_url)
187 }
188}
189
190// ############
191// SCHEMAS ###
192// ##########
193/// Request to add an enrichment to a specific album at a specific position.
194///
195/// # Activities
196///
197/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
198/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
199///
200/// * [add enrichment albums](AlbumAddEnrichmentCall) (request)
201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
202#[serde_with::serde_as]
203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
204pub struct AddEnrichmentToAlbumRequest {
205 /// Required. The position in the album where the enrichment is to be inserted.
206 #[serde(rename = "albumPosition")]
207 pub album_position: Option<AlbumPosition>,
208 /// Required. The enrichment to be added.
209 #[serde(rename = "newEnrichmentItem")]
210 pub new_enrichment_item: Option<NewEnrichmentItem>,
211}
212
213impl common::RequestValue for AddEnrichmentToAlbumRequest {}
214
215/// The enrichment item that’s created.
216///
217/// # Activities
218///
219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
221///
222/// * [add enrichment albums](AlbumAddEnrichmentCall) (response)
223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
224#[serde_with::serde_as]
225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
226pub struct AddEnrichmentToAlbumResponse {
227 /// Output only. Enrichment which was added.
228 #[serde(rename = "enrichmentItem")]
229 pub enrichment_item: Option<EnrichmentItem>,
230}
231
232impl common::ResponseResult for AddEnrichmentToAlbumResponse {}
233
234/// Representation of an album in Google Photos. Albums are containers for media items. If an album has been shared by the application, it contains an extra `shareInfo` property.
235///
236/// # Activities
237///
238/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
239/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
240///
241/// * [add enrichment albums](AlbumAddEnrichmentCall) (none)
242/// * [batch add media items albums](AlbumBatchAddMediaItemCall) (none)
243/// * [batch remove media items albums](AlbumBatchRemoveMediaItemCall) (none)
244/// * [create albums](AlbumCreateCall) (response)
245/// * [get albums](AlbumGetCall) (response)
246/// * [list albums](AlbumListCall) (none)
247/// * [patch albums](AlbumPatchCall) (request|response)
248/// * [share albums](AlbumShareCall) (none)
249/// * [unshare albums](AlbumUnshareCall) (none)
250/// * [get shared albums](SharedAlbumGetCall) (response)
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct Album {
255 /// [Output only] A URL to the cover photo's bytes. This shouldn't be used as is. Parameters should be appended to this URL before use. See the [developer documentation](https://developers.google.com/photos/library/guides/access-media-items#base-urls) for a complete list of supported parameters. For example, `'=w2048-h1024'` sets the dimensions of the cover photo to have a width of 2048 px and height of 1024 px.
256 #[serde(rename = "coverPhotoBaseUrl")]
257 pub cover_photo_base_url: Option<String>,
258 /// Identifier for the media item associated with the cover photo.
259 #[serde(rename = "coverPhotoMediaItemId")]
260 pub cover_photo_media_item_id: Option<String>,
261 /// Identifier for the album. This is a persistent identifier that can be used between sessions to identify this album.
262 pub id: Option<String>,
263 /// [Output only] True if you can create media items in this album. This field is based on the scopes granted and permissions of the album. If the scopes are changed or permissions of the album are changed, this field is updated.
264 #[serde(rename = "isWriteable")]
265 pub is_writeable: Option<bool>,
266 /// [Output only] The number of media items in the album.
267 #[serde(rename = "mediaItemsCount")]
268 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
269 pub media_items_count: Option<i64>,
270 /// [Output only] Google Photos URL for the album. The user needs to be signed in to their Google Photos account to access this link.
271 #[serde(rename = "productUrl")]
272 pub product_url: Option<String>,
273 /// [Output only] Information related to shared albums. This field is only populated if the album is a shared album, the developer created the album and the user has granted the `photoslibrary.sharing` scope.
274 #[serde(rename = "shareInfo")]
275 pub share_info: Option<ShareInfo>,
276 /// Name of the album displayed to the user in their Google Photos account. This string shouldn't be more than 500 characters.
277 pub title: Option<String>,
278}
279
280impl common::RequestValue for Album {}
281impl common::Resource for Album {}
282impl common::ResponseResult for Album {}
283
284/// Specifies a position in an album.
285///
286/// This type is not used in any activity, and only used as *part* of another schema.
287///
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as]
290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
291pub struct AlbumPosition {
292 /// Type of position, for a media or enrichment item.
293 pub position: Option<String>,
294 /// The enrichment item to which the position is relative to. Only used when position type is AFTER_ENRICHMENT_ITEM.
295 #[serde(rename = "relativeEnrichmentItemId")]
296 pub relative_enrichment_item_id: Option<String>,
297 /// The media item to which the position is relative to. Only used when position type is AFTER_MEDIA_ITEM.
298 #[serde(rename = "relativeMediaItemId")]
299 pub relative_media_item_id: Option<String>,
300}
301
302impl common::Part for AlbumPosition {}
303
304/// Request to add media items to an album.
305///
306/// # Activities
307///
308/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
309/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
310///
311/// * [batch add media items albums](AlbumBatchAddMediaItemCall) (request)
312#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
313#[serde_with::serde_as]
314#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
315pub struct BatchAddMediaItemsToAlbumRequest {
316 /// Required. Identifiers of the MediaItems to be added. The maximum number of media items that can be added in one call is 50.
317 #[serde(rename = "mediaItemIds")]
318 pub media_item_ids: Option<Vec<String>>,
319}
320
321impl common::RequestValue for BatchAddMediaItemsToAlbumRequest {}
322
323/// Response for adding media items to an album.
324///
325/// # Activities
326///
327/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
328/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
329///
330/// * [batch add media items albums](AlbumBatchAddMediaItemCall) (response)
331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
332#[serde_with::serde_as]
333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
334pub struct BatchAddMediaItemsToAlbumResponse {
335 _never_set: Option<bool>,
336}
337
338impl common::ResponseResult for BatchAddMediaItemsToAlbumResponse {}
339
340/// Request to create one or more media items in a user’s Google Photos library. If an `albumid` is specified, the media items are also added to that album. `albumPosition` is optional and can only be specified if an `albumId` is set.
341///
342/// # Activities
343///
344/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
345/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
346///
347/// * [batch create media items](MediaItemBatchCreateCall) (request)
348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
349#[serde_with::serde_as]
350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
351pub struct BatchCreateMediaItemsRequest {
352 /// Identifier of the album where the media items are added. The media items are also added to the user's library. This is an optional field.
353 #[serde(rename = "albumId")]
354 pub album_id: Option<String>,
355 /// Position in the album where the media items are added. If not specified, the media items are added to the end of the album (as per the default value, that is, `LAST_IN_ALBUM`). The request fails if this field is set and the `albumId` is not specified. The request will also fail if you set the field and are not the owner of the shared album.
356 #[serde(rename = "albumPosition")]
357 pub album_position: Option<AlbumPosition>,
358 /// Required. List of media items to be created. Maximum 50 media items per call.
359 #[serde(rename = "newMediaItems")]
360 pub new_media_items: Option<Vec<NewMediaItem>>,
361}
362
363impl common::RequestValue for BatchCreateMediaItemsRequest {}
364
365/// List of media items created.
366///
367/// # Activities
368///
369/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
370/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
371///
372/// * [batch create media items](MediaItemBatchCreateCall) (response)
373#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
374#[serde_with::serde_as]
375#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
376pub struct BatchCreateMediaItemsResponse {
377 /// Output only. List of media items created.
378 #[serde(rename = "newMediaItemResults")]
379 pub new_media_item_results: Option<Vec<NewMediaItemResult>>,
380}
381
382impl common::ResponseResult for BatchCreateMediaItemsResponse {}
383
384/// Response to retrieve a list of media items.
385///
386/// # Activities
387///
388/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
389/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
390///
391/// * [batch get media items](MediaItemBatchGetCall) (response)
392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
393#[serde_with::serde_as]
394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
395pub struct BatchGetMediaItemsResponse {
396 /// Output only. List of media items retrieved. Note that even if the call to BatchGetMediaItems succeeds, there may have been failures for some media items in the batch. These failures are indicated in each MediaItemResult.status.
397 #[serde(rename = "mediaItemResults")]
398 pub media_item_results: Option<Vec<MediaItemResult>>,
399}
400
401impl common::ResponseResult for BatchGetMediaItemsResponse {}
402
403/// Request to remove a list of media items from an album.
404///
405/// # Activities
406///
407/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
408/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
409///
410/// * [batch remove media items albums](AlbumBatchRemoveMediaItemCall) (request)
411#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
412#[serde_with::serde_as]
413#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
414pub struct BatchRemoveMediaItemsFromAlbumRequest {
415 /// Required. Identifiers of the MediaItems to be removed. Must not contain repeated identifiers and cannot be empty. The maximum number of media items that can be removed in one call is 50.
416 #[serde(rename = "mediaItemIds")]
417 pub media_item_ids: Option<Vec<String>>,
418}
419
420impl common::RequestValue for BatchRemoveMediaItemsFromAlbumRequest {}
421
422/// Response for successfully removing all specified media items from the album.
423///
424/// # Activities
425///
426/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
427/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
428///
429/// * [batch remove media items albums](AlbumBatchRemoveMediaItemCall) (response)
430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
431#[serde_with::serde_as]
432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
433pub struct BatchRemoveMediaItemsFromAlbumResponse {
434 _never_set: Option<bool>,
435}
436
437impl common::ResponseResult for BatchRemoveMediaItemsFromAlbumResponse {}
438
439/// This filter allows you to return media items based on the content type. It's possible to specify a list of categories to include, and/or a list of categories to exclude. Within each list, the categories are combined with an OR. The content filter `includedContentCategories`: [c1, c2, c3] would get media items that contain (c1 OR c2 OR c3). The content filter `excludedContentCategories`: [c1, c2, c3] would NOT get media items that contain (c1 OR c2 OR c3). You can also include some categories while excluding others, as in this example: `includedContentCategories`: [c1, c2], `excludedContentCategories`: [c3, c4] The previous example would get media items that contain (c1 OR c2) AND NOT (c3 OR c4). A category that appears in `includedContentategories` must not appear in `excludedContentCategories`.
440///
441/// This type is not used in any activity, and only used as *part* of another schema.
442///
443#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
444#[serde_with::serde_as]
445#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
446pub struct ContentFilter {
447 /// The set of categories which are not to be included in the media item search results. The items in the set are ORed. There's a maximum of 10 `excludedContentCategories` per request.
448 #[serde(rename = "excludedContentCategories")]
449 pub excluded_content_categories: Option<Vec<String>>,
450 /// The set of categories to be included in the media item search results. The items in the set are ORed. There's a maximum of 10 `includedContentCategories` per request.
451 #[serde(rename = "includedContentCategories")]
452 pub included_content_categories: Option<Vec<String>>,
453}
454
455impl common::Part for ContentFilter {}
456
457/// Information about the user who added the media item. Note that this information is included only if the media item is within a shared album created by your app and you have the sharing scope.
458///
459/// This type is not used in any activity, and only used as *part* of another schema.
460///
461#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
462#[serde_with::serde_as]
463#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
464pub struct ContributorInfo {
465 /// Display name of the contributor.
466 #[serde(rename = "displayName")]
467 pub display_name: Option<String>,
468 /// URL to the profile picture of the contributor.
469 #[serde(rename = "profilePictureBaseUrl")]
470 pub profile_picture_base_url: Option<String>,
471}
472
473impl common::Part for ContributorInfo {}
474
475/// Request to create an album in Google Photos.
476///
477/// # Activities
478///
479/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
480/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
481///
482/// * [create albums](AlbumCreateCall) (request)
483#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
484#[serde_with::serde_as]
485#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
486pub struct CreateAlbumRequest {
487 /// Required. The album to be created.
488 pub album: Option<Album>,
489}
490
491impl common::RequestValue for CreateAlbumRequest {}
492
493/// Represents a whole calendar date. Set `day` to 0 when only the month and year are significant, for example, all of December 2018. Set `day` and `month` to 0 if only the year is significant, for example, the entire of 2018. Set `year` to 0 when only the day and month are significant, for example, an anniversary or birthday. Unsupported: Setting all values to 0, only `month` to 0, or both `day` and `year` to 0 at the same time.
494///
495/// This type is not used in any activity, and only used as *part* of another schema.
496///
497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
498#[serde_with::serde_as]
499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
500pub struct Date {
501 /// Day of month. Must be from 1 to 31 and valid for the year and month, or 0 if specifying a year/month where the day isn't significant.
502 pub day: Option<i32>,
503 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
504 pub month: Option<i32>,
505 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
506 pub year: Option<i32>,
507}
508
509impl common::Part for Date {}
510
511/// This filter defines the allowed dates or date ranges for the media returned. It's possible to pick a set of specific dates and a set of date ranges. Media items uploaded without metadata specifying the date the media item was captured will not be returned in queries using date filters. Google Photos server upload time is not used as a fallback in this case.
512///
513/// This type is not used in any activity, and only used as *part* of another schema.
514///
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct DateFilter {
519 /// List of dates that match the media items' creation date. A maximum of 5 dates can be included per request.
520 pub dates: Option<Vec<Date>>,
521 /// List of dates ranges that match the media items' creation date. A maximum of 5 dates ranges can be included per request.
522 pub ranges: Option<Vec<DateRange>>,
523}
524
525impl common::Part for DateFilter {}
526
527/// Defines a range of dates. Both dates must be of the same format. For more information, see Date.
528///
529/// This type is not used in any activity, and only used as *part* of another schema.
530///
531#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
532#[serde_with::serde_as]
533#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
534pub struct DateRange {
535 /// The end date (included as part of the range). It must be specified in the same format as the start date.
536 #[serde(rename = "endDate")]
537 pub end_date: Option<Date>,
538 /// The start date (included as part of the range) in one of the formats described.
539 #[serde(rename = "startDate")]
540 pub start_date: Option<Date>,
541}
542
543impl common::Part for DateRange {}
544
545/// An enrichment item.
546///
547/// This type is not used in any activity, and only used as *part* of another schema.
548///
549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
550#[serde_with::serde_as]
551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
552pub struct EnrichmentItem {
553 /// Identifier of the enrichment item.
554 pub id: Option<String>,
555}
556
557impl common::Part for EnrichmentItem {}
558
559/// This filter defines the features that the media items should have.
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 FeatureFilter {
567 /// The set of features to be included in the media item search results. The items in the set are ORed and may match any of the specified features.
568 #[serde(rename = "includedFeatures")]
569 pub included_features: Option<Vec<String>>,
570}
571
572impl common::Part for FeatureFilter {}
573
574/// Filters that can be applied to a media item search. If multiple filter options are specified, they're treated as AND with each other.
575///
576/// This type is not used in any activity, and only used as *part* of another schema.
577///
578#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
579#[serde_with::serde_as]
580#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
581pub struct Filters {
582 /// Filters the media items based on their content.
583 #[serde(rename = "contentFilter")]
584 pub content_filter: Option<ContentFilter>,
585 /// Filters the media items based on their creation date.
586 #[serde(rename = "dateFilter")]
587 pub date_filter: Option<DateFilter>,
588 /// If set, the results exclude media items that were not created by this app. Defaults to false (all media items are returned). This field is ignored if the photoslibrary.readonly.appcreateddata scope is used.
589 #[serde(rename = "excludeNonAppCreatedData")]
590 pub exclude_non_app_created_data: Option<bool>,
591 /// Filters the media items based on their features.
592 #[serde(rename = "featureFilter")]
593 pub feature_filter: Option<FeatureFilter>,
594 /// If set, the results include media items that the user has archived. Defaults to false (archived media items aren't included).
595 #[serde(rename = "includeArchivedMedia")]
596 pub include_archived_media: Option<bool>,
597 /// Filters the media items based on the type of media.
598 #[serde(rename = "mediaTypeFilter")]
599 pub media_type_filter: Option<MediaTypeFilter>,
600}
601
602impl common::Part for Filters {}
603
604/// Request to join a shared album on behalf of the user. This uses a shareToken which can be acquired via the shareAlbum or listSharedAlbums calls.
605///
606/// # Activities
607///
608/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
609/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
610///
611/// * [join shared albums](SharedAlbumJoinCall) (request)
612#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
613#[serde_with::serde_as]
614#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
615pub struct JoinSharedAlbumRequest {
616 /// Required. Token to join the shared album on behalf of the user.
617 #[serde(rename = "shareToken")]
618 pub share_token: Option<String>,
619}
620
621impl common::RequestValue for JoinSharedAlbumRequest {}
622
623/// Response to successfully joining the shared album on behalf of the user.
624///
625/// # Activities
626///
627/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
628/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
629///
630/// * [join shared albums](SharedAlbumJoinCall) (response)
631#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
632#[serde_with::serde_as]
633#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
634pub struct JoinSharedAlbumResponse {
635 /// Shared album that the user has joined.
636 pub album: Option<Album>,
637}
638
639impl common::ResponseResult for JoinSharedAlbumResponse {}
640
641/// An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
642///
643/// This type is not used in any activity, and only used as *part* of another schema.
644///
645#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
646#[serde_with::serde_as]
647#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
648pub struct LatLng {
649 /// The latitude in degrees. It must be in the range [-90.0, +90.0].
650 pub latitude: Option<f64>,
651 /// The longitude in degrees. It must be in the range [-180.0, +180.0].
652 pub longitude: Option<f64>,
653}
654
655impl common::Part for LatLng {}
656
657/// Request to leave a shared album on behalf of the user. This uses a shareToken which can be acquired via the or listSharedAlbums or getAlbum calls.
658///
659/// # Activities
660///
661/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
662/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
663///
664/// * [leave shared albums](SharedAlbumLeaveCall) (request)
665#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
666#[serde_with::serde_as]
667#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
668pub struct LeaveSharedAlbumRequest {
669 /// Required. Token to leave the shared album on behalf of the user.
670 #[serde(rename = "shareToken")]
671 pub share_token: Option<String>,
672}
673
674impl common::RequestValue for LeaveSharedAlbumRequest {}
675
676/// Response to successfully leaving the shared album on behalf of the user.
677///
678/// # Activities
679///
680/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
681/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
682///
683/// * [leave shared albums](SharedAlbumLeaveCall) (response)
684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
685#[serde_with::serde_as]
686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
687pub struct LeaveSharedAlbumResponse {
688 _never_set: Option<bool>,
689}
690
691impl common::ResponseResult for LeaveSharedAlbumResponse {}
692
693/// List of albums requested.
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/// * [list albums](AlbumListCall) (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 ListAlbumsResponse {
705 /// Output only. List of albums shown in the Albums tab of the user's Google Photos app.
706 pub albums: Option<Vec<Album>>,
707 /// Output only. Token to use to get the next set of albums. Populated if there are more albums to retrieve for this request.
708 #[serde(rename = "nextPageToken")]
709 pub next_page_token: Option<String>,
710}
711
712impl common::ResponseResult for ListAlbumsResponse {}
713
714/// List of all media items from the user’s Google Photos library.
715///
716/// # Activities
717///
718/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
719/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
720///
721/// * [list media items](MediaItemListCall) (response)
722#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
723#[serde_with::serde_as]
724#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
725pub struct ListMediaItemsResponse {
726 /// Output only. List of media items in the user's library.
727 #[serde(rename = "mediaItems")]
728 pub media_items: Option<Vec<MediaItem>>,
729 /// Output only. Token to use to get the next set of media items. Its presence is the only reliable indicator of more media items being available in the next request.
730 #[serde(rename = "nextPageToken")]
731 pub next_page_token: Option<String>,
732}
733
734impl common::ResponseResult for ListMediaItemsResponse {}
735
736/// List of shared albums requested.
737///
738/// # Activities
739///
740/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
741/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
742///
743/// * [list shared albums](SharedAlbumListCall) (response)
744#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
745#[serde_with::serde_as]
746#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
747pub struct ListSharedAlbumsResponse {
748 /// Output only. Token to use to get the next set of shared albums. Populated if there are more shared albums to retrieve for this request.
749 #[serde(rename = "nextPageToken")]
750 pub next_page_token: Option<String>,
751 /// Output only. List of shared albums.
752 #[serde(rename = "sharedAlbums")]
753 pub shared_albums: Option<Vec<Album>>,
754}
755
756impl common::ResponseResult for ListSharedAlbumsResponse {}
757
758/// Represents a physical location.
759///
760/// This type is not used in any activity, and only used as *part* of another schema.
761///
762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
763#[serde_with::serde_as]
764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
765pub struct Location {
766 /// Position of the location on the map.
767 pub latlng: Option<LatLng>,
768 /// Name of the location to be displayed.
769 #[serde(rename = "locationName")]
770 pub location_name: Option<String>,
771}
772
773impl common::Part for Location {}
774
775/// An enrichment containing a single location.
776///
777/// This type is not used in any activity, and only used as *part* of another schema.
778///
779#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
780#[serde_with::serde_as]
781#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
782pub struct LocationEnrichment {
783 /// Location for this enrichment item.
784 pub location: Option<Location>,
785}
786
787impl common::Part for LocationEnrichment {}
788
789/// An enrichment containing a map, showing origin and destination locations.
790///
791/// This type is not used in any activity, and only used as *part* of another schema.
792///
793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
794#[serde_with::serde_as]
795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
796pub struct MapEnrichment {
797 /// Destination location for this enrichemt item.
798 pub destination: Option<Location>,
799 /// Origin location for this enrichment item.
800 pub origin: Option<Location>,
801}
802
803impl common::Part for MapEnrichment {}
804
805/// Representation of a media item (such as a photo or video) in Google Photos.
806///
807/// # Activities
808///
809/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
810/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
811///
812/// * [batch create media items](MediaItemBatchCreateCall) (none)
813/// * [batch get media items](MediaItemBatchGetCall) (none)
814/// * [get media items](MediaItemGetCall) (response)
815/// * [list media items](MediaItemListCall) (none)
816/// * [patch media items](MediaItemPatchCall) (request|response)
817/// * [search media items](MediaItemSearchCall) (none)
818#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
819#[serde_with::serde_as]
820#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
821pub struct MediaItem {
822 /// A URL to the media item's bytes. This shouldn't be used as is. Parameters should be appended to this URL before use. See the [developer documentation](https://developers.google.com/photos/library/guides/access-media-items#base-urls) for a complete list of supported parameters. For example, `'=w2048-h1024'` will set the dimensions of a media item of type photo to have a width of 2048 px and height of 1024 px.
823 #[serde(rename = "baseUrl")]
824 pub base_url: Option<String>,
825 /// Information about the user who added this media item. Note that this is only included when using mediaItems.search with the ID of a shared album. The album must be created by your app and you must have the sharing scope.
826 #[serde(rename = "contributorInfo")]
827 pub contributor_info: Option<ContributorInfo>,
828 /// Description of the media item. This is shown to the user in the item's info section in the Google Photos app. Must be shorter than 1000 characters. Only include text written by users. Descriptions should add context and help users understand media. Do not include any auto-generated strings such as filenames, tags, and other metadata.
829 pub description: Option<String>,
830 /// Filename of the media item. This is shown to the user in the item's info section in the Google Photos app.
831 pub filename: Option<String>,
832 /// Identifier for the media item. This is a persistent identifier that can be used between sessions to identify this media item.
833 pub id: Option<String>,
834 /// Metadata related to the media item, such as, height, width, or creation time.
835 #[serde(rename = "mediaMetadata")]
836 pub media_metadata: Option<MediaMetadata>,
837 /// MIME type of the media item. For example, `image/jpeg`.
838 #[serde(rename = "mimeType")]
839 pub mime_type: Option<String>,
840 /// Google Photos URL for the media item. This link is available to the user only if they're signed in. When retrieved from an album search, the URL points to the item inside the album.
841 #[serde(rename = "productUrl")]
842 pub product_url: Option<String>,
843}
844
845impl common::RequestValue for MediaItem {}
846impl common::Resource for MediaItem {}
847impl common::ResponseResult for MediaItem {}
848
849/// Result of retrieving a media item.
850///
851/// This type is not used in any activity, and only used as *part* of another schema.
852///
853#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
854#[serde_with::serde_as]
855#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
856pub struct MediaItemResult {
857 /// Media item retrieved from the user's library. It's populated if no errors occurred and the media item was fetched successfully.
858 #[serde(rename = "mediaItem")]
859 pub media_item: Option<MediaItem>,
860 /// If an error occurred while accessing this media item, this field is populated with information related to the error. For details regarding this field, see Status.
861 pub status: Option<Status>,
862}
863
864impl common::Part for MediaItemResult {}
865
866/// Metadata for a media item.
867///
868/// This type is not used in any activity, and only used as *part* of another schema.
869///
870#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
871#[serde_with::serde_as]
872#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
873pub struct MediaMetadata {
874 /// Time when the media item was first created (not when it was uploaded to Google Photos).
875 #[serde(rename = "creationTime")]
876 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
877 /// Original height (in pixels) of the media item.
878 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
879 pub height: Option<i64>,
880 /// Metadata for a photo media type.
881 pub photo: Option<Photo>,
882 /// Metadata for a video media type.
883 pub video: Option<Video>,
884 /// Original width (in pixels) of the media item.
885 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
886 pub width: Option<i64>,
887}
888
889impl common::Part for MediaMetadata {}
890
891/// This filter defines the type of media items to be returned, for example, videos or photos. Only one media type is supported.
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 MediaTypeFilter {
899 /// The types of media items to be included. This field should be populated with only one media type. If you specify multiple media types, it results in an error.
900 #[serde(rename = "mediaTypes")]
901 pub media_types: Option<Vec<String>>,
902}
903
904impl common::Part for MediaTypeFilter {}
905
906/// A new enrichment item to be added to an album, used by the `albums.addEnrichment` call.
907///
908/// This type is not used in any activity, and only used as *part* of another schema.
909///
910#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
911#[serde_with::serde_as]
912#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
913pub struct NewEnrichmentItem {
914 /// Location to be added to the album.
915 #[serde(rename = "locationEnrichment")]
916 pub location_enrichment: Option<LocationEnrichment>,
917 /// Map to be added to the album.
918 #[serde(rename = "mapEnrichment")]
919 pub map_enrichment: Option<MapEnrichment>,
920 /// Text to be added to the album.
921 #[serde(rename = "textEnrichment")]
922 pub text_enrichment: Option<TextEnrichment>,
923}
924
925impl common::Part for NewEnrichmentItem {}
926
927/// New media item that's created in a user's Google Photos account.
928///
929/// This type is not used in any activity, and only used as *part* of another schema.
930///
931#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
932#[serde_with::serde_as]
933#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
934pub struct NewMediaItem {
935 /// Description of the media item. This is shown to the user in the item's info section in the Google Photos app. Must be shorter than 1000 characters. Only include text written by users. Descriptions should add context and help users understand media. Do not include any auto-generated strings such as filenames, tags, and other metadata.
936 pub description: Option<String>,
937 /// A new media item that has been uploaded via the included `uploadToken`.
938 #[serde(rename = "simpleMediaItem")]
939 pub simple_media_item: Option<SimpleMediaItem>,
940}
941
942impl common::Part for NewMediaItem {}
943
944/// Result of creating a new media item.
945///
946/// This type is not used in any activity, and only used as *part* of another schema.
947///
948#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
949#[serde_with::serde_as]
950#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
951pub struct NewMediaItemResult {
952 /// Media item created with the upload token. It's populated if no errors occurred and the media item was created successfully.
953 #[serde(rename = "mediaItem")]
954 pub media_item: Option<MediaItem>,
955 /// If an error occurred during the creation of this media item, this field is populated with information related to the error. For details regarding this field, see Status.
956 pub status: Option<Status>,
957 /// The upload token used to create this new (simple) media item. Only populated if the media item is simple and required a single upload token.
958 #[serde(rename = "uploadToken")]
959 pub upload_token: Option<String>,
960}
961
962impl common::Part for NewMediaItemResult {}
963
964/// Metadata that is specific to a photo, such as, ISO, focal length and exposure time. Some of these fields may be null or not included.
965///
966/// This type is not used in any activity, and only used as *part* of another schema.
967///
968#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
969#[serde_with::serde_as]
970#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
971pub struct Photo {
972 /// Aperture f number of the camera lens with which the photo was taken.
973 #[serde(rename = "apertureFNumber")]
974 pub aperture_f_number: Option<f32>,
975 /// Brand of the camera with which the photo was taken.
976 #[serde(rename = "cameraMake")]
977 pub camera_make: Option<String>,
978 /// Model of the camera with which the photo was taken.
979 #[serde(rename = "cameraModel")]
980 pub camera_model: Option<String>,
981 /// Exposure time of the camera aperture when the photo was taken.
982 #[serde(rename = "exposureTime")]
983 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
984 pub exposure_time: Option<chrono::Duration>,
985 /// Focal length of the camera lens with which the photo was taken.
986 #[serde(rename = "focalLength")]
987 pub focal_length: Option<f32>,
988 /// ISO of the camera with which the photo was taken.
989 #[serde(rename = "isoEquivalent")]
990 pub iso_equivalent: Option<i32>,
991}
992
993impl common::Part for Photo {}
994
995/// Request to search for media items in a user’s library. If the album id is specified, this call will return the list of media items in the album. If neither filters nor album id are specified, this call will return all media items in a user’s Google Photos library. If filters are specified, this call will return all media items in the user’s library that fulfill the filter criteria. Filters and album id must not both be set, as this will result in an invalid request.
996///
997/// # Activities
998///
999/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1000/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1001///
1002/// * [search media items](MediaItemSearchCall) (request)
1003#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1004#[serde_with::serde_as]
1005#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1006pub struct SearchMediaItemsRequest {
1007 /// Identifier of an album. If populated, lists all media items in specified album. Can't set in conjunction with any filters.
1008 #[serde(rename = "albumId")]
1009 pub album_id: Option<String>,
1010 /// Filters to apply to the request. Can't be set in conjunction with an `albumId`.
1011 pub filters: Option<Filters>,
1012 /// An optional field to specify the sort order of the search results. The `orderBy` field only works when a dateFilter is used. When this field is not specified, results are displayed newest first, oldest last by their creationTime. Providing `MediaMetadata.creation_time` displays search results in the opposite order, oldest first then newest last. To display results newest first then oldest last, include the `desc` argument as follows: `MediaMetadata.creation_time desc`. The only additional filters that can be used with this parameter are includeArchivedMedia and excludeNonAppCreatedData. No other filters are supported.
1013 #[serde(rename = "orderBy")]
1014 pub order_by: Option<String>,
1015 /// Maximum number of media items to return in the response. Fewer media items might be returned than the specified number. The default `pageSize` is 25, the maximum is 100.
1016 #[serde(rename = "pageSize")]
1017 pub page_size: Option<i32>,
1018 /// A continuation token to get the next page of the results. Adding this to the request returns the rows after the `pageToken`. The `pageToken` should be the value returned in the `nextPageToken` parameter in the response to the `searchMediaItems` request.
1019 #[serde(rename = "pageToken")]
1020 pub page_token: Option<String>,
1021}
1022
1023impl common::RequestValue for SearchMediaItemsRequest {}
1024
1025/// List of media items that match the search parameters.
1026///
1027/// # Activities
1028///
1029/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1030/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1031///
1032/// * [search media items](MediaItemSearchCall) (response)
1033#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1034#[serde_with::serde_as]
1035#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1036pub struct SearchMediaItemsResponse {
1037 /// Output only. List of media items that match the search parameters.
1038 #[serde(rename = "mediaItems")]
1039 pub media_items: Option<Vec<MediaItem>>,
1040 /// Output only. Use this token to get the next set of media items. Its presence is the only reliable indicator of more media items being available in the next request.
1041 #[serde(rename = "nextPageToken")]
1042 pub next_page_token: Option<String>,
1043}
1044
1045impl common::ResponseResult for SearchMediaItemsResponse {}
1046
1047/// Request to make an album shared in Google Photos.
1048///
1049/// # Activities
1050///
1051/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1052/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1053///
1054/// * [share albums](AlbumShareCall) (request)
1055#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1056#[serde_with::serde_as]
1057#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1058pub struct ShareAlbumRequest {
1059 /// Options to be set when converting the album to a shared album.
1060 #[serde(rename = "sharedAlbumOptions")]
1061 pub shared_album_options: Option<SharedAlbumOptions>,
1062}
1063
1064impl common::RequestValue for ShareAlbumRequest {}
1065
1066/// Response to successfully sharing an album.
1067///
1068/// # Activities
1069///
1070/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1071/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1072///
1073/// * [share albums](AlbumShareCall) (response)
1074#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1075#[serde_with::serde_as]
1076#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1077pub struct ShareAlbumResponse {
1078 /// Output only. Information about the shared album.
1079 #[serde(rename = "shareInfo")]
1080 pub share_info: Option<ShareInfo>,
1081}
1082
1083impl common::ResponseResult for ShareAlbumResponse {}
1084
1085/// Information about albums that are shared. This information is only included if you created the album, it is shared and you have the sharing scope.
1086///
1087/// This type is not used in any activity, and only used as *part* of another schema.
1088///
1089#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1090#[serde_with::serde_as]
1091#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1092pub struct ShareInfo {
1093 /// True if the album can be joined by users.
1094 #[serde(rename = "isJoinable")]
1095 pub is_joinable: Option<bool>,
1096 /// True if the user is joined to the album. This is always true for the owner of the album.
1097 #[serde(rename = "isJoined")]
1098 pub is_joined: Option<bool>,
1099 /// True if the user owns the album.
1100 #[serde(rename = "isOwned")]
1101 pub is_owned: Option<bool>,
1102 /// A token that is used to join, leave, or retrieve the details of a shared album on behalf of a user who isn't the owner. A `shareToken` is invalidated if the owner turns off link sharing in the Google Photos app, or if the album is unshared.
1103 #[serde(rename = "shareToken")]
1104 pub share_token: Option<String>,
1105 /// A link to the shared Google Photos album. Anyone with the link can view the contents of the album, so it should be treated with care. The `shareableUrl` parameter is only returned if the album has link sharing turned on. If a user is already joined to an album that isn't link-shared, they can use the album's [`productUrl`](https://developers.google.com/photos/library/reference/rest/v1/albums#Album) to access it instead. A `shareableUrl` is invalidated if the owner turns off link sharing in the Google Photos app, or if the album is unshared.
1106 #[serde(rename = "shareableUrl")]
1107 pub shareable_url: Option<String>,
1108 /// Options that control whether someone can add media items to, or comment on a shared album.
1109 #[serde(rename = "sharedAlbumOptions")]
1110 pub shared_album_options: Option<SharedAlbumOptions>,
1111}
1112
1113impl common::Part for ShareInfo {}
1114
1115/// Options that control the sharing of an album.
1116///
1117/// This type is not used in any activity, and only used as *part* of another schema.
1118///
1119#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1120#[serde_with::serde_as]
1121#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1122pub struct SharedAlbumOptions {
1123 /// True if the shared album allows collaborators (users who have joined the album) to add media items to it. Defaults to false.
1124 #[serde(rename = "isCollaborative")]
1125 pub is_collaborative: Option<bool>,
1126 /// True if the shared album allows collaborators (users who have joined the album) to add comments to the album. Defaults to false.
1127 #[serde(rename = "isCommentable")]
1128 pub is_commentable: Option<bool>,
1129}
1130
1131impl common::Part for SharedAlbumOptions {}
1132
1133/// A simple media item to be created in Google Photos via an upload token.
1134///
1135/// This type is not used in any activity, and only used as *part* of another schema.
1136///
1137#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1138#[serde_with::serde_as]
1139#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1140pub struct SimpleMediaItem {
1141 /// File name with extension of the media item. This is shown to the user in Google Photos. The file name specified during the byte upload process is ignored if this field is set. The file name, including the file extension, shouldn't be more than 255 characters. This is an optional field.
1142 #[serde(rename = "fileName")]
1143 pub file_name: Option<String>,
1144 /// Token identifying the media bytes that have been uploaded to Google.
1145 #[serde(rename = "uploadToken")]
1146 pub upload_token: Option<String>,
1147}
1148
1149impl common::Part for SimpleMediaItem {}
1150
1151/// 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).
1152///
1153/// This type is not used in any activity, and only used as *part* of another schema.
1154///
1155#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1156#[serde_with::serde_as]
1157#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1158pub struct Status {
1159 /// The status code, which should be an enum value of google.rpc.Code.
1160 pub code: Option<i32>,
1161 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1162 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1163 /// 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.
1164 pub message: Option<String>,
1165}
1166
1167impl common::Part for Status {}
1168
1169/// An enrichment containing text.
1170///
1171/// This type is not used in any activity, and only used as *part* of another schema.
1172///
1173#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1174#[serde_with::serde_as]
1175#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1176pub struct TextEnrichment {
1177 /// Text for this enrichment item.
1178 pub text: Option<String>,
1179}
1180
1181impl common::Part for TextEnrichment {}
1182
1183/// Request to unshare a shared album in Google Photos.
1184///
1185/// # Activities
1186///
1187/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1188/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1189///
1190/// * [unshare albums](AlbumUnshareCall) (request)
1191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1192#[serde_with::serde_as]
1193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1194pub struct UnshareAlbumRequest {
1195 _never_set: Option<bool>,
1196}
1197
1198impl common::RequestValue for UnshareAlbumRequest {}
1199
1200/// Response of a successful unshare of a shared album.
1201///
1202/// # Activities
1203///
1204/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1205/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1206///
1207/// * [unshare albums](AlbumUnshareCall) (response)
1208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1209#[serde_with::serde_as]
1210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1211pub struct UnshareAlbumResponse {
1212 _never_set: Option<bool>,
1213}
1214
1215impl common::ResponseResult for UnshareAlbumResponse {}
1216
1217/// Metadata that is specific to a video, for example, fps and processing status. Some of these fields may be null or not included.
1218///
1219/// This type is not used in any activity, and only used as *part* of another schema.
1220///
1221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1222#[serde_with::serde_as]
1223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1224pub struct Video {
1225 /// Brand of the camera with which the video was taken.
1226 #[serde(rename = "cameraMake")]
1227 pub camera_make: Option<String>,
1228 /// Model of the camera with which the video was taken.
1229 #[serde(rename = "cameraModel")]
1230 pub camera_model: Option<String>,
1231 /// Frame rate of the video.
1232 pub fps: Option<f64>,
1233 /// Processing status of the video.
1234 pub status: Option<String>,
1235}
1236
1237impl common::Part for Video {}
1238
1239// ###################
1240// MethodBuilders ###
1241// #################
1242
1243/// A builder providing access to all methods supported on *album* resources.
1244/// It is not used directly, but through the [`PhotosLibrary`] hub.
1245///
1246/// # Example
1247///
1248/// Instantiate a resource builder
1249///
1250/// ```test_harness,no_run
1251/// extern crate hyper;
1252/// extern crate hyper_rustls;
1253/// extern crate google_photoslibrary1 as photoslibrary1;
1254///
1255/// # async fn dox() {
1256/// use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1257///
1258/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1259/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1260/// secret,
1261/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1262/// ).build().await.unwrap();
1263///
1264/// let client = hyper_util::client::legacy::Client::builder(
1265/// hyper_util::rt::TokioExecutor::new()
1266/// )
1267/// .build(
1268/// hyper_rustls::HttpsConnectorBuilder::new()
1269/// .with_native_roots()
1270/// .unwrap()
1271/// .https_or_http()
1272/// .enable_http1()
1273/// .build()
1274/// );
1275/// let mut hub = PhotosLibrary::new(client, auth);
1276/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1277/// // like `add_enrichment(...)`, `batch_add_media_items(...)`, `batch_remove_media_items(...)`, `create(...)`, `get(...)`, `list(...)`, `patch(...)`, `share(...)` and `unshare(...)`
1278/// // to build up your call.
1279/// let rb = hub.albums();
1280/// # }
1281/// ```
1282pub struct AlbumMethods<'a, C>
1283where
1284 C: 'a,
1285{
1286 hub: &'a PhotosLibrary<C>,
1287}
1288
1289impl<'a, C> common::MethodsBuilder for AlbumMethods<'a, C> {}
1290
1291impl<'a, C> AlbumMethods<'a, C> {
1292 /// Create a builder to help you perform the following task:
1293 ///
1294 /// Adds an enrichment at a specified position in a defined album.
1295 ///
1296 /// # Arguments
1297 ///
1298 /// * `request` - No description provided.
1299 /// * `albumId` - Required. Identifier of the album where the enrichment is to be added.
1300 pub fn add_enrichment(
1301 &self,
1302 request: AddEnrichmentToAlbumRequest,
1303 album_id: &str,
1304 ) -> AlbumAddEnrichmentCall<'a, C> {
1305 AlbumAddEnrichmentCall {
1306 hub: self.hub,
1307 _request: request,
1308 _album_id: album_id.to_string(),
1309 _delegate: Default::default(),
1310 _additional_params: Default::default(),
1311 _scopes: Default::default(),
1312 }
1313 }
1314
1315 /// Create a builder to help you perform the following task:
1316 ///
1317 /// Adds one or more media items in a user's Google Photos library to an album. The media items and albums must have been created by the developer via the API. Media items are added to the end of the album. If multiple media items are given, they are added in the order specified in this call. Each album can contain up to 20,000 media items. Only media items that are in the user's library can be added to an album. For albums that are shared, the album must either be owned by the user or the user must have joined the album as a collaborator. Partial success is not supported. The entire request will fail if an invalid media item or album is specified.
1318 ///
1319 /// # Arguments
1320 ///
1321 /// * `request` - No description provided.
1322 /// * `albumId` - Required. Identifier of the Album that the media items are added to.
1323 pub fn batch_add_media_items(
1324 &self,
1325 request: BatchAddMediaItemsToAlbumRequest,
1326 album_id: &str,
1327 ) -> AlbumBatchAddMediaItemCall<'a, C> {
1328 AlbumBatchAddMediaItemCall {
1329 hub: self.hub,
1330 _request: request,
1331 _album_id: album_id.to_string(),
1332 _delegate: Default::default(),
1333 _additional_params: Default::default(),
1334 _scopes: Default::default(),
1335 }
1336 }
1337
1338 /// Create a builder to help you perform the following task:
1339 ///
1340 /// Removes one or more media items from a specified album. The media items and the album must have been created by the developer via the API. For albums that are shared, this action is only supported for media items that were added to the album by this user, or for all media items if the album was created by this user. Partial success is not supported. The entire request will fail and no action will be performed on the album if an invalid media item or album is specified.
1341 ///
1342 /// # Arguments
1343 ///
1344 /// * `request` - No description provided.
1345 /// * `albumId` - Required. Identifier of the Album that the media items are to be removed from.
1346 pub fn batch_remove_media_items(
1347 &self,
1348 request: BatchRemoveMediaItemsFromAlbumRequest,
1349 album_id: &str,
1350 ) -> AlbumBatchRemoveMediaItemCall<'a, C> {
1351 AlbumBatchRemoveMediaItemCall {
1352 hub: self.hub,
1353 _request: request,
1354 _album_id: album_id.to_string(),
1355 _delegate: Default::default(),
1356 _additional_params: Default::default(),
1357 _scopes: Default::default(),
1358 }
1359 }
1360
1361 /// Create a builder to help you perform the following task:
1362 ///
1363 /// Creates an album in a user's Google Photos library.
1364 ///
1365 /// # Arguments
1366 ///
1367 /// * `request` - No description provided.
1368 pub fn create(&self, request: CreateAlbumRequest) -> AlbumCreateCall<'a, C> {
1369 AlbumCreateCall {
1370 hub: self.hub,
1371 _request: request,
1372 _delegate: Default::default(),
1373 _additional_params: Default::default(),
1374 _scopes: Default::default(),
1375 }
1376 }
1377
1378 /// Create a builder to help you perform the following task:
1379 ///
1380 /// Returns the album based on the specified `albumId`. The `albumId` must be the ID of an album owned by the user or a shared album that the user has joined.
1381 ///
1382 /// # Arguments
1383 ///
1384 /// * `albumId` - Required. Identifier of the album to be requested.
1385 pub fn get(&self, album_id: &str) -> AlbumGetCall<'a, C> {
1386 AlbumGetCall {
1387 hub: self.hub,
1388 _album_id: album_id.to_string(),
1389 _delegate: Default::default(),
1390 _additional_params: Default::default(),
1391 _scopes: Default::default(),
1392 }
1393 }
1394
1395 /// Create a builder to help you perform the following task:
1396 ///
1397 /// Lists all albums shown to a user in the Albums tab of the Google Photos app.
1398 pub fn list(&self) -> AlbumListCall<'a, C> {
1399 AlbumListCall {
1400 hub: self.hub,
1401 _page_token: Default::default(),
1402 _page_size: Default::default(),
1403 _exclude_non_app_created_data: Default::default(),
1404 _delegate: Default::default(),
1405 _additional_params: Default::default(),
1406 _scopes: Default::default(),
1407 }
1408 }
1409
1410 /// Create a builder to help you perform the following task:
1411 ///
1412 /// Update the album with the specified `id`. Only the `id`, `title` and `cover_photo_media_item_id` fields of the album are read. The album must have been created by the developer via the API and must be owned by the user.
1413 ///
1414 /// # Arguments
1415 ///
1416 /// * `request` - No description provided.
1417 /// * `id` - Identifier for the album. This is a persistent identifier that can be used between sessions to identify this album.
1418 pub fn patch(&self, request: Album, id: &str) -> AlbumPatchCall<'a, C> {
1419 AlbumPatchCall {
1420 hub: self.hub,
1421 _request: request,
1422 _id: id.to_string(),
1423 _update_mask: Default::default(),
1424 _delegate: Default::default(),
1425 _additional_params: Default::default(),
1426 _scopes: Default::default(),
1427 }
1428 }
1429
1430 /// Create a builder to help you perform the following task:
1431 ///
1432 /// Marks an album as shared and accessible to other users. This action can only be performed on albums which were created by the developer via the API.
1433 ///
1434 /// # Arguments
1435 ///
1436 /// * `request` - No description provided.
1437 /// * `albumId` - Required. Identifier of the album to be shared. This `albumId` must belong to an album created by the developer.
1438 pub fn share(&self, request: ShareAlbumRequest, album_id: &str) -> AlbumShareCall<'a, C> {
1439 AlbumShareCall {
1440 hub: self.hub,
1441 _request: request,
1442 _album_id: album_id.to_string(),
1443 _delegate: Default::default(),
1444 _additional_params: Default::default(),
1445 _scopes: Default::default(),
1446 }
1447 }
1448
1449 /// Create a builder to help you perform the following task:
1450 ///
1451 /// Marks a previously shared album as private. This means that the album is no longer shared and all the non-owners will lose access to the album. All non-owner content will be removed from the album. If a non-owner has previously added the album to their library, they will retain all photos in their library. This action can only be performed on albums which were created by the developer via the API.
1452 ///
1453 /// # Arguments
1454 ///
1455 /// * `request` - No description provided.
1456 /// * `albumId` - Required. Identifier of the album to be unshared. This album id must belong to an album created by the developer.
1457 pub fn unshare(&self, request: UnshareAlbumRequest, album_id: &str) -> AlbumUnshareCall<'a, C> {
1458 AlbumUnshareCall {
1459 hub: self.hub,
1460 _request: request,
1461 _album_id: album_id.to_string(),
1462 _delegate: Default::default(),
1463 _additional_params: Default::default(),
1464 _scopes: Default::default(),
1465 }
1466 }
1467}
1468
1469/// A builder providing access to all methods supported on *mediaItem* resources.
1470/// It is not used directly, but through the [`PhotosLibrary`] hub.
1471///
1472/// # Example
1473///
1474/// Instantiate a resource builder
1475///
1476/// ```test_harness,no_run
1477/// extern crate hyper;
1478/// extern crate hyper_rustls;
1479/// extern crate google_photoslibrary1 as photoslibrary1;
1480///
1481/// # async fn dox() {
1482/// use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1483///
1484/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1485/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1486/// secret,
1487/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1488/// ).build().await.unwrap();
1489///
1490/// let client = hyper_util::client::legacy::Client::builder(
1491/// hyper_util::rt::TokioExecutor::new()
1492/// )
1493/// .build(
1494/// hyper_rustls::HttpsConnectorBuilder::new()
1495/// .with_native_roots()
1496/// .unwrap()
1497/// .https_or_http()
1498/// .enable_http1()
1499/// .build()
1500/// );
1501/// let mut hub = PhotosLibrary::new(client, auth);
1502/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1503/// // like `batch_create(...)`, `batch_get(...)`, `get(...)`, `list(...)`, `patch(...)` and `search(...)`
1504/// // to build up your call.
1505/// let rb = hub.media_items();
1506/// # }
1507/// ```
1508pub struct MediaItemMethods<'a, C>
1509where
1510 C: 'a,
1511{
1512 hub: &'a PhotosLibrary<C>,
1513}
1514
1515impl<'a, C> common::MethodsBuilder for MediaItemMethods<'a, C> {}
1516
1517impl<'a, C> MediaItemMethods<'a, C> {
1518 /// Create a builder to help you perform the following task:
1519 ///
1520 /// Creates one or more media items in a user's Google Photos library. This is the second step for creating a media item. For details regarding Step 1, uploading the raw bytes to a Google Server, see Uploading media. This call adds the media item to the library. If an album `id` is specified, the call adds the media item to the album too. Each album can contain up to 20,000 media items. By default, the media item will be added to the end of the library or album. If an album `id` and position are both defined, the media item is added to the album at the specified position. If the call contains multiple media items, they're added at the specified position. If you are creating a media item in a shared album where you are not the owner, you are not allowed to position the media item. Doing so will result in a `BAD REQUEST` error.
1521 ///
1522 /// # Arguments
1523 ///
1524 /// * `request` - No description provided.
1525 pub fn batch_create(
1526 &self,
1527 request: BatchCreateMediaItemsRequest,
1528 ) -> MediaItemBatchCreateCall<'a, C> {
1529 MediaItemBatchCreateCall {
1530 hub: self.hub,
1531 _request: request,
1532 _delegate: Default::default(),
1533 _additional_params: Default::default(),
1534 _scopes: Default::default(),
1535 }
1536 }
1537
1538 /// Create a builder to help you perform the following task:
1539 ///
1540 /// Returns the list of media items for the specified media item identifiers. Items are returned in the same order as the supplied identifiers.
1541 pub fn batch_get(&self) -> MediaItemBatchGetCall<'a, C> {
1542 MediaItemBatchGetCall {
1543 hub: self.hub,
1544 _media_item_ids: Default::default(),
1545 _delegate: Default::default(),
1546 _additional_params: Default::default(),
1547 _scopes: Default::default(),
1548 }
1549 }
1550
1551 /// Create a builder to help you perform the following task:
1552 ///
1553 /// Returns the media item for the specified media item identifier.
1554 ///
1555 /// # Arguments
1556 ///
1557 /// * `mediaItemId` - Required. Identifier of the media item to be requested.
1558 pub fn get(&self, media_item_id: &str) -> MediaItemGetCall<'a, C> {
1559 MediaItemGetCall {
1560 hub: self.hub,
1561 _media_item_id: media_item_id.to_string(),
1562 _delegate: Default::default(),
1563 _additional_params: Default::default(),
1564 _scopes: Default::default(),
1565 }
1566 }
1567
1568 /// Create a builder to help you perform the following task:
1569 ///
1570 /// List all media items from a user's Google Photos library.
1571 pub fn list(&self) -> MediaItemListCall<'a, C> {
1572 MediaItemListCall {
1573 hub: self.hub,
1574 _page_token: Default::default(),
1575 _page_size: Default::default(),
1576 _delegate: Default::default(),
1577 _additional_params: Default::default(),
1578 _scopes: Default::default(),
1579 }
1580 }
1581
1582 /// Create a builder to help you perform the following task:
1583 ///
1584 /// Update the media item with the specified `id`. Only the `id` and `description` fields of the media item are read. The media item must have been created by the developer via the API and must be owned by the user.
1585 ///
1586 /// # Arguments
1587 ///
1588 /// * `request` - No description provided.
1589 /// * `id` - Identifier for the media item. This is a persistent identifier that can be used between sessions to identify this media item.
1590 pub fn patch(&self, request: MediaItem, id: &str) -> MediaItemPatchCall<'a, C> {
1591 MediaItemPatchCall {
1592 hub: self.hub,
1593 _request: request,
1594 _id: id.to_string(),
1595 _update_mask: Default::default(),
1596 _delegate: Default::default(),
1597 _additional_params: Default::default(),
1598 _scopes: Default::default(),
1599 }
1600 }
1601
1602 /// Create a builder to help you perform the following task:
1603 ///
1604 /// Searches for media items in a user's Google Photos library. If no filters are set, then all media items in the user's library are returned. If an album is set, all media items in the specified album are returned. If filters are specified, media items that match the filters from the user's library are listed. If you set both the album and the filters, the request results in an error.
1605 ///
1606 /// # Arguments
1607 ///
1608 /// * `request` - No description provided.
1609 pub fn search(&self, request: SearchMediaItemsRequest) -> MediaItemSearchCall<'a, C> {
1610 MediaItemSearchCall {
1611 hub: self.hub,
1612 _request: request,
1613 _delegate: Default::default(),
1614 _additional_params: Default::default(),
1615 _scopes: Default::default(),
1616 }
1617 }
1618}
1619
1620/// A builder providing access to all methods supported on *sharedAlbum* resources.
1621/// It is not used directly, but through the [`PhotosLibrary`] hub.
1622///
1623/// # Example
1624///
1625/// Instantiate a resource builder
1626///
1627/// ```test_harness,no_run
1628/// extern crate hyper;
1629/// extern crate hyper_rustls;
1630/// extern crate google_photoslibrary1 as photoslibrary1;
1631///
1632/// # async fn dox() {
1633/// use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1634///
1635/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1636/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1637/// secret,
1638/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1639/// ).build().await.unwrap();
1640///
1641/// let client = hyper_util::client::legacy::Client::builder(
1642/// hyper_util::rt::TokioExecutor::new()
1643/// )
1644/// .build(
1645/// hyper_rustls::HttpsConnectorBuilder::new()
1646/// .with_native_roots()
1647/// .unwrap()
1648/// .https_or_http()
1649/// .enable_http1()
1650/// .build()
1651/// );
1652/// let mut hub = PhotosLibrary::new(client, auth);
1653/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1654/// // like `get(...)`, `join(...)`, `leave(...)` and `list(...)`
1655/// // to build up your call.
1656/// let rb = hub.shared_albums();
1657/// # }
1658/// ```
1659pub struct SharedAlbumMethods<'a, C>
1660where
1661 C: 'a,
1662{
1663 hub: &'a PhotosLibrary<C>,
1664}
1665
1666impl<'a, C> common::MethodsBuilder for SharedAlbumMethods<'a, C> {}
1667
1668impl<'a, C> SharedAlbumMethods<'a, C> {
1669 /// Create a builder to help you perform the following task:
1670 ///
1671 /// Returns the album based on the specified `shareToken`.
1672 ///
1673 /// # Arguments
1674 ///
1675 /// * `shareToken` - Required. Share token of the album to be requested.
1676 pub fn get(&self, share_token: &str) -> SharedAlbumGetCall<'a, C> {
1677 SharedAlbumGetCall {
1678 hub: self.hub,
1679 _share_token: share_token.to_string(),
1680 _delegate: Default::default(),
1681 _additional_params: Default::default(),
1682 _scopes: Default::default(),
1683 }
1684 }
1685
1686 /// Create a builder to help you perform the following task:
1687 ///
1688 /// Joins a shared album on behalf of the Google Photos user.
1689 ///
1690 /// # Arguments
1691 ///
1692 /// * `request` - No description provided.
1693 pub fn join(&self, request: JoinSharedAlbumRequest) -> SharedAlbumJoinCall<'a, C> {
1694 SharedAlbumJoinCall {
1695 hub: self.hub,
1696 _request: request,
1697 _delegate: Default::default(),
1698 _additional_params: Default::default(),
1699 _scopes: Default::default(),
1700 }
1701 }
1702
1703 /// Create a builder to help you perform the following task:
1704 ///
1705 /// Leaves a previously-joined shared album on behalf of the Google Photos user. The user must not own this album.
1706 ///
1707 /// # Arguments
1708 ///
1709 /// * `request` - No description provided.
1710 pub fn leave(&self, request: LeaveSharedAlbumRequest) -> SharedAlbumLeaveCall<'a, C> {
1711 SharedAlbumLeaveCall {
1712 hub: self.hub,
1713 _request: request,
1714 _delegate: Default::default(),
1715 _additional_params: Default::default(),
1716 _scopes: Default::default(),
1717 }
1718 }
1719
1720 /// Create a builder to help you perform the following task:
1721 ///
1722 /// Lists all shared albums available in the Sharing tab of the user's Google Photos app.
1723 pub fn list(&self) -> SharedAlbumListCall<'a, C> {
1724 SharedAlbumListCall {
1725 hub: self.hub,
1726 _page_token: Default::default(),
1727 _page_size: Default::default(),
1728 _exclude_non_app_created_data: Default::default(),
1729 _delegate: Default::default(),
1730 _additional_params: Default::default(),
1731 _scopes: Default::default(),
1732 }
1733 }
1734}
1735
1736// ###################
1737// CallBuilders ###
1738// #################
1739
1740/// Adds an enrichment at a specified position in a defined album.
1741///
1742/// A builder for the *addEnrichment* method supported by a *album* resource.
1743/// It is not used directly, but through a [`AlbumMethods`] instance.
1744///
1745/// # Example
1746///
1747/// Instantiate a resource method builder
1748///
1749/// ```test_harness,no_run
1750/// # extern crate hyper;
1751/// # extern crate hyper_rustls;
1752/// # extern crate google_photoslibrary1 as photoslibrary1;
1753/// use photoslibrary1::api::AddEnrichmentToAlbumRequest;
1754/// # async fn dox() {
1755/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1756///
1757/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1758/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1759/// # secret,
1760/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1761/// # ).build().await.unwrap();
1762///
1763/// # let client = hyper_util::client::legacy::Client::builder(
1764/// # hyper_util::rt::TokioExecutor::new()
1765/// # )
1766/// # .build(
1767/// # hyper_rustls::HttpsConnectorBuilder::new()
1768/// # .with_native_roots()
1769/// # .unwrap()
1770/// # .https_or_http()
1771/// # .enable_http1()
1772/// # .build()
1773/// # );
1774/// # let mut hub = PhotosLibrary::new(client, auth);
1775/// // As the method needs a request, you would usually fill it with the desired information
1776/// // into the respective structure. Some of the parts shown here might not be applicable !
1777/// // Values shown here are possibly random and not representative !
1778/// let mut req = AddEnrichmentToAlbumRequest::default();
1779///
1780/// // You can configure optional parameters by calling the respective setters at will, and
1781/// // execute the final call using `doit()`.
1782/// // Values shown here are possibly random and not representative !
1783/// let result = hub.albums().add_enrichment(req, "albumId")
1784/// .doit().await;
1785/// # }
1786/// ```
1787pub struct AlbumAddEnrichmentCall<'a, C>
1788where
1789 C: 'a,
1790{
1791 hub: &'a PhotosLibrary<C>,
1792 _request: AddEnrichmentToAlbumRequest,
1793 _album_id: String,
1794 _delegate: Option<&'a mut dyn common::Delegate>,
1795 _additional_params: HashMap<String, String>,
1796 _scopes: BTreeSet<String>,
1797}
1798
1799impl<'a, C> common::CallBuilder for AlbumAddEnrichmentCall<'a, C> {}
1800
1801impl<'a, C> AlbumAddEnrichmentCall<'a, C>
1802where
1803 C: common::Connector,
1804{
1805 /// Perform the operation you have build so far.
1806 pub async fn doit(
1807 mut self,
1808 ) -> common::Result<(common::Response, AddEnrichmentToAlbumResponse)> {
1809 use std::borrow::Cow;
1810 use std::io::{Read, Seek};
1811
1812 use common::{url::Params, ToParts};
1813 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1814
1815 let mut dd = common::DefaultDelegate;
1816 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1817 dlg.begin(common::MethodInfo {
1818 id: "photoslibrary.albums.addEnrichment",
1819 http_method: hyper::Method::POST,
1820 });
1821
1822 for &field in ["alt", "albumId"].iter() {
1823 if self._additional_params.contains_key(field) {
1824 dlg.finished(false);
1825 return Err(common::Error::FieldClash(field));
1826 }
1827 }
1828
1829 let mut params = Params::with_capacity(4 + self._additional_params.len());
1830 params.push("albumId", self._album_id);
1831
1832 params.extend(self._additional_params.iter());
1833
1834 params.push("alt", "json");
1835 let mut url = self.hub._base_url.clone() + "v1/albums/{+albumId}:addEnrichment";
1836 if self._scopes.is_empty() {
1837 self._scopes.insert(Scope::Full.as_ref().to_string());
1838 }
1839
1840 #[allow(clippy::single_element_loop)]
1841 for &(find_this, param_name) in [("{+albumId}", "albumId")].iter() {
1842 url = params.uri_replacement(url, param_name, find_this, true);
1843 }
1844 {
1845 let to_remove = ["albumId"];
1846 params.remove_params(&to_remove);
1847 }
1848
1849 let url = params.parse_with_url(&url);
1850
1851 let mut json_mime_type = mime::APPLICATION_JSON;
1852 let mut request_value_reader = {
1853 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1854 common::remove_json_null_values(&mut value);
1855 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1856 serde_json::to_writer(&mut dst, &value).unwrap();
1857 dst
1858 };
1859 let request_size = request_value_reader
1860 .seek(std::io::SeekFrom::End(0))
1861 .unwrap();
1862 request_value_reader
1863 .seek(std::io::SeekFrom::Start(0))
1864 .unwrap();
1865
1866 loop {
1867 let token = match self
1868 .hub
1869 .auth
1870 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1871 .await
1872 {
1873 Ok(token) => token,
1874 Err(e) => match dlg.token(e) {
1875 Ok(token) => token,
1876 Err(e) => {
1877 dlg.finished(false);
1878 return Err(common::Error::MissingToken(e));
1879 }
1880 },
1881 };
1882 request_value_reader
1883 .seek(std::io::SeekFrom::Start(0))
1884 .unwrap();
1885 let mut req_result = {
1886 let client = &self.hub.client;
1887 dlg.pre_request();
1888 let mut req_builder = hyper::Request::builder()
1889 .method(hyper::Method::POST)
1890 .uri(url.as_str())
1891 .header(USER_AGENT, self.hub._user_agent.clone());
1892
1893 if let Some(token) = token.as_ref() {
1894 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1895 }
1896
1897 let request = req_builder
1898 .header(CONTENT_TYPE, json_mime_type.to_string())
1899 .header(CONTENT_LENGTH, request_size as u64)
1900 .body(common::to_body(
1901 request_value_reader.get_ref().clone().into(),
1902 ));
1903
1904 client.request(request.unwrap()).await
1905 };
1906
1907 match req_result {
1908 Err(err) => {
1909 if let common::Retry::After(d) = dlg.http_error(&err) {
1910 sleep(d).await;
1911 continue;
1912 }
1913 dlg.finished(false);
1914 return Err(common::Error::HttpError(err));
1915 }
1916 Ok(res) => {
1917 let (mut parts, body) = res.into_parts();
1918 let mut body = common::Body::new(body);
1919 if !parts.status.is_success() {
1920 let bytes = common::to_bytes(body).await.unwrap_or_default();
1921 let error = serde_json::from_str(&common::to_string(&bytes));
1922 let response = common::to_response(parts, bytes.into());
1923
1924 if let common::Retry::After(d) =
1925 dlg.http_failure(&response, error.as_ref().ok())
1926 {
1927 sleep(d).await;
1928 continue;
1929 }
1930
1931 dlg.finished(false);
1932
1933 return Err(match error {
1934 Ok(value) => common::Error::BadRequest(value),
1935 _ => common::Error::Failure(response),
1936 });
1937 }
1938 let response = {
1939 let bytes = common::to_bytes(body).await.unwrap_or_default();
1940 let encoded = common::to_string(&bytes);
1941 match serde_json::from_str(&encoded) {
1942 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1943 Err(error) => {
1944 dlg.response_json_decode_error(&encoded, &error);
1945 return Err(common::Error::JsonDecodeError(
1946 encoded.to_string(),
1947 error,
1948 ));
1949 }
1950 }
1951 };
1952
1953 dlg.finished(true);
1954 return Ok(response);
1955 }
1956 }
1957 }
1958 }
1959
1960 ///
1961 /// Sets the *request* property to the given value.
1962 ///
1963 /// Even though the property as already been set when instantiating this call,
1964 /// we provide this method for API completeness.
1965 pub fn request(
1966 mut self,
1967 new_value: AddEnrichmentToAlbumRequest,
1968 ) -> AlbumAddEnrichmentCall<'a, C> {
1969 self._request = new_value;
1970 self
1971 }
1972 /// Required. Identifier of the album where the enrichment is to be added.
1973 ///
1974 /// Sets the *album id* path property to the given value.
1975 ///
1976 /// Even though the property as already been set when instantiating this call,
1977 /// we provide this method for API completeness.
1978 pub fn album_id(mut self, new_value: &str) -> AlbumAddEnrichmentCall<'a, C> {
1979 self._album_id = new_value.to_string();
1980 self
1981 }
1982 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1983 /// while executing the actual API request.
1984 ///
1985 /// ````text
1986 /// It should be used to handle progress information, and to implement a certain level of resilience.
1987 /// ````
1988 ///
1989 /// Sets the *delegate* property to the given value.
1990 pub fn delegate(
1991 mut self,
1992 new_value: &'a mut dyn common::Delegate,
1993 ) -> AlbumAddEnrichmentCall<'a, C> {
1994 self._delegate = Some(new_value);
1995 self
1996 }
1997
1998 /// Set any additional parameter of the query string used in the request.
1999 /// It should be used to set parameters which are not yet available through their own
2000 /// setters.
2001 ///
2002 /// Please note that this method must not be used to set any of the known parameters
2003 /// which have their own setter method. If done anyway, the request will fail.
2004 ///
2005 /// # Additional Parameters
2006 ///
2007 /// * *$.xgafv* (query-string) - V1 error format.
2008 /// * *access_token* (query-string) - OAuth access token.
2009 /// * *alt* (query-string) - Data format for response.
2010 /// * *callback* (query-string) - JSONP
2011 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2012 /// * *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.
2013 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2014 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2015 /// * *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.
2016 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2017 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2018 pub fn param<T>(mut self, name: T, value: T) -> AlbumAddEnrichmentCall<'a, C>
2019 where
2020 T: AsRef<str>,
2021 {
2022 self._additional_params
2023 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2024 self
2025 }
2026
2027 /// Identifies the authorization scope for the method you are building.
2028 ///
2029 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2030 /// [`Scope::Full`].
2031 ///
2032 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2033 /// tokens for more than one scope.
2034 ///
2035 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2036 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2037 /// sufficient, a read-write scope will do as well.
2038 pub fn add_scope<St>(mut self, scope: St) -> AlbumAddEnrichmentCall<'a, C>
2039 where
2040 St: AsRef<str>,
2041 {
2042 self._scopes.insert(String::from(scope.as_ref()));
2043 self
2044 }
2045 /// Identifies the authorization scope(s) for the method you are building.
2046 ///
2047 /// See [`Self::add_scope()`] for details.
2048 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumAddEnrichmentCall<'a, C>
2049 where
2050 I: IntoIterator<Item = St>,
2051 St: AsRef<str>,
2052 {
2053 self._scopes
2054 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2055 self
2056 }
2057
2058 /// Removes all scopes, and no default scope will be used either.
2059 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2060 /// for details).
2061 pub fn clear_scopes(mut self) -> AlbumAddEnrichmentCall<'a, C> {
2062 self._scopes.clear();
2063 self
2064 }
2065}
2066
2067/// Adds one or more media items in a user's Google Photos library to an album. The media items and albums must have been created by the developer via the API. Media items are added to the end of the album. If multiple media items are given, they are added in the order specified in this call. Each album can contain up to 20,000 media items. Only media items that are in the user's library can be added to an album. For albums that are shared, the album must either be owned by the user or the user must have joined the album as a collaborator. Partial success is not supported. The entire request will fail if an invalid media item or album is specified.
2068///
2069/// A builder for the *batchAddMediaItems* method supported by a *album* resource.
2070/// It is not used directly, but through a [`AlbumMethods`] instance.
2071///
2072/// # Example
2073///
2074/// Instantiate a resource method builder
2075///
2076/// ```test_harness,no_run
2077/// # extern crate hyper;
2078/// # extern crate hyper_rustls;
2079/// # extern crate google_photoslibrary1 as photoslibrary1;
2080/// use photoslibrary1::api::BatchAddMediaItemsToAlbumRequest;
2081/// # async fn dox() {
2082/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2083///
2084/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2085/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2086/// # secret,
2087/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2088/// # ).build().await.unwrap();
2089///
2090/// # let client = hyper_util::client::legacy::Client::builder(
2091/// # hyper_util::rt::TokioExecutor::new()
2092/// # )
2093/// # .build(
2094/// # hyper_rustls::HttpsConnectorBuilder::new()
2095/// # .with_native_roots()
2096/// # .unwrap()
2097/// # .https_or_http()
2098/// # .enable_http1()
2099/// # .build()
2100/// # );
2101/// # let mut hub = PhotosLibrary::new(client, auth);
2102/// // As the method needs a request, you would usually fill it with the desired information
2103/// // into the respective structure. Some of the parts shown here might not be applicable !
2104/// // Values shown here are possibly random and not representative !
2105/// let mut req = BatchAddMediaItemsToAlbumRequest::default();
2106///
2107/// // You can configure optional parameters by calling the respective setters at will, and
2108/// // execute the final call using `doit()`.
2109/// // Values shown here are possibly random and not representative !
2110/// let result = hub.albums().batch_add_media_items(req, "albumId")
2111/// .doit().await;
2112/// # }
2113/// ```
2114pub struct AlbumBatchAddMediaItemCall<'a, C>
2115where
2116 C: 'a,
2117{
2118 hub: &'a PhotosLibrary<C>,
2119 _request: BatchAddMediaItemsToAlbumRequest,
2120 _album_id: String,
2121 _delegate: Option<&'a mut dyn common::Delegate>,
2122 _additional_params: HashMap<String, String>,
2123 _scopes: BTreeSet<String>,
2124}
2125
2126impl<'a, C> common::CallBuilder for AlbumBatchAddMediaItemCall<'a, C> {}
2127
2128impl<'a, C> AlbumBatchAddMediaItemCall<'a, C>
2129where
2130 C: common::Connector,
2131{
2132 /// Perform the operation you have build so far.
2133 pub async fn doit(
2134 mut self,
2135 ) -> common::Result<(common::Response, BatchAddMediaItemsToAlbumResponse)> {
2136 use std::borrow::Cow;
2137 use std::io::{Read, Seek};
2138
2139 use common::{url::Params, ToParts};
2140 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2141
2142 let mut dd = common::DefaultDelegate;
2143 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2144 dlg.begin(common::MethodInfo {
2145 id: "photoslibrary.albums.batchAddMediaItems",
2146 http_method: hyper::Method::POST,
2147 });
2148
2149 for &field in ["alt", "albumId"].iter() {
2150 if self._additional_params.contains_key(field) {
2151 dlg.finished(false);
2152 return Err(common::Error::FieldClash(field));
2153 }
2154 }
2155
2156 let mut params = Params::with_capacity(4 + self._additional_params.len());
2157 params.push("albumId", self._album_id);
2158
2159 params.extend(self._additional_params.iter());
2160
2161 params.push("alt", "json");
2162 let mut url = self.hub._base_url.clone() + "v1/albums/{+albumId}:batchAddMediaItems";
2163 if self._scopes.is_empty() {
2164 self._scopes.insert(Scope::Full.as_ref().to_string());
2165 }
2166
2167 #[allow(clippy::single_element_loop)]
2168 for &(find_this, param_name) in [("{+albumId}", "albumId")].iter() {
2169 url = params.uri_replacement(url, param_name, find_this, true);
2170 }
2171 {
2172 let to_remove = ["albumId"];
2173 params.remove_params(&to_remove);
2174 }
2175
2176 let url = params.parse_with_url(&url);
2177
2178 let mut json_mime_type = mime::APPLICATION_JSON;
2179 let mut request_value_reader = {
2180 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2181 common::remove_json_null_values(&mut value);
2182 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2183 serde_json::to_writer(&mut dst, &value).unwrap();
2184 dst
2185 };
2186 let request_size = request_value_reader
2187 .seek(std::io::SeekFrom::End(0))
2188 .unwrap();
2189 request_value_reader
2190 .seek(std::io::SeekFrom::Start(0))
2191 .unwrap();
2192
2193 loop {
2194 let token = match self
2195 .hub
2196 .auth
2197 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2198 .await
2199 {
2200 Ok(token) => token,
2201 Err(e) => match dlg.token(e) {
2202 Ok(token) => token,
2203 Err(e) => {
2204 dlg.finished(false);
2205 return Err(common::Error::MissingToken(e));
2206 }
2207 },
2208 };
2209 request_value_reader
2210 .seek(std::io::SeekFrom::Start(0))
2211 .unwrap();
2212 let mut req_result = {
2213 let client = &self.hub.client;
2214 dlg.pre_request();
2215 let mut req_builder = hyper::Request::builder()
2216 .method(hyper::Method::POST)
2217 .uri(url.as_str())
2218 .header(USER_AGENT, self.hub._user_agent.clone());
2219
2220 if let Some(token) = token.as_ref() {
2221 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2222 }
2223
2224 let request = req_builder
2225 .header(CONTENT_TYPE, json_mime_type.to_string())
2226 .header(CONTENT_LENGTH, request_size as u64)
2227 .body(common::to_body(
2228 request_value_reader.get_ref().clone().into(),
2229 ));
2230
2231 client.request(request.unwrap()).await
2232 };
2233
2234 match req_result {
2235 Err(err) => {
2236 if let common::Retry::After(d) = dlg.http_error(&err) {
2237 sleep(d).await;
2238 continue;
2239 }
2240 dlg.finished(false);
2241 return Err(common::Error::HttpError(err));
2242 }
2243 Ok(res) => {
2244 let (mut parts, body) = res.into_parts();
2245 let mut body = common::Body::new(body);
2246 if !parts.status.is_success() {
2247 let bytes = common::to_bytes(body).await.unwrap_or_default();
2248 let error = serde_json::from_str(&common::to_string(&bytes));
2249 let response = common::to_response(parts, bytes.into());
2250
2251 if let common::Retry::After(d) =
2252 dlg.http_failure(&response, error.as_ref().ok())
2253 {
2254 sleep(d).await;
2255 continue;
2256 }
2257
2258 dlg.finished(false);
2259
2260 return Err(match error {
2261 Ok(value) => common::Error::BadRequest(value),
2262 _ => common::Error::Failure(response),
2263 });
2264 }
2265 let response = {
2266 let bytes = common::to_bytes(body).await.unwrap_or_default();
2267 let encoded = common::to_string(&bytes);
2268 match serde_json::from_str(&encoded) {
2269 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2270 Err(error) => {
2271 dlg.response_json_decode_error(&encoded, &error);
2272 return Err(common::Error::JsonDecodeError(
2273 encoded.to_string(),
2274 error,
2275 ));
2276 }
2277 }
2278 };
2279
2280 dlg.finished(true);
2281 return Ok(response);
2282 }
2283 }
2284 }
2285 }
2286
2287 ///
2288 /// Sets the *request* property to the given value.
2289 ///
2290 /// Even though the property as already been set when instantiating this call,
2291 /// we provide this method for API completeness.
2292 pub fn request(
2293 mut self,
2294 new_value: BatchAddMediaItemsToAlbumRequest,
2295 ) -> AlbumBatchAddMediaItemCall<'a, C> {
2296 self._request = new_value;
2297 self
2298 }
2299 /// Required. Identifier of the Album that the media items are added to.
2300 ///
2301 /// Sets the *album id* path property to the given value.
2302 ///
2303 /// Even though the property as already been set when instantiating this call,
2304 /// we provide this method for API completeness.
2305 pub fn album_id(mut self, new_value: &str) -> AlbumBatchAddMediaItemCall<'a, C> {
2306 self._album_id = new_value.to_string();
2307 self
2308 }
2309 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2310 /// while executing the actual API request.
2311 ///
2312 /// ````text
2313 /// It should be used to handle progress information, and to implement a certain level of resilience.
2314 /// ````
2315 ///
2316 /// Sets the *delegate* property to the given value.
2317 pub fn delegate(
2318 mut self,
2319 new_value: &'a mut dyn common::Delegate,
2320 ) -> AlbumBatchAddMediaItemCall<'a, C> {
2321 self._delegate = Some(new_value);
2322 self
2323 }
2324
2325 /// Set any additional parameter of the query string used in the request.
2326 /// It should be used to set parameters which are not yet available through their own
2327 /// setters.
2328 ///
2329 /// Please note that this method must not be used to set any of the known parameters
2330 /// which have their own setter method. If done anyway, the request will fail.
2331 ///
2332 /// # Additional Parameters
2333 ///
2334 /// * *$.xgafv* (query-string) - V1 error format.
2335 /// * *access_token* (query-string) - OAuth access token.
2336 /// * *alt* (query-string) - Data format for response.
2337 /// * *callback* (query-string) - JSONP
2338 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2339 /// * *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.
2340 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2341 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2342 /// * *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.
2343 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2344 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2345 pub fn param<T>(mut self, name: T, value: T) -> AlbumBatchAddMediaItemCall<'a, C>
2346 where
2347 T: AsRef<str>,
2348 {
2349 self._additional_params
2350 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2351 self
2352 }
2353
2354 /// Identifies the authorization scope for the method you are building.
2355 ///
2356 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2357 /// [`Scope::Full`].
2358 ///
2359 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2360 /// tokens for more than one scope.
2361 ///
2362 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2363 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2364 /// sufficient, a read-write scope will do as well.
2365 pub fn add_scope<St>(mut self, scope: St) -> AlbumBatchAddMediaItemCall<'a, C>
2366 where
2367 St: AsRef<str>,
2368 {
2369 self._scopes.insert(String::from(scope.as_ref()));
2370 self
2371 }
2372 /// Identifies the authorization scope(s) for the method you are building.
2373 ///
2374 /// See [`Self::add_scope()`] for details.
2375 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumBatchAddMediaItemCall<'a, C>
2376 where
2377 I: IntoIterator<Item = St>,
2378 St: AsRef<str>,
2379 {
2380 self._scopes
2381 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2382 self
2383 }
2384
2385 /// Removes all scopes, and no default scope will be used either.
2386 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2387 /// for details).
2388 pub fn clear_scopes(mut self) -> AlbumBatchAddMediaItemCall<'a, C> {
2389 self._scopes.clear();
2390 self
2391 }
2392}
2393
2394/// Removes one or more media items from a specified album. The media items and the album must have been created by the developer via the API. For albums that are shared, this action is only supported for media items that were added to the album by this user, or for all media items if the album was created by this user. Partial success is not supported. The entire request will fail and no action will be performed on the album if an invalid media item or album is specified.
2395///
2396/// A builder for the *batchRemoveMediaItems* method supported by a *album* resource.
2397/// It is not used directly, but through a [`AlbumMethods`] instance.
2398///
2399/// # Example
2400///
2401/// Instantiate a resource method builder
2402///
2403/// ```test_harness,no_run
2404/// # extern crate hyper;
2405/// # extern crate hyper_rustls;
2406/// # extern crate google_photoslibrary1 as photoslibrary1;
2407/// use photoslibrary1::api::BatchRemoveMediaItemsFromAlbumRequest;
2408/// # async fn dox() {
2409/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2410///
2411/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2412/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2413/// # secret,
2414/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2415/// # ).build().await.unwrap();
2416///
2417/// # let client = hyper_util::client::legacy::Client::builder(
2418/// # hyper_util::rt::TokioExecutor::new()
2419/// # )
2420/// # .build(
2421/// # hyper_rustls::HttpsConnectorBuilder::new()
2422/// # .with_native_roots()
2423/// # .unwrap()
2424/// # .https_or_http()
2425/// # .enable_http1()
2426/// # .build()
2427/// # );
2428/// # let mut hub = PhotosLibrary::new(client, auth);
2429/// // As the method needs a request, you would usually fill it with the desired information
2430/// // into the respective structure. Some of the parts shown here might not be applicable !
2431/// // Values shown here are possibly random and not representative !
2432/// let mut req = BatchRemoveMediaItemsFromAlbumRequest::default();
2433///
2434/// // You can configure optional parameters by calling the respective setters at will, and
2435/// // execute the final call using `doit()`.
2436/// // Values shown here are possibly random and not representative !
2437/// let result = hub.albums().batch_remove_media_items(req, "albumId")
2438/// .doit().await;
2439/// # }
2440/// ```
2441pub struct AlbumBatchRemoveMediaItemCall<'a, C>
2442where
2443 C: 'a,
2444{
2445 hub: &'a PhotosLibrary<C>,
2446 _request: BatchRemoveMediaItemsFromAlbumRequest,
2447 _album_id: String,
2448 _delegate: Option<&'a mut dyn common::Delegate>,
2449 _additional_params: HashMap<String, String>,
2450 _scopes: BTreeSet<String>,
2451}
2452
2453impl<'a, C> common::CallBuilder for AlbumBatchRemoveMediaItemCall<'a, C> {}
2454
2455impl<'a, C> AlbumBatchRemoveMediaItemCall<'a, C>
2456where
2457 C: common::Connector,
2458{
2459 /// Perform the operation you have build so far.
2460 pub async fn doit(
2461 mut self,
2462 ) -> common::Result<(common::Response, BatchRemoveMediaItemsFromAlbumResponse)> {
2463 use std::borrow::Cow;
2464 use std::io::{Read, Seek};
2465
2466 use common::{url::Params, ToParts};
2467 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2468
2469 let mut dd = common::DefaultDelegate;
2470 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2471 dlg.begin(common::MethodInfo {
2472 id: "photoslibrary.albums.batchRemoveMediaItems",
2473 http_method: hyper::Method::POST,
2474 });
2475
2476 for &field in ["alt", "albumId"].iter() {
2477 if self._additional_params.contains_key(field) {
2478 dlg.finished(false);
2479 return Err(common::Error::FieldClash(field));
2480 }
2481 }
2482
2483 let mut params = Params::with_capacity(4 + self._additional_params.len());
2484 params.push("albumId", self._album_id);
2485
2486 params.extend(self._additional_params.iter());
2487
2488 params.push("alt", "json");
2489 let mut url = self.hub._base_url.clone() + "v1/albums/{+albumId}:batchRemoveMediaItems";
2490 if self._scopes.is_empty() {
2491 self._scopes.insert(Scope::Full.as_ref().to_string());
2492 }
2493
2494 #[allow(clippy::single_element_loop)]
2495 for &(find_this, param_name) in [("{+albumId}", "albumId")].iter() {
2496 url = params.uri_replacement(url, param_name, find_this, true);
2497 }
2498 {
2499 let to_remove = ["albumId"];
2500 params.remove_params(&to_remove);
2501 }
2502
2503 let url = params.parse_with_url(&url);
2504
2505 let mut json_mime_type = mime::APPLICATION_JSON;
2506 let mut request_value_reader = {
2507 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2508 common::remove_json_null_values(&mut value);
2509 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2510 serde_json::to_writer(&mut dst, &value).unwrap();
2511 dst
2512 };
2513 let request_size = request_value_reader
2514 .seek(std::io::SeekFrom::End(0))
2515 .unwrap();
2516 request_value_reader
2517 .seek(std::io::SeekFrom::Start(0))
2518 .unwrap();
2519
2520 loop {
2521 let token = match self
2522 .hub
2523 .auth
2524 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2525 .await
2526 {
2527 Ok(token) => token,
2528 Err(e) => match dlg.token(e) {
2529 Ok(token) => token,
2530 Err(e) => {
2531 dlg.finished(false);
2532 return Err(common::Error::MissingToken(e));
2533 }
2534 },
2535 };
2536 request_value_reader
2537 .seek(std::io::SeekFrom::Start(0))
2538 .unwrap();
2539 let mut req_result = {
2540 let client = &self.hub.client;
2541 dlg.pre_request();
2542 let mut req_builder = hyper::Request::builder()
2543 .method(hyper::Method::POST)
2544 .uri(url.as_str())
2545 .header(USER_AGENT, self.hub._user_agent.clone());
2546
2547 if let Some(token) = token.as_ref() {
2548 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2549 }
2550
2551 let request = req_builder
2552 .header(CONTENT_TYPE, json_mime_type.to_string())
2553 .header(CONTENT_LENGTH, request_size as u64)
2554 .body(common::to_body(
2555 request_value_reader.get_ref().clone().into(),
2556 ));
2557
2558 client.request(request.unwrap()).await
2559 };
2560
2561 match req_result {
2562 Err(err) => {
2563 if let common::Retry::After(d) = dlg.http_error(&err) {
2564 sleep(d).await;
2565 continue;
2566 }
2567 dlg.finished(false);
2568 return Err(common::Error::HttpError(err));
2569 }
2570 Ok(res) => {
2571 let (mut parts, body) = res.into_parts();
2572 let mut body = common::Body::new(body);
2573 if !parts.status.is_success() {
2574 let bytes = common::to_bytes(body).await.unwrap_or_default();
2575 let error = serde_json::from_str(&common::to_string(&bytes));
2576 let response = common::to_response(parts, bytes.into());
2577
2578 if let common::Retry::After(d) =
2579 dlg.http_failure(&response, error.as_ref().ok())
2580 {
2581 sleep(d).await;
2582 continue;
2583 }
2584
2585 dlg.finished(false);
2586
2587 return Err(match error {
2588 Ok(value) => common::Error::BadRequest(value),
2589 _ => common::Error::Failure(response),
2590 });
2591 }
2592 let response = {
2593 let bytes = common::to_bytes(body).await.unwrap_or_default();
2594 let encoded = common::to_string(&bytes);
2595 match serde_json::from_str(&encoded) {
2596 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2597 Err(error) => {
2598 dlg.response_json_decode_error(&encoded, &error);
2599 return Err(common::Error::JsonDecodeError(
2600 encoded.to_string(),
2601 error,
2602 ));
2603 }
2604 }
2605 };
2606
2607 dlg.finished(true);
2608 return Ok(response);
2609 }
2610 }
2611 }
2612 }
2613
2614 ///
2615 /// Sets the *request* property to the given value.
2616 ///
2617 /// Even though the property as already been set when instantiating this call,
2618 /// we provide this method for API completeness.
2619 pub fn request(
2620 mut self,
2621 new_value: BatchRemoveMediaItemsFromAlbumRequest,
2622 ) -> AlbumBatchRemoveMediaItemCall<'a, C> {
2623 self._request = new_value;
2624 self
2625 }
2626 /// Required. Identifier of the Album that the media items are to be removed from.
2627 ///
2628 /// Sets the *album id* path property to the given value.
2629 ///
2630 /// Even though the property as already been set when instantiating this call,
2631 /// we provide this method for API completeness.
2632 pub fn album_id(mut self, new_value: &str) -> AlbumBatchRemoveMediaItemCall<'a, C> {
2633 self._album_id = new_value.to_string();
2634 self
2635 }
2636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2637 /// while executing the actual API request.
2638 ///
2639 /// ````text
2640 /// It should be used to handle progress information, and to implement a certain level of resilience.
2641 /// ````
2642 ///
2643 /// Sets the *delegate* property to the given value.
2644 pub fn delegate(
2645 mut self,
2646 new_value: &'a mut dyn common::Delegate,
2647 ) -> AlbumBatchRemoveMediaItemCall<'a, C> {
2648 self._delegate = Some(new_value);
2649 self
2650 }
2651
2652 /// Set any additional parameter of the query string used in the request.
2653 /// It should be used to set parameters which are not yet available through their own
2654 /// setters.
2655 ///
2656 /// Please note that this method must not be used to set any of the known parameters
2657 /// which have their own setter method. If done anyway, the request will fail.
2658 ///
2659 /// # Additional Parameters
2660 ///
2661 /// * *$.xgafv* (query-string) - V1 error format.
2662 /// * *access_token* (query-string) - OAuth access token.
2663 /// * *alt* (query-string) - Data format for response.
2664 /// * *callback* (query-string) - JSONP
2665 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2666 /// * *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.
2667 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2668 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2669 /// * *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.
2670 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2671 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2672 pub fn param<T>(mut self, name: T, value: T) -> AlbumBatchRemoveMediaItemCall<'a, C>
2673 where
2674 T: AsRef<str>,
2675 {
2676 self._additional_params
2677 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2678 self
2679 }
2680
2681 /// Identifies the authorization scope for the method you are building.
2682 ///
2683 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2684 /// [`Scope::Full`].
2685 ///
2686 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2687 /// tokens for more than one scope.
2688 ///
2689 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2690 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2691 /// sufficient, a read-write scope will do as well.
2692 pub fn add_scope<St>(mut self, scope: St) -> AlbumBatchRemoveMediaItemCall<'a, C>
2693 where
2694 St: AsRef<str>,
2695 {
2696 self._scopes.insert(String::from(scope.as_ref()));
2697 self
2698 }
2699 /// Identifies the authorization scope(s) for the method you are building.
2700 ///
2701 /// See [`Self::add_scope()`] for details.
2702 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumBatchRemoveMediaItemCall<'a, C>
2703 where
2704 I: IntoIterator<Item = St>,
2705 St: AsRef<str>,
2706 {
2707 self._scopes
2708 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2709 self
2710 }
2711
2712 /// Removes all scopes, and no default scope will be used either.
2713 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2714 /// for details).
2715 pub fn clear_scopes(mut self) -> AlbumBatchRemoveMediaItemCall<'a, C> {
2716 self._scopes.clear();
2717 self
2718 }
2719}
2720
2721/// Creates an album in a user's Google Photos library.
2722///
2723/// A builder for the *create* method supported by a *album* resource.
2724/// It is not used directly, but through a [`AlbumMethods`] instance.
2725///
2726/// # Example
2727///
2728/// Instantiate a resource method builder
2729///
2730/// ```test_harness,no_run
2731/// # extern crate hyper;
2732/// # extern crate hyper_rustls;
2733/// # extern crate google_photoslibrary1 as photoslibrary1;
2734/// use photoslibrary1::api::CreateAlbumRequest;
2735/// # async fn dox() {
2736/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2737///
2738/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2739/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2740/// # secret,
2741/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2742/// # ).build().await.unwrap();
2743///
2744/// # let client = hyper_util::client::legacy::Client::builder(
2745/// # hyper_util::rt::TokioExecutor::new()
2746/// # )
2747/// # .build(
2748/// # hyper_rustls::HttpsConnectorBuilder::new()
2749/// # .with_native_roots()
2750/// # .unwrap()
2751/// # .https_or_http()
2752/// # .enable_http1()
2753/// # .build()
2754/// # );
2755/// # let mut hub = PhotosLibrary::new(client, auth);
2756/// // As the method needs a request, you would usually fill it with the desired information
2757/// // into the respective structure. Some of the parts shown here might not be applicable !
2758/// // Values shown here are possibly random and not representative !
2759/// let mut req = CreateAlbumRequest::default();
2760///
2761/// // You can configure optional parameters by calling the respective setters at will, and
2762/// // execute the final call using `doit()`.
2763/// // Values shown here are possibly random and not representative !
2764/// let result = hub.albums().create(req)
2765/// .doit().await;
2766/// # }
2767/// ```
2768pub struct AlbumCreateCall<'a, C>
2769where
2770 C: 'a,
2771{
2772 hub: &'a PhotosLibrary<C>,
2773 _request: CreateAlbumRequest,
2774 _delegate: Option<&'a mut dyn common::Delegate>,
2775 _additional_params: HashMap<String, String>,
2776 _scopes: BTreeSet<String>,
2777}
2778
2779impl<'a, C> common::CallBuilder for AlbumCreateCall<'a, C> {}
2780
2781impl<'a, C> AlbumCreateCall<'a, C>
2782where
2783 C: common::Connector,
2784{
2785 /// Perform the operation you have build so far.
2786 pub async fn doit(mut self) -> common::Result<(common::Response, Album)> {
2787 use std::borrow::Cow;
2788 use std::io::{Read, Seek};
2789
2790 use common::{url::Params, ToParts};
2791 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2792
2793 let mut dd = common::DefaultDelegate;
2794 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2795 dlg.begin(common::MethodInfo {
2796 id: "photoslibrary.albums.create",
2797 http_method: hyper::Method::POST,
2798 });
2799
2800 for &field in ["alt"].iter() {
2801 if self._additional_params.contains_key(field) {
2802 dlg.finished(false);
2803 return Err(common::Error::FieldClash(field));
2804 }
2805 }
2806
2807 let mut params = Params::with_capacity(3 + self._additional_params.len());
2808
2809 params.extend(self._additional_params.iter());
2810
2811 params.push("alt", "json");
2812 let mut url = self.hub._base_url.clone() + "v1/albums";
2813 if self._scopes.is_empty() {
2814 self._scopes.insert(Scope::Full.as_ref().to_string());
2815 }
2816
2817 let url = params.parse_with_url(&url);
2818
2819 let mut json_mime_type = mime::APPLICATION_JSON;
2820 let mut request_value_reader = {
2821 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2822 common::remove_json_null_values(&mut value);
2823 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2824 serde_json::to_writer(&mut dst, &value).unwrap();
2825 dst
2826 };
2827 let request_size = request_value_reader
2828 .seek(std::io::SeekFrom::End(0))
2829 .unwrap();
2830 request_value_reader
2831 .seek(std::io::SeekFrom::Start(0))
2832 .unwrap();
2833
2834 loop {
2835 let token = match self
2836 .hub
2837 .auth
2838 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2839 .await
2840 {
2841 Ok(token) => token,
2842 Err(e) => match dlg.token(e) {
2843 Ok(token) => token,
2844 Err(e) => {
2845 dlg.finished(false);
2846 return Err(common::Error::MissingToken(e));
2847 }
2848 },
2849 };
2850 request_value_reader
2851 .seek(std::io::SeekFrom::Start(0))
2852 .unwrap();
2853 let mut req_result = {
2854 let client = &self.hub.client;
2855 dlg.pre_request();
2856 let mut req_builder = hyper::Request::builder()
2857 .method(hyper::Method::POST)
2858 .uri(url.as_str())
2859 .header(USER_AGENT, self.hub._user_agent.clone());
2860
2861 if let Some(token) = token.as_ref() {
2862 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2863 }
2864
2865 let request = req_builder
2866 .header(CONTENT_TYPE, json_mime_type.to_string())
2867 .header(CONTENT_LENGTH, request_size as u64)
2868 .body(common::to_body(
2869 request_value_reader.get_ref().clone().into(),
2870 ));
2871
2872 client.request(request.unwrap()).await
2873 };
2874
2875 match req_result {
2876 Err(err) => {
2877 if let common::Retry::After(d) = dlg.http_error(&err) {
2878 sleep(d).await;
2879 continue;
2880 }
2881 dlg.finished(false);
2882 return Err(common::Error::HttpError(err));
2883 }
2884 Ok(res) => {
2885 let (mut parts, body) = res.into_parts();
2886 let mut body = common::Body::new(body);
2887 if !parts.status.is_success() {
2888 let bytes = common::to_bytes(body).await.unwrap_or_default();
2889 let error = serde_json::from_str(&common::to_string(&bytes));
2890 let response = common::to_response(parts, bytes.into());
2891
2892 if let common::Retry::After(d) =
2893 dlg.http_failure(&response, error.as_ref().ok())
2894 {
2895 sleep(d).await;
2896 continue;
2897 }
2898
2899 dlg.finished(false);
2900
2901 return Err(match error {
2902 Ok(value) => common::Error::BadRequest(value),
2903 _ => common::Error::Failure(response),
2904 });
2905 }
2906 let response = {
2907 let bytes = common::to_bytes(body).await.unwrap_or_default();
2908 let encoded = common::to_string(&bytes);
2909 match serde_json::from_str(&encoded) {
2910 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2911 Err(error) => {
2912 dlg.response_json_decode_error(&encoded, &error);
2913 return Err(common::Error::JsonDecodeError(
2914 encoded.to_string(),
2915 error,
2916 ));
2917 }
2918 }
2919 };
2920
2921 dlg.finished(true);
2922 return Ok(response);
2923 }
2924 }
2925 }
2926 }
2927
2928 ///
2929 /// Sets the *request* property to the given value.
2930 ///
2931 /// Even though the property as already been set when instantiating this call,
2932 /// we provide this method for API completeness.
2933 pub fn request(mut self, new_value: CreateAlbumRequest) -> AlbumCreateCall<'a, C> {
2934 self._request = new_value;
2935 self
2936 }
2937 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2938 /// while executing the actual API request.
2939 ///
2940 /// ````text
2941 /// It should be used to handle progress information, and to implement a certain level of resilience.
2942 /// ````
2943 ///
2944 /// Sets the *delegate* property to the given value.
2945 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AlbumCreateCall<'a, C> {
2946 self._delegate = Some(new_value);
2947 self
2948 }
2949
2950 /// Set any additional parameter of the query string used in the request.
2951 /// It should be used to set parameters which are not yet available through their own
2952 /// setters.
2953 ///
2954 /// Please note that this method must not be used to set any of the known parameters
2955 /// which have their own setter method. If done anyway, the request will fail.
2956 ///
2957 /// # Additional Parameters
2958 ///
2959 /// * *$.xgafv* (query-string) - V1 error format.
2960 /// * *access_token* (query-string) - OAuth access token.
2961 /// * *alt* (query-string) - Data format for response.
2962 /// * *callback* (query-string) - JSONP
2963 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2964 /// * *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.
2965 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2966 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2967 /// * *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.
2968 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2969 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2970 pub fn param<T>(mut self, name: T, value: T) -> AlbumCreateCall<'a, C>
2971 where
2972 T: AsRef<str>,
2973 {
2974 self._additional_params
2975 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2976 self
2977 }
2978
2979 /// Identifies the authorization scope for the method you are building.
2980 ///
2981 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2982 /// [`Scope::Full`].
2983 ///
2984 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2985 /// tokens for more than one scope.
2986 ///
2987 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2988 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2989 /// sufficient, a read-write scope will do as well.
2990 pub fn add_scope<St>(mut self, scope: St) -> AlbumCreateCall<'a, C>
2991 where
2992 St: AsRef<str>,
2993 {
2994 self._scopes.insert(String::from(scope.as_ref()));
2995 self
2996 }
2997 /// Identifies the authorization scope(s) for the method you are building.
2998 ///
2999 /// See [`Self::add_scope()`] for details.
3000 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumCreateCall<'a, C>
3001 where
3002 I: IntoIterator<Item = St>,
3003 St: AsRef<str>,
3004 {
3005 self._scopes
3006 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3007 self
3008 }
3009
3010 /// Removes all scopes, and no default scope will be used either.
3011 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3012 /// for details).
3013 pub fn clear_scopes(mut self) -> AlbumCreateCall<'a, C> {
3014 self._scopes.clear();
3015 self
3016 }
3017}
3018
3019/// Returns the album based on the specified `albumId`. The `albumId` must be the ID of an album owned by the user or a shared album that the user has joined.
3020///
3021/// A builder for the *get* method supported by a *album* resource.
3022/// It is not used directly, but through a [`AlbumMethods`] instance.
3023///
3024/// # Example
3025///
3026/// Instantiate a resource method builder
3027///
3028/// ```test_harness,no_run
3029/// # extern crate hyper;
3030/// # extern crate hyper_rustls;
3031/// # extern crate google_photoslibrary1 as photoslibrary1;
3032/// # async fn dox() {
3033/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3034///
3035/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3036/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3037/// # secret,
3038/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3039/// # ).build().await.unwrap();
3040///
3041/// # let client = hyper_util::client::legacy::Client::builder(
3042/// # hyper_util::rt::TokioExecutor::new()
3043/// # )
3044/// # .build(
3045/// # hyper_rustls::HttpsConnectorBuilder::new()
3046/// # .with_native_roots()
3047/// # .unwrap()
3048/// # .https_or_http()
3049/// # .enable_http1()
3050/// # .build()
3051/// # );
3052/// # let mut hub = PhotosLibrary::new(client, auth);
3053/// // You can configure optional parameters by calling the respective setters at will, and
3054/// // execute the final call using `doit()`.
3055/// // Values shown here are possibly random and not representative !
3056/// let result = hub.albums().get("albumId")
3057/// .doit().await;
3058/// # }
3059/// ```
3060pub struct AlbumGetCall<'a, C>
3061where
3062 C: 'a,
3063{
3064 hub: &'a PhotosLibrary<C>,
3065 _album_id: String,
3066 _delegate: Option<&'a mut dyn common::Delegate>,
3067 _additional_params: HashMap<String, String>,
3068 _scopes: BTreeSet<String>,
3069}
3070
3071impl<'a, C> common::CallBuilder for AlbumGetCall<'a, C> {}
3072
3073impl<'a, C> AlbumGetCall<'a, C>
3074where
3075 C: common::Connector,
3076{
3077 /// Perform the operation you have build so far.
3078 pub async fn doit(mut self) -> common::Result<(common::Response, Album)> {
3079 use std::borrow::Cow;
3080 use std::io::{Read, Seek};
3081
3082 use common::{url::Params, ToParts};
3083 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3084
3085 let mut dd = common::DefaultDelegate;
3086 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3087 dlg.begin(common::MethodInfo {
3088 id: "photoslibrary.albums.get",
3089 http_method: hyper::Method::GET,
3090 });
3091
3092 for &field in ["alt", "albumId"].iter() {
3093 if self._additional_params.contains_key(field) {
3094 dlg.finished(false);
3095 return Err(common::Error::FieldClash(field));
3096 }
3097 }
3098
3099 let mut params = Params::with_capacity(3 + self._additional_params.len());
3100 params.push("albumId", self._album_id);
3101
3102 params.extend(self._additional_params.iter());
3103
3104 params.push("alt", "json");
3105 let mut url = self.hub._base_url.clone() + "v1/albums/{+albumId}";
3106 if self._scopes.is_empty() {
3107 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3108 }
3109
3110 #[allow(clippy::single_element_loop)]
3111 for &(find_this, param_name) in [("{+albumId}", "albumId")].iter() {
3112 url = params.uri_replacement(url, param_name, find_this, true);
3113 }
3114 {
3115 let to_remove = ["albumId"];
3116 params.remove_params(&to_remove);
3117 }
3118
3119 let url = params.parse_with_url(&url);
3120
3121 loop {
3122 let token = match self
3123 .hub
3124 .auth
3125 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3126 .await
3127 {
3128 Ok(token) => token,
3129 Err(e) => match dlg.token(e) {
3130 Ok(token) => token,
3131 Err(e) => {
3132 dlg.finished(false);
3133 return Err(common::Error::MissingToken(e));
3134 }
3135 },
3136 };
3137 let mut req_result = {
3138 let client = &self.hub.client;
3139 dlg.pre_request();
3140 let mut req_builder = hyper::Request::builder()
3141 .method(hyper::Method::GET)
3142 .uri(url.as_str())
3143 .header(USER_AGENT, self.hub._user_agent.clone());
3144
3145 if let Some(token) = token.as_ref() {
3146 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3147 }
3148
3149 let request = req_builder
3150 .header(CONTENT_LENGTH, 0_u64)
3151 .body(common::to_body::<String>(None));
3152
3153 client.request(request.unwrap()).await
3154 };
3155
3156 match req_result {
3157 Err(err) => {
3158 if let common::Retry::After(d) = dlg.http_error(&err) {
3159 sleep(d).await;
3160 continue;
3161 }
3162 dlg.finished(false);
3163 return Err(common::Error::HttpError(err));
3164 }
3165 Ok(res) => {
3166 let (mut parts, body) = res.into_parts();
3167 let mut body = common::Body::new(body);
3168 if !parts.status.is_success() {
3169 let bytes = common::to_bytes(body).await.unwrap_or_default();
3170 let error = serde_json::from_str(&common::to_string(&bytes));
3171 let response = common::to_response(parts, bytes.into());
3172
3173 if let common::Retry::After(d) =
3174 dlg.http_failure(&response, error.as_ref().ok())
3175 {
3176 sleep(d).await;
3177 continue;
3178 }
3179
3180 dlg.finished(false);
3181
3182 return Err(match error {
3183 Ok(value) => common::Error::BadRequest(value),
3184 _ => common::Error::Failure(response),
3185 });
3186 }
3187 let response = {
3188 let bytes = common::to_bytes(body).await.unwrap_or_default();
3189 let encoded = common::to_string(&bytes);
3190 match serde_json::from_str(&encoded) {
3191 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3192 Err(error) => {
3193 dlg.response_json_decode_error(&encoded, &error);
3194 return Err(common::Error::JsonDecodeError(
3195 encoded.to_string(),
3196 error,
3197 ));
3198 }
3199 }
3200 };
3201
3202 dlg.finished(true);
3203 return Ok(response);
3204 }
3205 }
3206 }
3207 }
3208
3209 /// Required. Identifier of the album to be requested.
3210 ///
3211 /// Sets the *album id* path property to the given value.
3212 ///
3213 /// Even though the property as already been set when instantiating this call,
3214 /// we provide this method for API completeness.
3215 pub fn album_id(mut self, new_value: &str) -> AlbumGetCall<'a, C> {
3216 self._album_id = new_value.to_string();
3217 self
3218 }
3219 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3220 /// while executing the actual API request.
3221 ///
3222 /// ````text
3223 /// It should be used to handle progress information, and to implement a certain level of resilience.
3224 /// ````
3225 ///
3226 /// Sets the *delegate* property to the given value.
3227 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AlbumGetCall<'a, C> {
3228 self._delegate = Some(new_value);
3229 self
3230 }
3231
3232 /// Set any additional parameter of the query string used in the request.
3233 /// It should be used to set parameters which are not yet available through their own
3234 /// setters.
3235 ///
3236 /// Please note that this method must not be used to set any of the known parameters
3237 /// which have their own setter method. If done anyway, the request will fail.
3238 ///
3239 /// # Additional Parameters
3240 ///
3241 /// * *$.xgafv* (query-string) - V1 error format.
3242 /// * *access_token* (query-string) - OAuth access token.
3243 /// * *alt* (query-string) - Data format for response.
3244 /// * *callback* (query-string) - JSONP
3245 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3246 /// * *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.
3247 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3248 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3249 /// * *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.
3250 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3251 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3252 pub fn param<T>(mut self, name: T, value: T) -> AlbumGetCall<'a, C>
3253 where
3254 T: AsRef<str>,
3255 {
3256 self._additional_params
3257 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3258 self
3259 }
3260
3261 /// Identifies the authorization scope for the method you are building.
3262 ///
3263 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3264 /// [`Scope::Readonly`].
3265 ///
3266 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3267 /// tokens for more than one scope.
3268 ///
3269 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3270 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3271 /// sufficient, a read-write scope will do as well.
3272 pub fn add_scope<St>(mut self, scope: St) -> AlbumGetCall<'a, C>
3273 where
3274 St: AsRef<str>,
3275 {
3276 self._scopes.insert(String::from(scope.as_ref()));
3277 self
3278 }
3279 /// Identifies the authorization scope(s) for the method you are building.
3280 ///
3281 /// See [`Self::add_scope()`] for details.
3282 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumGetCall<'a, C>
3283 where
3284 I: IntoIterator<Item = St>,
3285 St: AsRef<str>,
3286 {
3287 self._scopes
3288 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3289 self
3290 }
3291
3292 /// Removes all scopes, and no default scope will be used either.
3293 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3294 /// for details).
3295 pub fn clear_scopes(mut self) -> AlbumGetCall<'a, C> {
3296 self._scopes.clear();
3297 self
3298 }
3299}
3300
3301/// Lists all albums shown to a user in the Albums tab of the Google Photos app.
3302///
3303/// A builder for the *list* method supported by a *album* resource.
3304/// It is not used directly, but through a [`AlbumMethods`] instance.
3305///
3306/// # Example
3307///
3308/// Instantiate a resource method builder
3309///
3310/// ```test_harness,no_run
3311/// # extern crate hyper;
3312/// # extern crate hyper_rustls;
3313/// # extern crate google_photoslibrary1 as photoslibrary1;
3314/// # async fn dox() {
3315/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3316///
3317/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3318/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3319/// # secret,
3320/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3321/// # ).build().await.unwrap();
3322///
3323/// # let client = hyper_util::client::legacy::Client::builder(
3324/// # hyper_util::rt::TokioExecutor::new()
3325/// # )
3326/// # .build(
3327/// # hyper_rustls::HttpsConnectorBuilder::new()
3328/// # .with_native_roots()
3329/// # .unwrap()
3330/// # .https_or_http()
3331/// # .enable_http1()
3332/// # .build()
3333/// # );
3334/// # let mut hub = PhotosLibrary::new(client, auth);
3335/// // You can configure optional parameters by calling the respective setters at will, and
3336/// // execute the final call using `doit()`.
3337/// // Values shown here are possibly random and not representative !
3338/// let result = hub.albums().list()
3339/// .page_token("gubergren")
3340/// .page_size(-75)
3341/// .exclude_non_app_created_data(true)
3342/// .doit().await;
3343/// # }
3344/// ```
3345pub struct AlbumListCall<'a, C>
3346where
3347 C: 'a,
3348{
3349 hub: &'a PhotosLibrary<C>,
3350 _page_token: Option<String>,
3351 _page_size: Option<i32>,
3352 _exclude_non_app_created_data: Option<bool>,
3353 _delegate: Option<&'a mut dyn common::Delegate>,
3354 _additional_params: HashMap<String, String>,
3355 _scopes: BTreeSet<String>,
3356}
3357
3358impl<'a, C> common::CallBuilder for AlbumListCall<'a, C> {}
3359
3360impl<'a, C> AlbumListCall<'a, C>
3361where
3362 C: common::Connector,
3363{
3364 /// Perform the operation you have build so far.
3365 pub async fn doit(mut self) -> common::Result<(common::Response, ListAlbumsResponse)> {
3366 use std::borrow::Cow;
3367 use std::io::{Read, Seek};
3368
3369 use common::{url::Params, ToParts};
3370 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3371
3372 let mut dd = common::DefaultDelegate;
3373 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3374 dlg.begin(common::MethodInfo {
3375 id: "photoslibrary.albums.list",
3376 http_method: hyper::Method::GET,
3377 });
3378
3379 for &field in ["alt", "pageToken", "pageSize", "excludeNonAppCreatedData"].iter() {
3380 if self._additional_params.contains_key(field) {
3381 dlg.finished(false);
3382 return Err(common::Error::FieldClash(field));
3383 }
3384 }
3385
3386 let mut params = Params::with_capacity(5 + self._additional_params.len());
3387 if let Some(value) = self._page_token.as_ref() {
3388 params.push("pageToken", value);
3389 }
3390 if let Some(value) = self._page_size.as_ref() {
3391 params.push("pageSize", value.to_string());
3392 }
3393 if let Some(value) = self._exclude_non_app_created_data.as_ref() {
3394 params.push("excludeNonAppCreatedData", value.to_string());
3395 }
3396
3397 params.extend(self._additional_params.iter());
3398
3399 params.push("alt", "json");
3400 let mut url = self.hub._base_url.clone() + "v1/albums";
3401 if self._scopes.is_empty() {
3402 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3403 }
3404
3405 let url = params.parse_with_url(&url);
3406
3407 loop {
3408 let token = match self
3409 .hub
3410 .auth
3411 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3412 .await
3413 {
3414 Ok(token) => token,
3415 Err(e) => match dlg.token(e) {
3416 Ok(token) => token,
3417 Err(e) => {
3418 dlg.finished(false);
3419 return Err(common::Error::MissingToken(e));
3420 }
3421 },
3422 };
3423 let mut req_result = {
3424 let client = &self.hub.client;
3425 dlg.pre_request();
3426 let mut req_builder = hyper::Request::builder()
3427 .method(hyper::Method::GET)
3428 .uri(url.as_str())
3429 .header(USER_AGENT, self.hub._user_agent.clone());
3430
3431 if let Some(token) = token.as_ref() {
3432 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3433 }
3434
3435 let request = req_builder
3436 .header(CONTENT_LENGTH, 0_u64)
3437 .body(common::to_body::<String>(None));
3438
3439 client.request(request.unwrap()).await
3440 };
3441
3442 match req_result {
3443 Err(err) => {
3444 if let common::Retry::After(d) = dlg.http_error(&err) {
3445 sleep(d).await;
3446 continue;
3447 }
3448 dlg.finished(false);
3449 return Err(common::Error::HttpError(err));
3450 }
3451 Ok(res) => {
3452 let (mut parts, body) = res.into_parts();
3453 let mut body = common::Body::new(body);
3454 if !parts.status.is_success() {
3455 let bytes = common::to_bytes(body).await.unwrap_or_default();
3456 let error = serde_json::from_str(&common::to_string(&bytes));
3457 let response = common::to_response(parts, bytes.into());
3458
3459 if let common::Retry::After(d) =
3460 dlg.http_failure(&response, error.as_ref().ok())
3461 {
3462 sleep(d).await;
3463 continue;
3464 }
3465
3466 dlg.finished(false);
3467
3468 return Err(match error {
3469 Ok(value) => common::Error::BadRequest(value),
3470 _ => common::Error::Failure(response),
3471 });
3472 }
3473 let response = {
3474 let bytes = common::to_bytes(body).await.unwrap_or_default();
3475 let encoded = common::to_string(&bytes);
3476 match serde_json::from_str(&encoded) {
3477 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3478 Err(error) => {
3479 dlg.response_json_decode_error(&encoded, &error);
3480 return Err(common::Error::JsonDecodeError(
3481 encoded.to_string(),
3482 error,
3483 ));
3484 }
3485 }
3486 };
3487
3488 dlg.finished(true);
3489 return Ok(response);
3490 }
3491 }
3492 }
3493 }
3494
3495 /// A continuation token to get the next page of the results. Adding this to the request returns the rows after the `pageToken`. The `pageToken` should be the value returned in the `nextPageToken` parameter in the response to the `listAlbums` request.
3496 ///
3497 /// Sets the *page token* query property to the given value.
3498 pub fn page_token(mut self, new_value: &str) -> AlbumListCall<'a, C> {
3499 self._page_token = Some(new_value.to_string());
3500 self
3501 }
3502 /// Maximum number of albums to return in the response. Fewer albums might be returned than the specified number. The default `pageSize` is 20, the maximum is 50.
3503 ///
3504 /// Sets the *page size* query property to the given value.
3505 pub fn page_size(mut self, new_value: i32) -> AlbumListCall<'a, C> {
3506 self._page_size = Some(new_value);
3507 self
3508 }
3509 /// If set, the results exclude media items that were not created by this app. Defaults to false (all albums are returned). This field is ignored if the photoslibrary.readonly.appcreateddata scope is used.
3510 ///
3511 /// Sets the *exclude non app created data* query property to the given value.
3512 pub fn exclude_non_app_created_data(mut self, new_value: bool) -> AlbumListCall<'a, C> {
3513 self._exclude_non_app_created_data = Some(new_value);
3514 self
3515 }
3516 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3517 /// while executing the actual API request.
3518 ///
3519 /// ````text
3520 /// It should be used to handle progress information, and to implement a certain level of resilience.
3521 /// ````
3522 ///
3523 /// Sets the *delegate* property to the given value.
3524 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AlbumListCall<'a, C> {
3525 self._delegate = Some(new_value);
3526 self
3527 }
3528
3529 /// Set any additional parameter of the query string used in the request.
3530 /// It should be used to set parameters which are not yet available through their own
3531 /// setters.
3532 ///
3533 /// Please note that this method must not be used to set any of the known parameters
3534 /// which have their own setter method. If done anyway, the request will fail.
3535 ///
3536 /// # Additional Parameters
3537 ///
3538 /// * *$.xgafv* (query-string) - V1 error format.
3539 /// * *access_token* (query-string) - OAuth access token.
3540 /// * *alt* (query-string) - Data format for response.
3541 /// * *callback* (query-string) - JSONP
3542 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3543 /// * *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.
3544 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3545 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3546 /// * *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.
3547 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3548 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3549 pub fn param<T>(mut self, name: T, value: T) -> AlbumListCall<'a, C>
3550 where
3551 T: AsRef<str>,
3552 {
3553 self._additional_params
3554 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3555 self
3556 }
3557
3558 /// Identifies the authorization scope for the method you are building.
3559 ///
3560 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3561 /// [`Scope::Readonly`].
3562 ///
3563 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3564 /// tokens for more than one scope.
3565 ///
3566 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3567 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3568 /// sufficient, a read-write scope will do as well.
3569 pub fn add_scope<St>(mut self, scope: St) -> AlbumListCall<'a, C>
3570 where
3571 St: AsRef<str>,
3572 {
3573 self._scopes.insert(String::from(scope.as_ref()));
3574 self
3575 }
3576 /// Identifies the authorization scope(s) for the method you are building.
3577 ///
3578 /// See [`Self::add_scope()`] for details.
3579 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumListCall<'a, C>
3580 where
3581 I: IntoIterator<Item = St>,
3582 St: AsRef<str>,
3583 {
3584 self._scopes
3585 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3586 self
3587 }
3588
3589 /// Removes all scopes, and no default scope will be used either.
3590 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3591 /// for details).
3592 pub fn clear_scopes(mut self) -> AlbumListCall<'a, C> {
3593 self._scopes.clear();
3594 self
3595 }
3596}
3597
3598/// Update the album with the specified `id`. Only the `id`, `title` and `cover_photo_media_item_id` fields of the album are read. The album must have been created by the developer via the API and must be owned by the user.
3599///
3600/// A builder for the *patch* method supported by a *album* resource.
3601/// It is not used directly, but through a [`AlbumMethods`] instance.
3602///
3603/// # Example
3604///
3605/// Instantiate a resource method builder
3606///
3607/// ```test_harness,no_run
3608/// # extern crate hyper;
3609/// # extern crate hyper_rustls;
3610/// # extern crate google_photoslibrary1 as photoslibrary1;
3611/// use photoslibrary1::api::Album;
3612/// # async fn dox() {
3613/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3614///
3615/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3616/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3617/// # secret,
3618/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3619/// # ).build().await.unwrap();
3620///
3621/// # let client = hyper_util::client::legacy::Client::builder(
3622/// # hyper_util::rt::TokioExecutor::new()
3623/// # )
3624/// # .build(
3625/// # hyper_rustls::HttpsConnectorBuilder::new()
3626/// # .with_native_roots()
3627/// # .unwrap()
3628/// # .https_or_http()
3629/// # .enable_http1()
3630/// # .build()
3631/// # );
3632/// # let mut hub = PhotosLibrary::new(client, auth);
3633/// // As the method needs a request, you would usually fill it with the desired information
3634/// // into the respective structure. Some of the parts shown here might not be applicable !
3635/// // Values shown here are possibly random and not representative !
3636/// let mut req = Album::default();
3637///
3638/// // You can configure optional parameters by calling the respective setters at will, and
3639/// // execute the final call using `doit()`.
3640/// // Values shown here are possibly random and not representative !
3641/// let result = hub.albums().patch(req, "id")
3642/// .update_mask(FieldMask::new::<&str>(&[]))
3643/// .doit().await;
3644/// # }
3645/// ```
3646pub struct AlbumPatchCall<'a, C>
3647where
3648 C: 'a,
3649{
3650 hub: &'a PhotosLibrary<C>,
3651 _request: Album,
3652 _id: String,
3653 _update_mask: Option<common::FieldMask>,
3654 _delegate: Option<&'a mut dyn common::Delegate>,
3655 _additional_params: HashMap<String, String>,
3656 _scopes: BTreeSet<String>,
3657}
3658
3659impl<'a, C> common::CallBuilder for AlbumPatchCall<'a, C> {}
3660
3661impl<'a, C> AlbumPatchCall<'a, C>
3662where
3663 C: common::Connector,
3664{
3665 /// Perform the operation you have build so far.
3666 pub async fn doit(mut self) -> common::Result<(common::Response, Album)> {
3667 use std::borrow::Cow;
3668 use std::io::{Read, Seek};
3669
3670 use common::{url::Params, ToParts};
3671 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3672
3673 let mut dd = common::DefaultDelegate;
3674 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3675 dlg.begin(common::MethodInfo {
3676 id: "photoslibrary.albums.patch",
3677 http_method: hyper::Method::PATCH,
3678 });
3679
3680 for &field in ["alt", "id", "updateMask"].iter() {
3681 if self._additional_params.contains_key(field) {
3682 dlg.finished(false);
3683 return Err(common::Error::FieldClash(field));
3684 }
3685 }
3686
3687 let mut params = Params::with_capacity(5 + self._additional_params.len());
3688 params.push("id", self._id);
3689 if let Some(value) = self._update_mask.as_ref() {
3690 params.push("updateMask", value.to_string());
3691 }
3692
3693 params.extend(self._additional_params.iter());
3694
3695 params.push("alt", "json");
3696 let mut url = self.hub._base_url.clone() + "v1/albums/{+id}";
3697 if self._scopes.is_empty() {
3698 self._scopes
3699 .insert(Scope::EditAppcreateddata.as_ref().to_string());
3700 }
3701
3702 #[allow(clippy::single_element_loop)]
3703 for &(find_this, param_name) in [("{+id}", "id")].iter() {
3704 url = params.uri_replacement(url, param_name, find_this, true);
3705 }
3706 {
3707 let to_remove = ["id"];
3708 params.remove_params(&to_remove);
3709 }
3710
3711 let url = params.parse_with_url(&url);
3712
3713 let mut json_mime_type = mime::APPLICATION_JSON;
3714 let mut request_value_reader = {
3715 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3716 common::remove_json_null_values(&mut value);
3717 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3718 serde_json::to_writer(&mut dst, &value).unwrap();
3719 dst
3720 };
3721 let request_size = request_value_reader
3722 .seek(std::io::SeekFrom::End(0))
3723 .unwrap();
3724 request_value_reader
3725 .seek(std::io::SeekFrom::Start(0))
3726 .unwrap();
3727
3728 loop {
3729 let token = match self
3730 .hub
3731 .auth
3732 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3733 .await
3734 {
3735 Ok(token) => token,
3736 Err(e) => match dlg.token(e) {
3737 Ok(token) => token,
3738 Err(e) => {
3739 dlg.finished(false);
3740 return Err(common::Error::MissingToken(e));
3741 }
3742 },
3743 };
3744 request_value_reader
3745 .seek(std::io::SeekFrom::Start(0))
3746 .unwrap();
3747 let mut req_result = {
3748 let client = &self.hub.client;
3749 dlg.pre_request();
3750 let mut req_builder = hyper::Request::builder()
3751 .method(hyper::Method::PATCH)
3752 .uri(url.as_str())
3753 .header(USER_AGENT, self.hub._user_agent.clone());
3754
3755 if let Some(token) = token.as_ref() {
3756 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3757 }
3758
3759 let request = req_builder
3760 .header(CONTENT_TYPE, json_mime_type.to_string())
3761 .header(CONTENT_LENGTH, request_size as u64)
3762 .body(common::to_body(
3763 request_value_reader.get_ref().clone().into(),
3764 ));
3765
3766 client.request(request.unwrap()).await
3767 };
3768
3769 match req_result {
3770 Err(err) => {
3771 if let common::Retry::After(d) = dlg.http_error(&err) {
3772 sleep(d).await;
3773 continue;
3774 }
3775 dlg.finished(false);
3776 return Err(common::Error::HttpError(err));
3777 }
3778 Ok(res) => {
3779 let (mut parts, body) = res.into_parts();
3780 let mut body = common::Body::new(body);
3781 if !parts.status.is_success() {
3782 let bytes = common::to_bytes(body).await.unwrap_or_default();
3783 let error = serde_json::from_str(&common::to_string(&bytes));
3784 let response = common::to_response(parts, bytes.into());
3785
3786 if let common::Retry::After(d) =
3787 dlg.http_failure(&response, error.as_ref().ok())
3788 {
3789 sleep(d).await;
3790 continue;
3791 }
3792
3793 dlg.finished(false);
3794
3795 return Err(match error {
3796 Ok(value) => common::Error::BadRequest(value),
3797 _ => common::Error::Failure(response),
3798 });
3799 }
3800 let response = {
3801 let bytes = common::to_bytes(body).await.unwrap_or_default();
3802 let encoded = common::to_string(&bytes);
3803 match serde_json::from_str(&encoded) {
3804 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3805 Err(error) => {
3806 dlg.response_json_decode_error(&encoded, &error);
3807 return Err(common::Error::JsonDecodeError(
3808 encoded.to_string(),
3809 error,
3810 ));
3811 }
3812 }
3813 };
3814
3815 dlg.finished(true);
3816 return Ok(response);
3817 }
3818 }
3819 }
3820 }
3821
3822 ///
3823 /// Sets the *request* property to the given value.
3824 ///
3825 /// Even though the property as already been set when instantiating this call,
3826 /// we provide this method for API completeness.
3827 pub fn request(mut self, new_value: Album) -> AlbumPatchCall<'a, C> {
3828 self._request = new_value;
3829 self
3830 }
3831 /// Identifier for the album. This is a persistent identifier that can be used between sessions to identify this album.
3832 ///
3833 /// Sets the *id* path property to the given value.
3834 ///
3835 /// Even though the property as already been set when instantiating this call,
3836 /// we provide this method for API completeness.
3837 pub fn id(mut self, new_value: &str) -> AlbumPatchCall<'a, C> {
3838 self._id = new_value.to_string();
3839 self
3840 }
3841 /// Required. Indicate what fields in the provided album to update. The only valid values are `title` and `cover_photo_media_item_id`.
3842 ///
3843 /// Sets the *update mask* query property to the given value.
3844 pub fn update_mask(mut self, new_value: common::FieldMask) -> AlbumPatchCall<'a, C> {
3845 self._update_mask = Some(new_value);
3846 self
3847 }
3848 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3849 /// while executing the actual API request.
3850 ///
3851 /// ````text
3852 /// It should be used to handle progress information, and to implement a certain level of resilience.
3853 /// ````
3854 ///
3855 /// Sets the *delegate* property to the given value.
3856 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AlbumPatchCall<'a, C> {
3857 self._delegate = Some(new_value);
3858 self
3859 }
3860
3861 /// Set any additional parameter of the query string used in the request.
3862 /// It should be used to set parameters which are not yet available through their own
3863 /// setters.
3864 ///
3865 /// Please note that this method must not be used to set any of the known parameters
3866 /// which have their own setter method. If done anyway, the request will fail.
3867 ///
3868 /// # Additional Parameters
3869 ///
3870 /// * *$.xgafv* (query-string) - V1 error format.
3871 /// * *access_token* (query-string) - OAuth access token.
3872 /// * *alt* (query-string) - Data format for response.
3873 /// * *callback* (query-string) - JSONP
3874 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3875 /// * *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.
3876 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3877 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3878 /// * *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.
3879 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3880 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3881 pub fn param<T>(mut self, name: T, value: T) -> AlbumPatchCall<'a, C>
3882 where
3883 T: AsRef<str>,
3884 {
3885 self._additional_params
3886 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3887 self
3888 }
3889
3890 /// Identifies the authorization scope for the method you are building.
3891 ///
3892 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3893 /// [`Scope::EditAppcreateddata`].
3894 ///
3895 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3896 /// tokens for more than one scope.
3897 ///
3898 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3899 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3900 /// sufficient, a read-write scope will do as well.
3901 pub fn add_scope<St>(mut self, scope: St) -> AlbumPatchCall<'a, C>
3902 where
3903 St: AsRef<str>,
3904 {
3905 self._scopes.insert(String::from(scope.as_ref()));
3906 self
3907 }
3908 /// Identifies the authorization scope(s) for the method you are building.
3909 ///
3910 /// See [`Self::add_scope()`] for details.
3911 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumPatchCall<'a, C>
3912 where
3913 I: IntoIterator<Item = St>,
3914 St: AsRef<str>,
3915 {
3916 self._scopes
3917 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3918 self
3919 }
3920
3921 /// Removes all scopes, and no default scope will be used either.
3922 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3923 /// for details).
3924 pub fn clear_scopes(mut self) -> AlbumPatchCall<'a, C> {
3925 self._scopes.clear();
3926 self
3927 }
3928}
3929
3930/// Marks an album as shared and accessible to other users. This action can only be performed on albums which were created by the developer via the API.
3931///
3932/// A builder for the *share* method supported by a *album* resource.
3933/// It is not used directly, but through a [`AlbumMethods`] instance.
3934///
3935/// # Example
3936///
3937/// Instantiate a resource method builder
3938///
3939/// ```test_harness,no_run
3940/// # extern crate hyper;
3941/// # extern crate hyper_rustls;
3942/// # extern crate google_photoslibrary1 as photoslibrary1;
3943/// use photoslibrary1::api::ShareAlbumRequest;
3944/// # async fn dox() {
3945/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3946///
3947/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3948/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3949/// # secret,
3950/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3951/// # ).build().await.unwrap();
3952///
3953/// # let client = hyper_util::client::legacy::Client::builder(
3954/// # hyper_util::rt::TokioExecutor::new()
3955/// # )
3956/// # .build(
3957/// # hyper_rustls::HttpsConnectorBuilder::new()
3958/// # .with_native_roots()
3959/// # .unwrap()
3960/// # .https_or_http()
3961/// # .enable_http1()
3962/// # .build()
3963/// # );
3964/// # let mut hub = PhotosLibrary::new(client, auth);
3965/// // As the method needs a request, you would usually fill it with the desired information
3966/// // into the respective structure. Some of the parts shown here might not be applicable !
3967/// // Values shown here are possibly random and not representative !
3968/// let mut req = ShareAlbumRequest::default();
3969///
3970/// // You can configure optional parameters by calling the respective setters at will, and
3971/// // execute the final call using `doit()`.
3972/// // Values shown here are possibly random and not representative !
3973/// let result = hub.albums().share(req, "albumId")
3974/// .doit().await;
3975/// # }
3976/// ```
3977pub struct AlbumShareCall<'a, C>
3978where
3979 C: 'a,
3980{
3981 hub: &'a PhotosLibrary<C>,
3982 _request: ShareAlbumRequest,
3983 _album_id: String,
3984 _delegate: Option<&'a mut dyn common::Delegate>,
3985 _additional_params: HashMap<String, String>,
3986 _scopes: BTreeSet<String>,
3987}
3988
3989impl<'a, C> common::CallBuilder for AlbumShareCall<'a, C> {}
3990
3991impl<'a, C> AlbumShareCall<'a, C>
3992where
3993 C: common::Connector,
3994{
3995 /// Perform the operation you have build so far.
3996 pub async fn doit(mut self) -> common::Result<(common::Response, ShareAlbumResponse)> {
3997 use std::borrow::Cow;
3998 use std::io::{Read, Seek};
3999
4000 use common::{url::Params, ToParts};
4001 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4002
4003 let mut dd = common::DefaultDelegate;
4004 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4005 dlg.begin(common::MethodInfo {
4006 id: "photoslibrary.albums.share",
4007 http_method: hyper::Method::POST,
4008 });
4009
4010 for &field in ["alt", "albumId"].iter() {
4011 if self._additional_params.contains_key(field) {
4012 dlg.finished(false);
4013 return Err(common::Error::FieldClash(field));
4014 }
4015 }
4016
4017 let mut params = Params::with_capacity(4 + self._additional_params.len());
4018 params.push("albumId", self._album_id);
4019
4020 params.extend(self._additional_params.iter());
4021
4022 params.push("alt", "json");
4023 let mut url = self.hub._base_url.clone() + "v1/albums/{+albumId}:share";
4024 if self._scopes.is_empty() {
4025 self._scopes.insert(Scope::Sharing.as_ref().to_string());
4026 }
4027
4028 #[allow(clippy::single_element_loop)]
4029 for &(find_this, param_name) in [("{+albumId}", "albumId")].iter() {
4030 url = params.uri_replacement(url, param_name, find_this, true);
4031 }
4032 {
4033 let to_remove = ["albumId"];
4034 params.remove_params(&to_remove);
4035 }
4036
4037 let url = params.parse_with_url(&url);
4038
4039 let mut json_mime_type = mime::APPLICATION_JSON;
4040 let mut request_value_reader = {
4041 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4042 common::remove_json_null_values(&mut value);
4043 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4044 serde_json::to_writer(&mut dst, &value).unwrap();
4045 dst
4046 };
4047 let request_size = request_value_reader
4048 .seek(std::io::SeekFrom::End(0))
4049 .unwrap();
4050 request_value_reader
4051 .seek(std::io::SeekFrom::Start(0))
4052 .unwrap();
4053
4054 loop {
4055 let token = match self
4056 .hub
4057 .auth
4058 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4059 .await
4060 {
4061 Ok(token) => token,
4062 Err(e) => match dlg.token(e) {
4063 Ok(token) => token,
4064 Err(e) => {
4065 dlg.finished(false);
4066 return Err(common::Error::MissingToken(e));
4067 }
4068 },
4069 };
4070 request_value_reader
4071 .seek(std::io::SeekFrom::Start(0))
4072 .unwrap();
4073 let mut req_result = {
4074 let client = &self.hub.client;
4075 dlg.pre_request();
4076 let mut req_builder = hyper::Request::builder()
4077 .method(hyper::Method::POST)
4078 .uri(url.as_str())
4079 .header(USER_AGENT, self.hub._user_agent.clone());
4080
4081 if let Some(token) = token.as_ref() {
4082 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4083 }
4084
4085 let request = req_builder
4086 .header(CONTENT_TYPE, json_mime_type.to_string())
4087 .header(CONTENT_LENGTH, request_size as u64)
4088 .body(common::to_body(
4089 request_value_reader.get_ref().clone().into(),
4090 ));
4091
4092 client.request(request.unwrap()).await
4093 };
4094
4095 match req_result {
4096 Err(err) => {
4097 if let common::Retry::After(d) = dlg.http_error(&err) {
4098 sleep(d).await;
4099 continue;
4100 }
4101 dlg.finished(false);
4102 return Err(common::Error::HttpError(err));
4103 }
4104 Ok(res) => {
4105 let (mut parts, body) = res.into_parts();
4106 let mut body = common::Body::new(body);
4107 if !parts.status.is_success() {
4108 let bytes = common::to_bytes(body).await.unwrap_or_default();
4109 let error = serde_json::from_str(&common::to_string(&bytes));
4110 let response = common::to_response(parts, bytes.into());
4111
4112 if let common::Retry::After(d) =
4113 dlg.http_failure(&response, error.as_ref().ok())
4114 {
4115 sleep(d).await;
4116 continue;
4117 }
4118
4119 dlg.finished(false);
4120
4121 return Err(match error {
4122 Ok(value) => common::Error::BadRequest(value),
4123 _ => common::Error::Failure(response),
4124 });
4125 }
4126 let response = {
4127 let bytes = common::to_bytes(body).await.unwrap_or_default();
4128 let encoded = common::to_string(&bytes);
4129 match serde_json::from_str(&encoded) {
4130 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4131 Err(error) => {
4132 dlg.response_json_decode_error(&encoded, &error);
4133 return Err(common::Error::JsonDecodeError(
4134 encoded.to_string(),
4135 error,
4136 ));
4137 }
4138 }
4139 };
4140
4141 dlg.finished(true);
4142 return Ok(response);
4143 }
4144 }
4145 }
4146 }
4147
4148 ///
4149 /// Sets the *request* property to the given value.
4150 ///
4151 /// Even though the property as already been set when instantiating this call,
4152 /// we provide this method for API completeness.
4153 pub fn request(mut self, new_value: ShareAlbumRequest) -> AlbumShareCall<'a, C> {
4154 self._request = new_value;
4155 self
4156 }
4157 /// Required. Identifier of the album to be shared. This `albumId` must belong to an album created by the developer.
4158 ///
4159 /// Sets the *album id* path property to the given value.
4160 ///
4161 /// Even though the property as already been set when instantiating this call,
4162 /// we provide this method for API completeness.
4163 pub fn album_id(mut self, new_value: &str) -> AlbumShareCall<'a, C> {
4164 self._album_id = new_value.to_string();
4165 self
4166 }
4167 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4168 /// while executing the actual API request.
4169 ///
4170 /// ````text
4171 /// It should be used to handle progress information, and to implement a certain level of resilience.
4172 /// ````
4173 ///
4174 /// Sets the *delegate* property to the given value.
4175 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AlbumShareCall<'a, C> {
4176 self._delegate = Some(new_value);
4177 self
4178 }
4179
4180 /// Set any additional parameter of the query string used in the request.
4181 /// It should be used to set parameters which are not yet available through their own
4182 /// setters.
4183 ///
4184 /// Please note that this method must not be used to set any of the known parameters
4185 /// which have their own setter method. If done anyway, the request will fail.
4186 ///
4187 /// # Additional Parameters
4188 ///
4189 /// * *$.xgafv* (query-string) - V1 error format.
4190 /// * *access_token* (query-string) - OAuth access token.
4191 /// * *alt* (query-string) - Data format for response.
4192 /// * *callback* (query-string) - JSONP
4193 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4194 /// * *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.
4195 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4196 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4197 /// * *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.
4198 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4199 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4200 pub fn param<T>(mut self, name: T, value: T) -> AlbumShareCall<'a, C>
4201 where
4202 T: AsRef<str>,
4203 {
4204 self._additional_params
4205 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4206 self
4207 }
4208
4209 /// Identifies the authorization scope for the method you are building.
4210 ///
4211 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4212 /// [`Scope::Sharing`].
4213 ///
4214 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4215 /// tokens for more than one scope.
4216 ///
4217 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4218 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4219 /// sufficient, a read-write scope will do as well.
4220 pub fn add_scope<St>(mut self, scope: St) -> AlbumShareCall<'a, C>
4221 where
4222 St: AsRef<str>,
4223 {
4224 self._scopes.insert(String::from(scope.as_ref()));
4225 self
4226 }
4227 /// Identifies the authorization scope(s) for the method you are building.
4228 ///
4229 /// See [`Self::add_scope()`] for details.
4230 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumShareCall<'a, C>
4231 where
4232 I: IntoIterator<Item = St>,
4233 St: AsRef<str>,
4234 {
4235 self._scopes
4236 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4237 self
4238 }
4239
4240 /// Removes all scopes, and no default scope will be used either.
4241 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4242 /// for details).
4243 pub fn clear_scopes(mut self) -> AlbumShareCall<'a, C> {
4244 self._scopes.clear();
4245 self
4246 }
4247}
4248
4249/// Marks a previously shared album as private. This means that the album is no longer shared and all the non-owners will lose access to the album. All non-owner content will be removed from the album. If a non-owner has previously added the album to their library, they will retain all photos in their library. This action can only be performed on albums which were created by the developer via the API.
4250///
4251/// A builder for the *unshare* method supported by a *album* resource.
4252/// It is not used directly, but through a [`AlbumMethods`] instance.
4253///
4254/// # Example
4255///
4256/// Instantiate a resource method builder
4257///
4258/// ```test_harness,no_run
4259/// # extern crate hyper;
4260/// # extern crate hyper_rustls;
4261/// # extern crate google_photoslibrary1 as photoslibrary1;
4262/// use photoslibrary1::api::UnshareAlbumRequest;
4263/// # async fn dox() {
4264/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4265///
4266/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4268/// # secret,
4269/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4270/// # ).build().await.unwrap();
4271///
4272/// # let client = hyper_util::client::legacy::Client::builder(
4273/// # hyper_util::rt::TokioExecutor::new()
4274/// # )
4275/// # .build(
4276/// # hyper_rustls::HttpsConnectorBuilder::new()
4277/// # .with_native_roots()
4278/// # .unwrap()
4279/// # .https_or_http()
4280/// # .enable_http1()
4281/// # .build()
4282/// # );
4283/// # let mut hub = PhotosLibrary::new(client, auth);
4284/// // As the method needs a request, you would usually fill it with the desired information
4285/// // into the respective structure. Some of the parts shown here might not be applicable !
4286/// // Values shown here are possibly random and not representative !
4287/// let mut req = UnshareAlbumRequest::default();
4288///
4289/// // You can configure optional parameters by calling the respective setters at will, and
4290/// // execute the final call using `doit()`.
4291/// // Values shown here are possibly random and not representative !
4292/// let result = hub.albums().unshare(req, "albumId")
4293/// .doit().await;
4294/// # }
4295/// ```
4296pub struct AlbumUnshareCall<'a, C>
4297where
4298 C: 'a,
4299{
4300 hub: &'a PhotosLibrary<C>,
4301 _request: UnshareAlbumRequest,
4302 _album_id: String,
4303 _delegate: Option<&'a mut dyn common::Delegate>,
4304 _additional_params: HashMap<String, String>,
4305 _scopes: BTreeSet<String>,
4306}
4307
4308impl<'a, C> common::CallBuilder for AlbumUnshareCall<'a, C> {}
4309
4310impl<'a, C> AlbumUnshareCall<'a, C>
4311where
4312 C: common::Connector,
4313{
4314 /// Perform the operation you have build so far.
4315 pub async fn doit(mut self) -> common::Result<(common::Response, UnshareAlbumResponse)> {
4316 use std::borrow::Cow;
4317 use std::io::{Read, Seek};
4318
4319 use common::{url::Params, ToParts};
4320 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4321
4322 let mut dd = common::DefaultDelegate;
4323 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4324 dlg.begin(common::MethodInfo {
4325 id: "photoslibrary.albums.unshare",
4326 http_method: hyper::Method::POST,
4327 });
4328
4329 for &field in ["alt", "albumId"].iter() {
4330 if self._additional_params.contains_key(field) {
4331 dlg.finished(false);
4332 return Err(common::Error::FieldClash(field));
4333 }
4334 }
4335
4336 let mut params = Params::with_capacity(4 + self._additional_params.len());
4337 params.push("albumId", self._album_id);
4338
4339 params.extend(self._additional_params.iter());
4340
4341 params.push("alt", "json");
4342 let mut url = self.hub._base_url.clone() + "v1/albums/{+albumId}:unshare";
4343 if self._scopes.is_empty() {
4344 self._scopes.insert(Scope::Sharing.as_ref().to_string());
4345 }
4346
4347 #[allow(clippy::single_element_loop)]
4348 for &(find_this, param_name) in [("{+albumId}", "albumId")].iter() {
4349 url = params.uri_replacement(url, param_name, find_this, true);
4350 }
4351 {
4352 let to_remove = ["albumId"];
4353 params.remove_params(&to_remove);
4354 }
4355
4356 let url = params.parse_with_url(&url);
4357
4358 let mut json_mime_type = mime::APPLICATION_JSON;
4359 let mut request_value_reader = {
4360 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4361 common::remove_json_null_values(&mut value);
4362 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4363 serde_json::to_writer(&mut dst, &value).unwrap();
4364 dst
4365 };
4366 let request_size = request_value_reader
4367 .seek(std::io::SeekFrom::End(0))
4368 .unwrap();
4369 request_value_reader
4370 .seek(std::io::SeekFrom::Start(0))
4371 .unwrap();
4372
4373 loop {
4374 let token = match self
4375 .hub
4376 .auth
4377 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4378 .await
4379 {
4380 Ok(token) => token,
4381 Err(e) => match dlg.token(e) {
4382 Ok(token) => token,
4383 Err(e) => {
4384 dlg.finished(false);
4385 return Err(common::Error::MissingToken(e));
4386 }
4387 },
4388 };
4389 request_value_reader
4390 .seek(std::io::SeekFrom::Start(0))
4391 .unwrap();
4392 let mut req_result = {
4393 let client = &self.hub.client;
4394 dlg.pre_request();
4395 let mut req_builder = hyper::Request::builder()
4396 .method(hyper::Method::POST)
4397 .uri(url.as_str())
4398 .header(USER_AGENT, self.hub._user_agent.clone());
4399
4400 if let Some(token) = token.as_ref() {
4401 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4402 }
4403
4404 let request = req_builder
4405 .header(CONTENT_TYPE, json_mime_type.to_string())
4406 .header(CONTENT_LENGTH, request_size as u64)
4407 .body(common::to_body(
4408 request_value_reader.get_ref().clone().into(),
4409 ));
4410
4411 client.request(request.unwrap()).await
4412 };
4413
4414 match req_result {
4415 Err(err) => {
4416 if let common::Retry::After(d) = dlg.http_error(&err) {
4417 sleep(d).await;
4418 continue;
4419 }
4420 dlg.finished(false);
4421 return Err(common::Error::HttpError(err));
4422 }
4423 Ok(res) => {
4424 let (mut parts, body) = res.into_parts();
4425 let mut body = common::Body::new(body);
4426 if !parts.status.is_success() {
4427 let bytes = common::to_bytes(body).await.unwrap_or_default();
4428 let error = serde_json::from_str(&common::to_string(&bytes));
4429 let response = common::to_response(parts, bytes.into());
4430
4431 if let common::Retry::After(d) =
4432 dlg.http_failure(&response, error.as_ref().ok())
4433 {
4434 sleep(d).await;
4435 continue;
4436 }
4437
4438 dlg.finished(false);
4439
4440 return Err(match error {
4441 Ok(value) => common::Error::BadRequest(value),
4442 _ => common::Error::Failure(response),
4443 });
4444 }
4445 let response = {
4446 let bytes = common::to_bytes(body).await.unwrap_or_default();
4447 let encoded = common::to_string(&bytes);
4448 match serde_json::from_str(&encoded) {
4449 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4450 Err(error) => {
4451 dlg.response_json_decode_error(&encoded, &error);
4452 return Err(common::Error::JsonDecodeError(
4453 encoded.to_string(),
4454 error,
4455 ));
4456 }
4457 }
4458 };
4459
4460 dlg.finished(true);
4461 return Ok(response);
4462 }
4463 }
4464 }
4465 }
4466
4467 ///
4468 /// Sets the *request* property to the given value.
4469 ///
4470 /// Even though the property as already been set when instantiating this call,
4471 /// we provide this method for API completeness.
4472 pub fn request(mut self, new_value: UnshareAlbumRequest) -> AlbumUnshareCall<'a, C> {
4473 self._request = new_value;
4474 self
4475 }
4476 /// Required. Identifier of the album to be unshared. This album id must belong to an album created by the developer.
4477 ///
4478 /// Sets the *album id* path property to the given value.
4479 ///
4480 /// Even though the property as already been set when instantiating this call,
4481 /// we provide this method for API completeness.
4482 pub fn album_id(mut self, new_value: &str) -> AlbumUnshareCall<'a, C> {
4483 self._album_id = new_value.to_string();
4484 self
4485 }
4486 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4487 /// while executing the actual API request.
4488 ///
4489 /// ````text
4490 /// It should be used to handle progress information, and to implement a certain level of resilience.
4491 /// ````
4492 ///
4493 /// Sets the *delegate* property to the given value.
4494 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AlbumUnshareCall<'a, C> {
4495 self._delegate = Some(new_value);
4496 self
4497 }
4498
4499 /// Set any additional parameter of the query string used in the request.
4500 /// It should be used to set parameters which are not yet available through their own
4501 /// setters.
4502 ///
4503 /// Please note that this method must not be used to set any of the known parameters
4504 /// which have their own setter method. If done anyway, the request will fail.
4505 ///
4506 /// # Additional Parameters
4507 ///
4508 /// * *$.xgafv* (query-string) - V1 error format.
4509 /// * *access_token* (query-string) - OAuth access token.
4510 /// * *alt* (query-string) - Data format for response.
4511 /// * *callback* (query-string) - JSONP
4512 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4513 /// * *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.
4514 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4515 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4516 /// * *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.
4517 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4518 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4519 pub fn param<T>(mut self, name: T, value: T) -> AlbumUnshareCall<'a, C>
4520 where
4521 T: AsRef<str>,
4522 {
4523 self._additional_params
4524 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4525 self
4526 }
4527
4528 /// Identifies the authorization scope for the method you are building.
4529 ///
4530 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4531 /// [`Scope::Sharing`].
4532 ///
4533 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4534 /// tokens for more than one scope.
4535 ///
4536 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4537 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4538 /// sufficient, a read-write scope will do as well.
4539 pub fn add_scope<St>(mut self, scope: St) -> AlbumUnshareCall<'a, C>
4540 where
4541 St: AsRef<str>,
4542 {
4543 self._scopes.insert(String::from(scope.as_ref()));
4544 self
4545 }
4546 /// Identifies the authorization scope(s) for the method you are building.
4547 ///
4548 /// See [`Self::add_scope()`] for details.
4549 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlbumUnshareCall<'a, C>
4550 where
4551 I: IntoIterator<Item = St>,
4552 St: AsRef<str>,
4553 {
4554 self._scopes
4555 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4556 self
4557 }
4558
4559 /// Removes all scopes, and no default scope will be used either.
4560 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4561 /// for details).
4562 pub fn clear_scopes(mut self) -> AlbumUnshareCall<'a, C> {
4563 self._scopes.clear();
4564 self
4565 }
4566}
4567
4568/// Creates one or more media items in a user's Google Photos library. This is the second step for creating a media item. For details regarding Step 1, uploading the raw bytes to a Google Server, see Uploading media. This call adds the media item to the library. If an album `id` is specified, the call adds the media item to the album too. Each album can contain up to 20,000 media items. By default, the media item will be added to the end of the library or album. If an album `id` and position are both defined, the media item is added to the album at the specified position. If the call contains multiple media items, they're added at the specified position. If you are creating a media item in a shared album where you are not the owner, you are not allowed to position the media item. Doing so will result in a `BAD REQUEST` error.
4569///
4570/// A builder for the *batchCreate* method supported by a *mediaItem* resource.
4571/// It is not used directly, but through a [`MediaItemMethods`] instance.
4572///
4573/// # Example
4574///
4575/// Instantiate a resource method builder
4576///
4577/// ```test_harness,no_run
4578/// # extern crate hyper;
4579/// # extern crate hyper_rustls;
4580/// # extern crate google_photoslibrary1 as photoslibrary1;
4581/// use photoslibrary1::api::BatchCreateMediaItemsRequest;
4582/// # async fn dox() {
4583/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4584///
4585/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4586/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4587/// # secret,
4588/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4589/// # ).build().await.unwrap();
4590///
4591/// # let client = hyper_util::client::legacy::Client::builder(
4592/// # hyper_util::rt::TokioExecutor::new()
4593/// # )
4594/// # .build(
4595/// # hyper_rustls::HttpsConnectorBuilder::new()
4596/// # .with_native_roots()
4597/// # .unwrap()
4598/// # .https_or_http()
4599/// # .enable_http1()
4600/// # .build()
4601/// # );
4602/// # let mut hub = PhotosLibrary::new(client, auth);
4603/// // As the method needs a request, you would usually fill it with the desired information
4604/// // into the respective structure. Some of the parts shown here might not be applicable !
4605/// // Values shown here are possibly random and not representative !
4606/// let mut req = BatchCreateMediaItemsRequest::default();
4607///
4608/// // You can configure optional parameters by calling the respective setters at will, and
4609/// // execute the final call using `doit()`.
4610/// // Values shown here are possibly random and not representative !
4611/// let result = hub.media_items().batch_create(req)
4612/// .doit().await;
4613/// # }
4614/// ```
4615pub struct MediaItemBatchCreateCall<'a, C>
4616where
4617 C: 'a,
4618{
4619 hub: &'a PhotosLibrary<C>,
4620 _request: BatchCreateMediaItemsRequest,
4621 _delegate: Option<&'a mut dyn common::Delegate>,
4622 _additional_params: HashMap<String, String>,
4623 _scopes: BTreeSet<String>,
4624}
4625
4626impl<'a, C> common::CallBuilder for MediaItemBatchCreateCall<'a, C> {}
4627
4628impl<'a, C> MediaItemBatchCreateCall<'a, C>
4629where
4630 C: common::Connector,
4631{
4632 /// Perform the operation you have build so far.
4633 pub async fn doit(
4634 mut self,
4635 ) -> common::Result<(common::Response, BatchCreateMediaItemsResponse)> {
4636 use std::borrow::Cow;
4637 use std::io::{Read, Seek};
4638
4639 use common::{url::Params, ToParts};
4640 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4641
4642 let mut dd = common::DefaultDelegate;
4643 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4644 dlg.begin(common::MethodInfo {
4645 id: "photoslibrary.mediaItems.batchCreate",
4646 http_method: hyper::Method::POST,
4647 });
4648
4649 for &field in ["alt"].iter() {
4650 if self._additional_params.contains_key(field) {
4651 dlg.finished(false);
4652 return Err(common::Error::FieldClash(field));
4653 }
4654 }
4655
4656 let mut params = Params::with_capacity(3 + self._additional_params.len());
4657
4658 params.extend(self._additional_params.iter());
4659
4660 params.push("alt", "json");
4661 let mut url = self.hub._base_url.clone() + "v1/mediaItems:batchCreate";
4662 if self._scopes.is_empty() {
4663 self._scopes.insert(Scope::Full.as_ref().to_string());
4664 }
4665
4666 let url = params.parse_with_url(&url);
4667
4668 let mut json_mime_type = mime::APPLICATION_JSON;
4669 let mut request_value_reader = {
4670 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4671 common::remove_json_null_values(&mut value);
4672 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4673 serde_json::to_writer(&mut dst, &value).unwrap();
4674 dst
4675 };
4676 let request_size = request_value_reader
4677 .seek(std::io::SeekFrom::End(0))
4678 .unwrap();
4679 request_value_reader
4680 .seek(std::io::SeekFrom::Start(0))
4681 .unwrap();
4682
4683 loop {
4684 let token = match self
4685 .hub
4686 .auth
4687 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4688 .await
4689 {
4690 Ok(token) => token,
4691 Err(e) => match dlg.token(e) {
4692 Ok(token) => token,
4693 Err(e) => {
4694 dlg.finished(false);
4695 return Err(common::Error::MissingToken(e));
4696 }
4697 },
4698 };
4699 request_value_reader
4700 .seek(std::io::SeekFrom::Start(0))
4701 .unwrap();
4702 let mut req_result = {
4703 let client = &self.hub.client;
4704 dlg.pre_request();
4705 let mut req_builder = hyper::Request::builder()
4706 .method(hyper::Method::POST)
4707 .uri(url.as_str())
4708 .header(USER_AGENT, self.hub._user_agent.clone());
4709
4710 if let Some(token) = token.as_ref() {
4711 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4712 }
4713
4714 let request = req_builder
4715 .header(CONTENT_TYPE, json_mime_type.to_string())
4716 .header(CONTENT_LENGTH, request_size as u64)
4717 .body(common::to_body(
4718 request_value_reader.get_ref().clone().into(),
4719 ));
4720
4721 client.request(request.unwrap()).await
4722 };
4723
4724 match req_result {
4725 Err(err) => {
4726 if let common::Retry::After(d) = dlg.http_error(&err) {
4727 sleep(d).await;
4728 continue;
4729 }
4730 dlg.finished(false);
4731 return Err(common::Error::HttpError(err));
4732 }
4733 Ok(res) => {
4734 let (mut parts, body) = res.into_parts();
4735 let mut body = common::Body::new(body);
4736 if !parts.status.is_success() {
4737 let bytes = common::to_bytes(body).await.unwrap_or_default();
4738 let error = serde_json::from_str(&common::to_string(&bytes));
4739 let response = common::to_response(parts, bytes.into());
4740
4741 if let common::Retry::After(d) =
4742 dlg.http_failure(&response, error.as_ref().ok())
4743 {
4744 sleep(d).await;
4745 continue;
4746 }
4747
4748 dlg.finished(false);
4749
4750 return Err(match error {
4751 Ok(value) => common::Error::BadRequest(value),
4752 _ => common::Error::Failure(response),
4753 });
4754 }
4755 let response = {
4756 let bytes = common::to_bytes(body).await.unwrap_or_default();
4757 let encoded = common::to_string(&bytes);
4758 match serde_json::from_str(&encoded) {
4759 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4760 Err(error) => {
4761 dlg.response_json_decode_error(&encoded, &error);
4762 return Err(common::Error::JsonDecodeError(
4763 encoded.to_string(),
4764 error,
4765 ));
4766 }
4767 }
4768 };
4769
4770 dlg.finished(true);
4771 return Ok(response);
4772 }
4773 }
4774 }
4775 }
4776
4777 ///
4778 /// Sets the *request* property to the given value.
4779 ///
4780 /// Even though the property as already been set when instantiating this call,
4781 /// we provide this method for API completeness.
4782 pub fn request(
4783 mut self,
4784 new_value: BatchCreateMediaItemsRequest,
4785 ) -> MediaItemBatchCreateCall<'a, C> {
4786 self._request = new_value;
4787 self
4788 }
4789 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4790 /// while executing the actual API request.
4791 ///
4792 /// ````text
4793 /// It should be used to handle progress information, and to implement a certain level of resilience.
4794 /// ````
4795 ///
4796 /// Sets the *delegate* property to the given value.
4797 pub fn delegate(
4798 mut self,
4799 new_value: &'a mut dyn common::Delegate,
4800 ) -> MediaItemBatchCreateCall<'a, C> {
4801 self._delegate = Some(new_value);
4802 self
4803 }
4804
4805 /// Set any additional parameter of the query string used in the request.
4806 /// It should be used to set parameters which are not yet available through their own
4807 /// setters.
4808 ///
4809 /// Please note that this method must not be used to set any of the known parameters
4810 /// which have their own setter method. If done anyway, the request will fail.
4811 ///
4812 /// # Additional Parameters
4813 ///
4814 /// * *$.xgafv* (query-string) - V1 error format.
4815 /// * *access_token* (query-string) - OAuth access token.
4816 /// * *alt* (query-string) - Data format for response.
4817 /// * *callback* (query-string) - JSONP
4818 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4819 /// * *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.
4820 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4821 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4822 /// * *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.
4823 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4824 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4825 pub fn param<T>(mut self, name: T, value: T) -> MediaItemBatchCreateCall<'a, C>
4826 where
4827 T: AsRef<str>,
4828 {
4829 self._additional_params
4830 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4831 self
4832 }
4833
4834 /// Identifies the authorization scope for the method you are building.
4835 ///
4836 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4837 /// [`Scope::Full`].
4838 ///
4839 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4840 /// tokens for more than one scope.
4841 ///
4842 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4843 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4844 /// sufficient, a read-write scope will do as well.
4845 pub fn add_scope<St>(mut self, scope: St) -> MediaItemBatchCreateCall<'a, C>
4846 where
4847 St: AsRef<str>,
4848 {
4849 self._scopes.insert(String::from(scope.as_ref()));
4850 self
4851 }
4852 /// Identifies the authorization scope(s) for the method you are building.
4853 ///
4854 /// See [`Self::add_scope()`] for details.
4855 pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaItemBatchCreateCall<'a, C>
4856 where
4857 I: IntoIterator<Item = St>,
4858 St: AsRef<str>,
4859 {
4860 self._scopes
4861 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4862 self
4863 }
4864
4865 /// Removes all scopes, and no default scope will be used either.
4866 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4867 /// for details).
4868 pub fn clear_scopes(mut self) -> MediaItemBatchCreateCall<'a, C> {
4869 self._scopes.clear();
4870 self
4871 }
4872}
4873
4874/// Returns the list of media items for the specified media item identifiers. Items are returned in the same order as the supplied identifiers.
4875///
4876/// A builder for the *batchGet* method supported by a *mediaItem* resource.
4877/// It is not used directly, but through a [`MediaItemMethods`] instance.
4878///
4879/// # Example
4880///
4881/// Instantiate a resource method builder
4882///
4883/// ```test_harness,no_run
4884/// # extern crate hyper;
4885/// # extern crate hyper_rustls;
4886/// # extern crate google_photoslibrary1 as photoslibrary1;
4887/// # async fn dox() {
4888/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4889///
4890/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4891/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4892/// # secret,
4893/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4894/// # ).build().await.unwrap();
4895///
4896/// # let client = hyper_util::client::legacy::Client::builder(
4897/// # hyper_util::rt::TokioExecutor::new()
4898/// # )
4899/// # .build(
4900/// # hyper_rustls::HttpsConnectorBuilder::new()
4901/// # .with_native_roots()
4902/// # .unwrap()
4903/// # .https_or_http()
4904/// # .enable_http1()
4905/// # .build()
4906/// # );
4907/// # let mut hub = PhotosLibrary::new(client, auth);
4908/// // You can configure optional parameters by calling the respective setters at will, and
4909/// // execute the final call using `doit()`.
4910/// // Values shown here are possibly random and not representative !
4911/// let result = hub.media_items().batch_get()
4912/// .add_media_item_ids("ipsum")
4913/// .doit().await;
4914/// # }
4915/// ```
4916pub struct MediaItemBatchGetCall<'a, C>
4917where
4918 C: 'a,
4919{
4920 hub: &'a PhotosLibrary<C>,
4921 _media_item_ids: Vec<String>,
4922 _delegate: Option<&'a mut dyn common::Delegate>,
4923 _additional_params: HashMap<String, String>,
4924 _scopes: BTreeSet<String>,
4925}
4926
4927impl<'a, C> common::CallBuilder for MediaItemBatchGetCall<'a, C> {}
4928
4929impl<'a, C> MediaItemBatchGetCall<'a, C>
4930where
4931 C: common::Connector,
4932{
4933 /// Perform the operation you have build so far.
4934 pub async fn doit(mut self) -> common::Result<(common::Response, BatchGetMediaItemsResponse)> {
4935 use std::borrow::Cow;
4936 use std::io::{Read, Seek};
4937
4938 use common::{url::Params, ToParts};
4939 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4940
4941 let mut dd = common::DefaultDelegate;
4942 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4943 dlg.begin(common::MethodInfo {
4944 id: "photoslibrary.mediaItems.batchGet",
4945 http_method: hyper::Method::GET,
4946 });
4947
4948 for &field in ["alt", "mediaItemIds"].iter() {
4949 if self._additional_params.contains_key(field) {
4950 dlg.finished(false);
4951 return Err(common::Error::FieldClash(field));
4952 }
4953 }
4954
4955 let mut params = Params::with_capacity(3 + self._additional_params.len());
4956 if !self._media_item_ids.is_empty() {
4957 for f in self._media_item_ids.iter() {
4958 params.push("mediaItemIds", f);
4959 }
4960 }
4961
4962 params.extend(self._additional_params.iter());
4963
4964 params.push("alt", "json");
4965 let mut url = self.hub._base_url.clone() + "v1/mediaItems:batchGet";
4966 if self._scopes.is_empty() {
4967 self._scopes.insert(Scope::Readonly.as_ref().to_string());
4968 }
4969
4970 let url = params.parse_with_url(&url);
4971
4972 loop {
4973 let token = match self
4974 .hub
4975 .auth
4976 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4977 .await
4978 {
4979 Ok(token) => token,
4980 Err(e) => match dlg.token(e) {
4981 Ok(token) => token,
4982 Err(e) => {
4983 dlg.finished(false);
4984 return Err(common::Error::MissingToken(e));
4985 }
4986 },
4987 };
4988 let mut req_result = {
4989 let client = &self.hub.client;
4990 dlg.pre_request();
4991 let mut req_builder = hyper::Request::builder()
4992 .method(hyper::Method::GET)
4993 .uri(url.as_str())
4994 .header(USER_AGENT, self.hub._user_agent.clone());
4995
4996 if let Some(token) = token.as_ref() {
4997 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4998 }
4999
5000 let request = req_builder
5001 .header(CONTENT_LENGTH, 0_u64)
5002 .body(common::to_body::<String>(None));
5003
5004 client.request(request.unwrap()).await
5005 };
5006
5007 match req_result {
5008 Err(err) => {
5009 if let common::Retry::After(d) = dlg.http_error(&err) {
5010 sleep(d).await;
5011 continue;
5012 }
5013 dlg.finished(false);
5014 return Err(common::Error::HttpError(err));
5015 }
5016 Ok(res) => {
5017 let (mut parts, body) = res.into_parts();
5018 let mut body = common::Body::new(body);
5019 if !parts.status.is_success() {
5020 let bytes = common::to_bytes(body).await.unwrap_or_default();
5021 let error = serde_json::from_str(&common::to_string(&bytes));
5022 let response = common::to_response(parts, bytes.into());
5023
5024 if let common::Retry::After(d) =
5025 dlg.http_failure(&response, error.as_ref().ok())
5026 {
5027 sleep(d).await;
5028 continue;
5029 }
5030
5031 dlg.finished(false);
5032
5033 return Err(match error {
5034 Ok(value) => common::Error::BadRequest(value),
5035 _ => common::Error::Failure(response),
5036 });
5037 }
5038 let response = {
5039 let bytes = common::to_bytes(body).await.unwrap_or_default();
5040 let encoded = common::to_string(&bytes);
5041 match serde_json::from_str(&encoded) {
5042 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5043 Err(error) => {
5044 dlg.response_json_decode_error(&encoded, &error);
5045 return Err(common::Error::JsonDecodeError(
5046 encoded.to_string(),
5047 error,
5048 ));
5049 }
5050 }
5051 };
5052
5053 dlg.finished(true);
5054 return Ok(response);
5055 }
5056 }
5057 }
5058 }
5059
5060 /// Required. Identifiers of the media items to be requested. Must not contain repeated identifiers and cannot be empty. The maximum number of media items that can be retrieved in one call is 50.
5061 ///
5062 /// Append the given value to the *media item ids* query property.
5063 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5064 pub fn add_media_item_ids(mut self, new_value: &str) -> MediaItemBatchGetCall<'a, C> {
5065 self._media_item_ids.push(new_value.to_string());
5066 self
5067 }
5068 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5069 /// while executing the actual API request.
5070 ///
5071 /// ````text
5072 /// It should be used to handle progress information, and to implement a certain level of resilience.
5073 /// ````
5074 ///
5075 /// Sets the *delegate* property to the given value.
5076 pub fn delegate(
5077 mut self,
5078 new_value: &'a mut dyn common::Delegate,
5079 ) -> MediaItemBatchGetCall<'a, C> {
5080 self._delegate = Some(new_value);
5081 self
5082 }
5083
5084 /// Set any additional parameter of the query string used in the request.
5085 /// It should be used to set parameters which are not yet available through their own
5086 /// setters.
5087 ///
5088 /// Please note that this method must not be used to set any of the known parameters
5089 /// which have their own setter method. If done anyway, the request will fail.
5090 ///
5091 /// # Additional Parameters
5092 ///
5093 /// * *$.xgafv* (query-string) - V1 error format.
5094 /// * *access_token* (query-string) - OAuth access token.
5095 /// * *alt* (query-string) - Data format for response.
5096 /// * *callback* (query-string) - JSONP
5097 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5098 /// * *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.
5099 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5100 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5101 /// * *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.
5102 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5103 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5104 pub fn param<T>(mut self, name: T, value: T) -> MediaItemBatchGetCall<'a, C>
5105 where
5106 T: AsRef<str>,
5107 {
5108 self._additional_params
5109 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5110 self
5111 }
5112
5113 /// Identifies the authorization scope for the method you are building.
5114 ///
5115 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5116 /// [`Scope::Readonly`].
5117 ///
5118 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5119 /// tokens for more than one scope.
5120 ///
5121 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5122 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5123 /// sufficient, a read-write scope will do as well.
5124 pub fn add_scope<St>(mut self, scope: St) -> MediaItemBatchGetCall<'a, C>
5125 where
5126 St: AsRef<str>,
5127 {
5128 self._scopes.insert(String::from(scope.as_ref()));
5129 self
5130 }
5131 /// Identifies the authorization scope(s) for the method you are building.
5132 ///
5133 /// See [`Self::add_scope()`] for details.
5134 pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaItemBatchGetCall<'a, C>
5135 where
5136 I: IntoIterator<Item = St>,
5137 St: AsRef<str>,
5138 {
5139 self._scopes
5140 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5141 self
5142 }
5143
5144 /// Removes all scopes, and no default scope will be used either.
5145 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5146 /// for details).
5147 pub fn clear_scopes(mut self) -> MediaItemBatchGetCall<'a, C> {
5148 self._scopes.clear();
5149 self
5150 }
5151}
5152
5153/// Returns the media item for the specified media item identifier.
5154///
5155/// A builder for the *get* method supported by a *mediaItem* resource.
5156/// It is not used directly, but through a [`MediaItemMethods`] instance.
5157///
5158/// # Example
5159///
5160/// Instantiate a resource method builder
5161///
5162/// ```test_harness,no_run
5163/// # extern crate hyper;
5164/// # extern crate hyper_rustls;
5165/// # extern crate google_photoslibrary1 as photoslibrary1;
5166/// # async fn dox() {
5167/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5168///
5169/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5170/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5171/// # secret,
5172/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5173/// # ).build().await.unwrap();
5174///
5175/// # let client = hyper_util::client::legacy::Client::builder(
5176/// # hyper_util::rt::TokioExecutor::new()
5177/// # )
5178/// # .build(
5179/// # hyper_rustls::HttpsConnectorBuilder::new()
5180/// # .with_native_roots()
5181/// # .unwrap()
5182/// # .https_or_http()
5183/// # .enable_http1()
5184/// # .build()
5185/// # );
5186/// # let mut hub = PhotosLibrary::new(client, auth);
5187/// // You can configure optional parameters by calling the respective setters at will, and
5188/// // execute the final call using `doit()`.
5189/// // Values shown here are possibly random and not representative !
5190/// let result = hub.media_items().get("mediaItemId")
5191/// .doit().await;
5192/// # }
5193/// ```
5194pub struct MediaItemGetCall<'a, C>
5195where
5196 C: 'a,
5197{
5198 hub: &'a PhotosLibrary<C>,
5199 _media_item_id: String,
5200 _delegate: Option<&'a mut dyn common::Delegate>,
5201 _additional_params: HashMap<String, String>,
5202 _scopes: BTreeSet<String>,
5203}
5204
5205impl<'a, C> common::CallBuilder for MediaItemGetCall<'a, C> {}
5206
5207impl<'a, C> MediaItemGetCall<'a, C>
5208where
5209 C: common::Connector,
5210{
5211 /// Perform the operation you have build so far.
5212 pub async fn doit(mut self) -> common::Result<(common::Response, MediaItem)> {
5213 use std::borrow::Cow;
5214 use std::io::{Read, Seek};
5215
5216 use common::{url::Params, ToParts};
5217 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5218
5219 let mut dd = common::DefaultDelegate;
5220 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5221 dlg.begin(common::MethodInfo {
5222 id: "photoslibrary.mediaItems.get",
5223 http_method: hyper::Method::GET,
5224 });
5225
5226 for &field in ["alt", "mediaItemId"].iter() {
5227 if self._additional_params.contains_key(field) {
5228 dlg.finished(false);
5229 return Err(common::Error::FieldClash(field));
5230 }
5231 }
5232
5233 let mut params = Params::with_capacity(3 + self._additional_params.len());
5234 params.push("mediaItemId", self._media_item_id);
5235
5236 params.extend(self._additional_params.iter());
5237
5238 params.push("alt", "json");
5239 let mut url = self.hub._base_url.clone() + "v1/mediaItems/{+mediaItemId}";
5240 if self._scopes.is_empty() {
5241 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5242 }
5243
5244 #[allow(clippy::single_element_loop)]
5245 for &(find_this, param_name) in [("{+mediaItemId}", "mediaItemId")].iter() {
5246 url = params.uri_replacement(url, param_name, find_this, true);
5247 }
5248 {
5249 let to_remove = ["mediaItemId"];
5250 params.remove_params(&to_remove);
5251 }
5252
5253 let url = params.parse_with_url(&url);
5254
5255 loop {
5256 let token = match self
5257 .hub
5258 .auth
5259 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5260 .await
5261 {
5262 Ok(token) => token,
5263 Err(e) => match dlg.token(e) {
5264 Ok(token) => token,
5265 Err(e) => {
5266 dlg.finished(false);
5267 return Err(common::Error::MissingToken(e));
5268 }
5269 },
5270 };
5271 let mut req_result = {
5272 let client = &self.hub.client;
5273 dlg.pre_request();
5274 let mut req_builder = hyper::Request::builder()
5275 .method(hyper::Method::GET)
5276 .uri(url.as_str())
5277 .header(USER_AGENT, self.hub._user_agent.clone());
5278
5279 if let Some(token) = token.as_ref() {
5280 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5281 }
5282
5283 let request = req_builder
5284 .header(CONTENT_LENGTH, 0_u64)
5285 .body(common::to_body::<String>(None));
5286
5287 client.request(request.unwrap()).await
5288 };
5289
5290 match req_result {
5291 Err(err) => {
5292 if let common::Retry::After(d) = dlg.http_error(&err) {
5293 sleep(d).await;
5294 continue;
5295 }
5296 dlg.finished(false);
5297 return Err(common::Error::HttpError(err));
5298 }
5299 Ok(res) => {
5300 let (mut parts, body) = res.into_parts();
5301 let mut body = common::Body::new(body);
5302 if !parts.status.is_success() {
5303 let bytes = common::to_bytes(body).await.unwrap_or_default();
5304 let error = serde_json::from_str(&common::to_string(&bytes));
5305 let response = common::to_response(parts, bytes.into());
5306
5307 if let common::Retry::After(d) =
5308 dlg.http_failure(&response, error.as_ref().ok())
5309 {
5310 sleep(d).await;
5311 continue;
5312 }
5313
5314 dlg.finished(false);
5315
5316 return Err(match error {
5317 Ok(value) => common::Error::BadRequest(value),
5318 _ => common::Error::Failure(response),
5319 });
5320 }
5321 let response = {
5322 let bytes = common::to_bytes(body).await.unwrap_or_default();
5323 let encoded = common::to_string(&bytes);
5324 match serde_json::from_str(&encoded) {
5325 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5326 Err(error) => {
5327 dlg.response_json_decode_error(&encoded, &error);
5328 return Err(common::Error::JsonDecodeError(
5329 encoded.to_string(),
5330 error,
5331 ));
5332 }
5333 }
5334 };
5335
5336 dlg.finished(true);
5337 return Ok(response);
5338 }
5339 }
5340 }
5341 }
5342
5343 /// Required. Identifier of the media item to be requested.
5344 ///
5345 /// Sets the *media item id* path property to the given value.
5346 ///
5347 /// Even though the property as already been set when instantiating this call,
5348 /// we provide this method for API completeness.
5349 pub fn media_item_id(mut self, new_value: &str) -> MediaItemGetCall<'a, C> {
5350 self._media_item_id = new_value.to_string();
5351 self
5352 }
5353 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5354 /// while executing the actual API request.
5355 ///
5356 /// ````text
5357 /// It should be used to handle progress information, and to implement a certain level of resilience.
5358 /// ````
5359 ///
5360 /// Sets the *delegate* property to the given value.
5361 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MediaItemGetCall<'a, C> {
5362 self._delegate = Some(new_value);
5363 self
5364 }
5365
5366 /// Set any additional parameter of the query string used in the request.
5367 /// It should be used to set parameters which are not yet available through their own
5368 /// setters.
5369 ///
5370 /// Please note that this method must not be used to set any of the known parameters
5371 /// which have their own setter method. If done anyway, the request will fail.
5372 ///
5373 /// # Additional Parameters
5374 ///
5375 /// * *$.xgafv* (query-string) - V1 error format.
5376 /// * *access_token* (query-string) - OAuth access token.
5377 /// * *alt* (query-string) - Data format for response.
5378 /// * *callback* (query-string) - JSONP
5379 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5380 /// * *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.
5381 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5382 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5383 /// * *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.
5384 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5385 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5386 pub fn param<T>(mut self, name: T, value: T) -> MediaItemGetCall<'a, C>
5387 where
5388 T: AsRef<str>,
5389 {
5390 self._additional_params
5391 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5392 self
5393 }
5394
5395 /// Identifies the authorization scope for the method you are building.
5396 ///
5397 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5398 /// [`Scope::Readonly`].
5399 ///
5400 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5401 /// tokens for more than one scope.
5402 ///
5403 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5404 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5405 /// sufficient, a read-write scope will do as well.
5406 pub fn add_scope<St>(mut self, scope: St) -> MediaItemGetCall<'a, C>
5407 where
5408 St: AsRef<str>,
5409 {
5410 self._scopes.insert(String::from(scope.as_ref()));
5411 self
5412 }
5413 /// Identifies the authorization scope(s) for the method you are building.
5414 ///
5415 /// See [`Self::add_scope()`] for details.
5416 pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaItemGetCall<'a, C>
5417 where
5418 I: IntoIterator<Item = St>,
5419 St: AsRef<str>,
5420 {
5421 self._scopes
5422 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5423 self
5424 }
5425
5426 /// Removes all scopes, and no default scope will be used either.
5427 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5428 /// for details).
5429 pub fn clear_scopes(mut self) -> MediaItemGetCall<'a, C> {
5430 self._scopes.clear();
5431 self
5432 }
5433}
5434
5435/// List all media items from a user's Google Photos library.
5436///
5437/// A builder for the *list* method supported by a *mediaItem* resource.
5438/// It is not used directly, but through a [`MediaItemMethods`] instance.
5439///
5440/// # Example
5441///
5442/// Instantiate a resource method builder
5443///
5444/// ```test_harness,no_run
5445/// # extern crate hyper;
5446/// # extern crate hyper_rustls;
5447/// # extern crate google_photoslibrary1 as photoslibrary1;
5448/// # async fn dox() {
5449/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5450///
5451/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5452/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5453/// # secret,
5454/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5455/// # ).build().await.unwrap();
5456///
5457/// # let client = hyper_util::client::legacy::Client::builder(
5458/// # hyper_util::rt::TokioExecutor::new()
5459/// # )
5460/// # .build(
5461/// # hyper_rustls::HttpsConnectorBuilder::new()
5462/// # .with_native_roots()
5463/// # .unwrap()
5464/// # .https_or_http()
5465/// # .enable_http1()
5466/// # .build()
5467/// # );
5468/// # let mut hub = PhotosLibrary::new(client, auth);
5469/// // You can configure optional parameters by calling the respective setters at will, and
5470/// // execute the final call using `doit()`.
5471/// // Values shown here are possibly random and not representative !
5472/// let result = hub.media_items().list()
5473/// .page_token("ut")
5474/// .page_size(-12)
5475/// .doit().await;
5476/// # }
5477/// ```
5478pub struct MediaItemListCall<'a, C>
5479where
5480 C: 'a,
5481{
5482 hub: &'a PhotosLibrary<C>,
5483 _page_token: Option<String>,
5484 _page_size: Option<i32>,
5485 _delegate: Option<&'a mut dyn common::Delegate>,
5486 _additional_params: HashMap<String, String>,
5487 _scopes: BTreeSet<String>,
5488}
5489
5490impl<'a, C> common::CallBuilder for MediaItemListCall<'a, C> {}
5491
5492impl<'a, C> MediaItemListCall<'a, C>
5493where
5494 C: common::Connector,
5495{
5496 /// Perform the operation you have build so far.
5497 pub async fn doit(mut self) -> common::Result<(common::Response, ListMediaItemsResponse)> {
5498 use std::borrow::Cow;
5499 use std::io::{Read, Seek};
5500
5501 use common::{url::Params, ToParts};
5502 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5503
5504 let mut dd = common::DefaultDelegate;
5505 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5506 dlg.begin(common::MethodInfo {
5507 id: "photoslibrary.mediaItems.list",
5508 http_method: hyper::Method::GET,
5509 });
5510
5511 for &field in ["alt", "pageToken", "pageSize"].iter() {
5512 if self._additional_params.contains_key(field) {
5513 dlg.finished(false);
5514 return Err(common::Error::FieldClash(field));
5515 }
5516 }
5517
5518 let mut params = Params::with_capacity(4 + self._additional_params.len());
5519 if let Some(value) = self._page_token.as_ref() {
5520 params.push("pageToken", value);
5521 }
5522 if let Some(value) = self._page_size.as_ref() {
5523 params.push("pageSize", value.to_string());
5524 }
5525
5526 params.extend(self._additional_params.iter());
5527
5528 params.push("alt", "json");
5529 let mut url = self.hub._base_url.clone() + "v1/mediaItems";
5530 if self._scopes.is_empty() {
5531 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5532 }
5533
5534 let url = params.parse_with_url(&url);
5535
5536 loop {
5537 let token = match self
5538 .hub
5539 .auth
5540 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5541 .await
5542 {
5543 Ok(token) => token,
5544 Err(e) => match dlg.token(e) {
5545 Ok(token) => token,
5546 Err(e) => {
5547 dlg.finished(false);
5548 return Err(common::Error::MissingToken(e));
5549 }
5550 },
5551 };
5552 let mut req_result = {
5553 let client = &self.hub.client;
5554 dlg.pre_request();
5555 let mut req_builder = hyper::Request::builder()
5556 .method(hyper::Method::GET)
5557 .uri(url.as_str())
5558 .header(USER_AGENT, self.hub._user_agent.clone());
5559
5560 if let Some(token) = token.as_ref() {
5561 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5562 }
5563
5564 let request = req_builder
5565 .header(CONTENT_LENGTH, 0_u64)
5566 .body(common::to_body::<String>(None));
5567
5568 client.request(request.unwrap()).await
5569 };
5570
5571 match req_result {
5572 Err(err) => {
5573 if let common::Retry::After(d) = dlg.http_error(&err) {
5574 sleep(d).await;
5575 continue;
5576 }
5577 dlg.finished(false);
5578 return Err(common::Error::HttpError(err));
5579 }
5580 Ok(res) => {
5581 let (mut parts, body) = res.into_parts();
5582 let mut body = common::Body::new(body);
5583 if !parts.status.is_success() {
5584 let bytes = common::to_bytes(body).await.unwrap_or_default();
5585 let error = serde_json::from_str(&common::to_string(&bytes));
5586 let response = common::to_response(parts, bytes.into());
5587
5588 if let common::Retry::After(d) =
5589 dlg.http_failure(&response, error.as_ref().ok())
5590 {
5591 sleep(d).await;
5592 continue;
5593 }
5594
5595 dlg.finished(false);
5596
5597 return Err(match error {
5598 Ok(value) => common::Error::BadRequest(value),
5599 _ => common::Error::Failure(response),
5600 });
5601 }
5602 let response = {
5603 let bytes = common::to_bytes(body).await.unwrap_or_default();
5604 let encoded = common::to_string(&bytes);
5605 match serde_json::from_str(&encoded) {
5606 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5607 Err(error) => {
5608 dlg.response_json_decode_error(&encoded, &error);
5609 return Err(common::Error::JsonDecodeError(
5610 encoded.to_string(),
5611 error,
5612 ));
5613 }
5614 }
5615 };
5616
5617 dlg.finished(true);
5618 return Ok(response);
5619 }
5620 }
5621 }
5622 }
5623
5624 /// A continuation token to get the next page of the results. Adding this to the request returns the rows after the `pageToken`. The `pageToken` should be the value returned in the `nextPageToken` parameter in the response to the `listMediaItems` request.
5625 ///
5626 /// Sets the *page token* query property to the given value.
5627 pub fn page_token(mut self, new_value: &str) -> MediaItemListCall<'a, C> {
5628 self._page_token = Some(new_value.to_string());
5629 self
5630 }
5631 /// Maximum number of media items to return in the response. Fewer media items might be returned than the specified number. The default `pageSize` is 25, the maximum is 100.
5632 ///
5633 /// Sets the *page size* query property to the given value.
5634 pub fn page_size(mut self, new_value: i32) -> MediaItemListCall<'a, C> {
5635 self._page_size = Some(new_value);
5636 self
5637 }
5638 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5639 /// while executing the actual API request.
5640 ///
5641 /// ````text
5642 /// It should be used to handle progress information, and to implement a certain level of resilience.
5643 /// ````
5644 ///
5645 /// Sets the *delegate* property to the given value.
5646 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MediaItemListCall<'a, C> {
5647 self._delegate = Some(new_value);
5648 self
5649 }
5650
5651 /// Set any additional parameter of the query string used in the request.
5652 /// It should be used to set parameters which are not yet available through their own
5653 /// setters.
5654 ///
5655 /// Please note that this method must not be used to set any of the known parameters
5656 /// which have their own setter method. If done anyway, the request will fail.
5657 ///
5658 /// # Additional Parameters
5659 ///
5660 /// * *$.xgafv* (query-string) - V1 error format.
5661 /// * *access_token* (query-string) - OAuth access token.
5662 /// * *alt* (query-string) - Data format for response.
5663 /// * *callback* (query-string) - JSONP
5664 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5665 /// * *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.
5666 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5667 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5668 /// * *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.
5669 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5670 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5671 pub fn param<T>(mut self, name: T, value: T) -> MediaItemListCall<'a, C>
5672 where
5673 T: AsRef<str>,
5674 {
5675 self._additional_params
5676 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5677 self
5678 }
5679
5680 /// Identifies the authorization scope for the method you are building.
5681 ///
5682 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5683 /// [`Scope::Readonly`].
5684 ///
5685 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5686 /// tokens for more than one scope.
5687 ///
5688 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5689 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5690 /// sufficient, a read-write scope will do as well.
5691 pub fn add_scope<St>(mut self, scope: St) -> MediaItemListCall<'a, C>
5692 where
5693 St: AsRef<str>,
5694 {
5695 self._scopes.insert(String::from(scope.as_ref()));
5696 self
5697 }
5698 /// Identifies the authorization scope(s) for the method you are building.
5699 ///
5700 /// See [`Self::add_scope()`] for details.
5701 pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaItemListCall<'a, C>
5702 where
5703 I: IntoIterator<Item = St>,
5704 St: AsRef<str>,
5705 {
5706 self._scopes
5707 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5708 self
5709 }
5710
5711 /// Removes all scopes, and no default scope will be used either.
5712 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5713 /// for details).
5714 pub fn clear_scopes(mut self) -> MediaItemListCall<'a, C> {
5715 self._scopes.clear();
5716 self
5717 }
5718}
5719
5720/// Update the media item with the specified `id`. Only the `id` and `description` fields of the media item are read. The media item must have been created by the developer via the API and must be owned by the user.
5721///
5722/// A builder for the *patch* method supported by a *mediaItem* resource.
5723/// It is not used directly, but through a [`MediaItemMethods`] instance.
5724///
5725/// # Example
5726///
5727/// Instantiate a resource method builder
5728///
5729/// ```test_harness,no_run
5730/// # extern crate hyper;
5731/// # extern crate hyper_rustls;
5732/// # extern crate google_photoslibrary1 as photoslibrary1;
5733/// use photoslibrary1::api::MediaItem;
5734/// # async fn dox() {
5735/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5736///
5737/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5738/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5739/// # secret,
5740/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5741/// # ).build().await.unwrap();
5742///
5743/// # let client = hyper_util::client::legacy::Client::builder(
5744/// # hyper_util::rt::TokioExecutor::new()
5745/// # )
5746/// # .build(
5747/// # hyper_rustls::HttpsConnectorBuilder::new()
5748/// # .with_native_roots()
5749/// # .unwrap()
5750/// # .https_or_http()
5751/// # .enable_http1()
5752/// # .build()
5753/// # );
5754/// # let mut hub = PhotosLibrary::new(client, auth);
5755/// // As the method needs a request, you would usually fill it with the desired information
5756/// // into the respective structure. Some of the parts shown here might not be applicable !
5757/// // Values shown here are possibly random and not representative !
5758/// let mut req = MediaItem::default();
5759///
5760/// // You can configure optional parameters by calling the respective setters at will, and
5761/// // execute the final call using `doit()`.
5762/// // Values shown here are possibly random and not representative !
5763/// let result = hub.media_items().patch(req, "id")
5764/// .update_mask(FieldMask::new::<&str>(&[]))
5765/// .doit().await;
5766/// # }
5767/// ```
5768pub struct MediaItemPatchCall<'a, C>
5769where
5770 C: 'a,
5771{
5772 hub: &'a PhotosLibrary<C>,
5773 _request: MediaItem,
5774 _id: String,
5775 _update_mask: Option<common::FieldMask>,
5776 _delegate: Option<&'a mut dyn common::Delegate>,
5777 _additional_params: HashMap<String, String>,
5778 _scopes: BTreeSet<String>,
5779}
5780
5781impl<'a, C> common::CallBuilder for MediaItemPatchCall<'a, C> {}
5782
5783impl<'a, C> MediaItemPatchCall<'a, C>
5784where
5785 C: common::Connector,
5786{
5787 /// Perform the operation you have build so far.
5788 pub async fn doit(mut self) -> common::Result<(common::Response, MediaItem)> {
5789 use std::borrow::Cow;
5790 use std::io::{Read, Seek};
5791
5792 use common::{url::Params, ToParts};
5793 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5794
5795 let mut dd = common::DefaultDelegate;
5796 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5797 dlg.begin(common::MethodInfo {
5798 id: "photoslibrary.mediaItems.patch",
5799 http_method: hyper::Method::PATCH,
5800 });
5801
5802 for &field in ["alt", "id", "updateMask"].iter() {
5803 if self._additional_params.contains_key(field) {
5804 dlg.finished(false);
5805 return Err(common::Error::FieldClash(field));
5806 }
5807 }
5808
5809 let mut params = Params::with_capacity(5 + self._additional_params.len());
5810 params.push("id", self._id);
5811 if let Some(value) = self._update_mask.as_ref() {
5812 params.push("updateMask", value.to_string());
5813 }
5814
5815 params.extend(self._additional_params.iter());
5816
5817 params.push("alt", "json");
5818 let mut url = self.hub._base_url.clone() + "v1/mediaItems/{+id}";
5819 if self._scopes.is_empty() {
5820 self._scopes
5821 .insert(Scope::EditAppcreateddata.as_ref().to_string());
5822 }
5823
5824 #[allow(clippy::single_element_loop)]
5825 for &(find_this, param_name) in [("{+id}", "id")].iter() {
5826 url = params.uri_replacement(url, param_name, find_this, true);
5827 }
5828 {
5829 let to_remove = ["id"];
5830 params.remove_params(&to_remove);
5831 }
5832
5833 let url = params.parse_with_url(&url);
5834
5835 let mut json_mime_type = mime::APPLICATION_JSON;
5836 let mut request_value_reader = {
5837 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5838 common::remove_json_null_values(&mut value);
5839 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5840 serde_json::to_writer(&mut dst, &value).unwrap();
5841 dst
5842 };
5843 let request_size = request_value_reader
5844 .seek(std::io::SeekFrom::End(0))
5845 .unwrap();
5846 request_value_reader
5847 .seek(std::io::SeekFrom::Start(0))
5848 .unwrap();
5849
5850 loop {
5851 let token = match self
5852 .hub
5853 .auth
5854 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5855 .await
5856 {
5857 Ok(token) => token,
5858 Err(e) => match dlg.token(e) {
5859 Ok(token) => token,
5860 Err(e) => {
5861 dlg.finished(false);
5862 return Err(common::Error::MissingToken(e));
5863 }
5864 },
5865 };
5866 request_value_reader
5867 .seek(std::io::SeekFrom::Start(0))
5868 .unwrap();
5869 let mut req_result = {
5870 let client = &self.hub.client;
5871 dlg.pre_request();
5872 let mut req_builder = hyper::Request::builder()
5873 .method(hyper::Method::PATCH)
5874 .uri(url.as_str())
5875 .header(USER_AGENT, self.hub._user_agent.clone());
5876
5877 if let Some(token) = token.as_ref() {
5878 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5879 }
5880
5881 let request = req_builder
5882 .header(CONTENT_TYPE, json_mime_type.to_string())
5883 .header(CONTENT_LENGTH, request_size as u64)
5884 .body(common::to_body(
5885 request_value_reader.get_ref().clone().into(),
5886 ));
5887
5888 client.request(request.unwrap()).await
5889 };
5890
5891 match req_result {
5892 Err(err) => {
5893 if let common::Retry::After(d) = dlg.http_error(&err) {
5894 sleep(d).await;
5895 continue;
5896 }
5897 dlg.finished(false);
5898 return Err(common::Error::HttpError(err));
5899 }
5900 Ok(res) => {
5901 let (mut parts, body) = res.into_parts();
5902 let mut body = common::Body::new(body);
5903 if !parts.status.is_success() {
5904 let bytes = common::to_bytes(body).await.unwrap_or_default();
5905 let error = serde_json::from_str(&common::to_string(&bytes));
5906 let response = common::to_response(parts, bytes.into());
5907
5908 if let common::Retry::After(d) =
5909 dlg.http_failure(&response, error.as_ref().ok())
5910 {
5911 sleep(d).await;
5912 continue;
5913 }
5914
5915 dlg.finished(false);
5916
5917 return Err(match error {
5918 Ok(value) => common::Error::BadRequest(value),
5919 _ => common::Error::Failure(response),
5920 });
5921 }
5922 let response = {
5923 let bytes = common::to_bytes(body).await.unwrap_or_default();
5924 let encoded = common::to_string(&bytes);
5925 match serde_json::from_str(&encoded) {
5926 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5927 Err(error) => {
5928 dlg.response_json_decode_error(&encoded, &error);
5929 return Err(common::Error::JsonDecodeError(
5930 encoded.to_string(),
5931 error,
5932 ));
5933 }
5934 }
5935 };
5936
5937 dlg.finished(true);
5938 return Ok(response);
5939 }
5940 }
5941 }
5942 }
5943
5944 ///
5945 /// Sets the *request* property to the given value.
5946 ///
5947 /// Even though the property as already been set when instantiating this call,
5948 /// we provide this method for API completeness.
5949 pub fn request(mut self, new_value: MediaItem) -> MediaItemPatchCall<'a, C> {
5950 self._request = new_value;
5951 self
5952 }
5953 /// Identifier for the media item. This is a persistent identifier that can be used between sessions to identify this media item.
5954 ///
5955 /// Sets the *id* path property to the given value.
5956 ///
5957 /// Even though the property as already been set when instantiating this call,
5958 /// we provide this method for API completeness.
5959 pub fn id(mut self, new_value: &str) -> MediaItemPatchCall<'a, C> {
5960 self._id = new_value.to_string();
5961 self
5962 }
5963 /// Required. Indicate what fields in the provided media item to update. The only valid value is `description`.
5964 ///
5965 /// Sets the *update mask* query property to the given value.
5966 pub fn update_mask(mut self, new_value: common::FieldMask) -> MediaItemPatchCall<'a, C> {
5967 self._update_mask = Some(new_value);
5968 self
5969 }
5970 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5971 /// while executing the actual API request.
5972 ///
5973 /// ````text
5974 /// It should be used to handle progress information, and to implement a certain level of resilience.
5975 /// ````
5976 ///
5977 /// Sets the *delegate* property to the given value.
5978 pub fn delegate(
5979 mut self,
5980 new_value: &'a mut dyn common::Delegate,
5981 ) -> MediaItemPatchCall<'a, C> {
5982 self._delegate = Some(new_value);
5983 self
5984 }
5985
5986 /// Set any additional parameter of the query string used in the request.
5987 /// It should be used to set parameters which are not yet available through their own
5988 /// setters.
5989 ///
5990 /// Please note that this method must not be used to set any of the known parameters
5991 /// which have their own setter method. If done anyway, the request will fail.
5992 ///
5993 /// # Additional Parameters
5994 ///
5995 /// * *$.xgafv* (query-string) - V1 error format.
5996 /// * *access_token* (query-string) - OAuth access token.
5997 /// * *alt* (query-string) - Data format for response.
5998 /// * *callback* (query-string) - JSONP
5999 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6000 /// * *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.
6001 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6002 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6003 /// * *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.
6004 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6005 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6006 pub fn param<T>(mut self, name: T, value: T) -> MediaItemPatchCall<'a, C>
6007 where
6008 T: AsRef<str>,
6009 {
6010 self._additional_params
6011 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6012 self
6013 }
6014
6015 /// Identifies the authorization scope for the method you are building.
6016 ///
6017 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6018 /// [`Scope::EditAppcreateddata`].
6019 ///
6020 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6021 /// tokens for more than one scope.
6022 ///
6023 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6024 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6025 /// sufficient, a read-write scope will do as well.
6026 pub fn add_scope<St>(mut self, scope: St) -> MediaItemPatchCall<'a, C>
6027 where
6028 St: AsRef<str>,
6029 {
6030 self._scopes.insert(String::from(scope.as_ref()));
6031 self
6032 }
6033 /// Identifies the authorization scope(s) for the method you are building.
6034 ///
6035 /// See [`Self::add_scope()`] for details.
6036 pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaItemPatchCall<'a, C>
6037 where
6038 I: IntoIterator<Item = St>,
6039 St: AsRef<str>,
6040 {
6041 self._scopes
6042 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6043 self
6044 }
6045
6046 /// Removes all scopes, and no default scope will be used either.
6047 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6048 /// for details).
6049 pub fn clear_scopes(mut self) -> MediaItemPatchCall<'a, C> {
6050 self._scopes.clear();
6051 self
6052 }
6053}
6054
6055/// Searches for media items in a user's Google Photos library. If no filters are set, then all media items in the user's library are returned. If an album is set, all media items in the specified album are returned. If filters are specified, media items that match the filters from the user's library are listed. If you set both the album and the filters, the request results in an error.
6056///
6057/// A builder for the *search* method supported by a *mediaItem* resource.
6058/// It is not used directly, but through a [`MediaItemMethods`] instance.
6059///
6060/// # Example
6061///
6062/// Instantiate a resource method builder
6063///
6064/// ```test_harness,no_run
6065/// # extern crate hyper;
6066/// # extern crate hyper_rustls;
6067/// # extern crate google_photoslibrary1 as photoslibrary1;
6068/// use photoslibrary1::api::SearchMediaItemsRequest;
6069/// # async fn dox() {
6070/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6071///
6072/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6073/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6074/// # secret,
6075/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6076/// # ).build().await.unwrap();
6077///
6078/// # let client = hyper_util::client::legacy::Client::builder(
6079/// # hyper_util::rt::TokioExecutor::new()
6080/// # )
6081/// # .build(
6082/// # hyper_rustls::HttpsConnectorBuilder::new()
6083/// # .with_native_roots()
6084/// # .unwrap()
6085/// # .https_or_http()
6086/// # .enable_http1()
6087/// # .build()
6088/// # );
6089/// # let mut hub = PhotosLibrary::new(client, auth);
6090/// // As the method needs a request, you would usually fill it with the desired information
6091/// // into the respective structure. Some of the parts shown here might not be applicable !
6092/// // Values shown here are possibly random and not representative !
6093/// let mut req = SearchMediaItemsRequest::default();
6094///
6095/// // You can configure optional parameters by calling the respective setters at will, and
6096/// // execute the final call using `doit()`.
6097/// // Values shown here are possibly random and not representative !
6098/// let result = hub.media_items().search(req)
6099/// .doit().await;
6100/// # }
6101/// ```
6102pub struct MediaItemSearchCall<'a, C>
6103where
6104 C: 'a,
6105{
6106 hub: &'a PhotosLibrary<C>,
6107 _request: SearchMediaItemsRequest,
6108 _delegate: Option<&'a mut dyn common::Delegate>,
6109 _additional_params: HashMap<String, String>,
6110 _scopes: BTreeSet<String>,
6111}
6112
6113impl<'a, C> common::CallBuilder for MediaItemSearchCall<'a, C> {}
6114
6115impl<'a, C> MediaItemSearchCall<'a, C>
6116where
6117 C: common::Connector,
6118{
6119 /// Perform the operation you have build so far.
6120 pub async fn doit(mut self) -> common::Result<(common::Response, SearchMediaItemsResponse)> {
6121 use std::borrow::Cow;
6122 use std::io::{Read, Seek};
6123
6124 use common::{url::Params, ToParts};
6125 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6126
6127 let mut dd = common::DefaultDelegate;
6128 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6129 dlg.begin(common::MethodInfo {
6130 id: "photoslibrary.mediaItems.search",
6131 http_method: hyper::Method::POST,
6132 });
6133
6134 for &field in ["alt"].iter() {
6135 if self._additional_params.contains_key(field) {
6136 dlg.finished(false);
6137 return Err(common::Error::FieldClash(field));
6138 }
6139 }
6140
6141 let mut params = Params::with_capacity(3 + self._additional_params.len());
6142
6143 params.extend(self._additional_params.iter());
6144
6145 params.push("alt", "json");
6146 let mut url = self.hub._base_url.clone() + "v1/mediaItems:search";
6147 if self._scopes.is_empty() {
6148 self._scopes.insert(Scope::Full.as_ref().to_string());
6149 }
6150
6151 let url = params.parse_with_url(&url);
6152
6153 let mut json_mime_type = mime::APPLICATION_JSON;
6154 let mut request_value_reader = {
6155 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6156 common::remove_json_null_values(&mut value);
6157 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6158 serde_json::to_writer(&mut dst, &value).unwrap();
6159 dst
6160 };
6161 let request_size = request_value_reader
6162 .seek(std::io::SeekFrom::End(0))
6163 .unwrap();
6164 request_value_reader
6165 .seek(std::io::SeekFrom::Start(0))
6166 .unwrap();
6167
6168 loop {
6169 let token = match self
6170 .hub
6171 .auth
6172 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6173 .await
6174 {
6175 Ok(token) => token,
6176 Err(e) => match dlg.token(e) {
6177 Ok(token) => token,
6178 Err(e) => {
6179 dlg.finished(false);
6180 return Err(common::Error::MissingToken(e));
6181 }
6182 },
6183 };
6184 request_value_reader
6185 .seek(std::io::SeekFrom::Start(0))
6186 .unwrap();
6187 let mut req_result = {
6188 let client = &self.hub.client;
6189 dlg.pre_request();
6190 let mut req_builder = hyper::Request::builder()
6191 .method(hyper::Method::POST)
6192 .uri(url.as_str())
6193 .header(USER_AGENT, self.hub._user_agent.clone());
6194
6195 if let Some(token) = token.as_ref() {
6196 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6197 }
6198
6199 let request = req_builder
6200 .header(CONTENT_TYPE, json_mime_type.to_string())
6201 .header(CONTENT_LENGTH, request_size as u64)
6202 .body(common::to_body(
6203 request_value_reader.get_ref().clone().into(),
6204 ));
6205
6206 client.request(request.unwrap()).await
6207 };
6208
6209 match req_result {
6210 Err(err) => {
6211 if let common::Retry::After(d) = dlg.http_error(&err) {
6212 sleep(d).await;
6213 continue;
6214 }
6215 dlg.finished(false);
6216 return Err(common::Error::HttpError(err));
6217 }
6218 Ok(res) => {
6219 let (mut parts, body) = res.into_parts();
6220 let mut body = common::Body::new(body);
6221 if !parts.status.is_success() {
6222 let bytes = common::to_bytes(body).await.unwrap_or_default();
6223 let error = serde_json::from_str(&common::to_string(&bytes));
6224 let response = common::to_response(parts, bytes.into());
6225
6226 if let common::Retry::After(d) =
6227 dlg.http_failure(&response, error.as_ref().ok())
6228 {
6229 sleep(d).await;
6230 continue;
6231 }
6232
6233 dlg.finished(false);
6234
6235 return Err(match error {
6236 Ok(value) => common::Error::BadRequest(value),
6237 _ => common::Error::Failure(response),
6238 });
6239 }
6240 let response = {
6241 let bytes = common::to_bytes(body).await.unwrap_or_default();
6242 let encoded = common::to_string(&bytes);
6243 match serde_json::from_str(&encoded) {
6244 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6245 Err(error) => {
6246 dlg.response_json_decode_error(&encoded, &error);
6247 return Err(common::Error::JsonDecodeError(
6248 encoded.to_string(),
6249 error,
6250 ));
6251 }
6252 }
6253 };
6254
6255 dlg.finished(true);
6256 return Ok(response);
6257 }
6258 }
6259 }
6260 }
6261
6262 ///
6263 /// Sets the *request* property to the given value.
6264 ///
6265 /// Even though the property as already been set when instantiating this call,
6266 /// we provide this method for API completeness.
6267 pub fn request(mut self, new_value: SearchMediaItemsRequest) -> MediaItemSearchCall<'a, C> {
6268 self._request = new_value;
6269 self
6270 }
6271 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6272 /// while executing the actual API request.
6273 ///
6274 /// ````text
6275 /// It should be used to handle progress information, and to implement a certain level of resilience.
6276 /// ````
6277 ///
6278 /// Sets the *delegate* property to the given value.
6279 pub fn delegate(
6280 mut self,
6281 new_value: &'a mut dyn common::Delegate,
6282 ) -> MediaItemSearchCall<'a, C> {
6283 self._delegate = Some(new_value);
6284 self
6285 }
6286
6287 /// Set any additional parameter of the query string used in the request.
6288 /// It should be used to set parameters which are not yet available through their own
6289 /// setters.
6290 ///
6291 /// Please note that this method must not be used to set any of the known parameters
6292 /// which have their own setter method. If done anyway, the request will fail.
6293 ///
6294 /// # Additional Parameters
6295 ///
6296 /// * *$.xgafv* (query-string) - V1 error format.
6297 /// * *access_token* (query-string) - OAuth access token.
6298 /// * *alt* (query-string) - Data format for response.
6299 /// * *callback* (query-string) - JSONP
6300 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6301 /// * *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.
6302 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6303 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6304 /// * *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.
6305 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6306 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6307 pub fn param<T>(mut self, name: T, value: T) -> MediaItemSearchCall<'a, C>
6308 where
6309 T: AsRef<str>,
6310 {
6311 self._additional_params
6312 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6313 self
6314 }
6315
6316 /// Identifies the authorization scope for the method you are building.
6317 ///
6318 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6319 /// [`Scope::Full`].
6320 ///
6321 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6322 /// tokens for more than one scope.
6323 ///
6324 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6325 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6326 /// sufficient, a read-write scope will do as well.
6327 pub fn add_scope<St>(mut self, scope: St) -> MediaItemSearchCall<'a, C>
6328 where
6329 St: AsRef<str>,
6330 {
6331 self._scopes.insert(String::from(scope.as_ref()));
6332 self
6333 }
6334 /// Identifies the authorization scope(s) for the method you are building.
6335 ///
6336 /// See [`Self::add_scope()`] for details.
6337 pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaItemSearchCall<'a, C>
6338 where
6339 I: IntoIterator<Item = St>,
6340 St: AsRef<str>,
6341 {
6342 self._scopes
6343 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6344 self
6345 }
6346
6347 /// Removes all scopes, and no default scope will be used either.
6348 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6349 /// for details).
6350 pub fn clear_scopes(mut self) -> MediaItemSearchCall<'a, C> {
6351 self._scopes.clear();
6352 self
6353 }
6354}
6355
6356/// Returns the album based on the specified `shareToken`.
6357///
6358/// A builder for the *get* method supported by a *sharedAlbum* resource.
6359/// It is not used directly, but through a [`SharedAlbumMethods`] instance.
6360///
6361/// # Example
6362///
6363/// Instantiate a resource method builder
6364///
6365/// ```test_harness,no_run
6366/// # extern crate hyper;
6367/// # extern crate hyper_rustls;
6368/// # extern crate google_photoslibrary1 as photoslibrary1;
6369/// # async fn dox() {
6370/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6371///
6372/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6373/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6374/// # secret,
6375/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6376/// # ).build().await.unwrap();
6377///
6378/// # let client = hyper_util::client::legacy::Client::builder(
6379/// # hyper_util::rt::TokioExecutor::new()
6380/// # )
6381/// # .build(
6382/// # hyper_rustls::HttpsConnectorBuilder::new()
6383/// # .with_native_roots()
6384/// # .unwrap()
6385/// # .https_or_http()
6386/// # .enable_http1()
6387/// # .build()
6388/// # );
6389/// # let mut hub = PhotosLibrary::new(client, auth);
6390/// // You can configure optional parameters by calling the respective setters at will, and
6391/// // execute the final call using `doit()`.
6392/// // Values shown here are possibly random and not representative !
6393/// let result = hub.shared_albums().get("shareToken")
6394/// .doit().await;
6395/// # }
6396/// ```
6397pub struct SharedAlbumGetCall<'a, C>
6398where
6399 C: 'a,
6400{
6401 hub: &'a PhotosLibrary<C>,
6402 _share_token: String,
6403 _delegate: Option<&'a mut dyn common::Delegate>,
6404 _additional_params: HashMap<String, String>,
6405 _scopes: BTreeSet<String>,
6406}
6407
6408impl<'a, C> common::CallBuilder for SharedAlbumGetCall<'a, C> {}
6409
6410impl<'a, C> SharedAlbumGetCall<'a, C>
6411where
6412 C: common::Connector,
6413{
6414 /// Perform the operation you have build so far.
6415 pub async fn doit(mut self) -> common::Result<(common::Response, Album)> {
6416 use std::borrow::Cow;
6417 use std::io::{Read, Seek};
6418
6419 use common::{url::Params, ToParts};
6420 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6421
6422 let mut dd = common::DefaultDelegate;
6423 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6424 dlg.begin(common::MethodInfo {
6425 id: "photoslibrary.sharedAlbums.get",
6426 http_method: hyper::Method::GET,
6427 });
6428
6429 for &field in ["alt", "shareToken"].iter() {
6430 if self._additional_params.contains_key(field) {
6431 dlg.finished(false);
6432 return Err(common::Error::FieldClash(field));
6433 }
6434 }
6435
6436 let mut params = Params::with_capacity(3 + self._additional_params.len());
6437 params.push("shareToken", self._share_token);
6438
6439 params.extend(self._additional_params.iter());
6440
6441 params.push("alt", "json");
6442 let mut url = self.hub._base_url.clone() + "v1/sharedAlbums/{+shareToken}";
6443 if self._scopes.is_empty() {
6444 self._scopes.insert(Scope::Sharing.as_ref().to_string());
6445 }
6446
6447 #[allow(clippy::single_element_loop)]
6448 for &(find_this, param_name) in [("{+shareToken}", "shareToken")].iter() {
6449 url = params.uri_replacement(url, param_name, find_this, true);
6450 }
6451 {
6452 let to_remove = ["shareToken"];
6453 params.remove_params(&to_remove);
6454 }
6455
6456 let url = params.parse_with_url(&url);
6457
6458 loop {
6459 let token = match self
6460 .hub
6461 .auth
6462 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6463 .await
6464 {
6465 Ok(token) => token,
6466 Err(e) => match dlg.token(e) {
6467 Ok(token) => token,
6468 Err(e) => {
6469 dlg.finished(false);
6470 return Err(common::Error::MissingToken(e));
6471 }
6472 },
6473 };
6474 let mut req_result = {
6475 let client = &self.hub.client;
6476 dlg.pre_request();
6477 let mut req_builder = hyper::Request::builder()
6478 .method(hyper::Method::GET)
6479 .uri(url.as_str())
6480 .header(USER_AGENT, self.hub._user_agent.clone());
6481
6482 if let Some(token) = token.as_ref() {
6483 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6484 }
6485
6486 let request = req_builder
6487 .header(CONTENT_LENGTH, 0_u64)
6488 .body(common::to_body::<String>(None));
6489
6490 client.request(request.unwrap()).await
6491 };
6492
6493 match req_result {
6494 Err(err) => {
6495 if let common::Retry::After(d) = dlg.http_error(&err) {
6496 sleep(d).await;
6497 continue;
6498 }
6499 dlg.finished(false);
6500 return Err(common::Error::HttpError(err));
6501 }
6502 Ok(res) => {
6503 let (mut parts, body) = res.into_parts();
6504 let mut body = common::Body::new(body);
6505 if !parts.status.is_success() {
6506 let bytes = common::to_bytes(body).await.unwrap_or_default();
6507 let error = serde_json::from_str(&common::to_string(&bytes));
6508 let response = common::to_response(parts, bytes.into());
6509
6510 if let common::Retry::After(d) =
6511 dlg.http_failure(&response, error.as_ref().ok())
6512 {
6513 sleep(d).await;
6514 continue;
6515 }
6516
6517 dlg.finished(false);
6518
6519 return Err(match error {
6520 Ok(value) => common::Error::BadRequest(value),
6521 _ => common::Error::Failure(response),
6522 });
6523 }
6524 let response = {
6525 let bytes = common::to_bytes(body).await.unwrap_or_default();
6526 let encoded = common::to_string(&bytes);
6527 match serde_json::from_str(&encoded) {
6528 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6529 Err(error) => {
6530 dlg.response_json_decode_error(&encoded, &error);
6531 return Err(common::Error::JsonDecodeError(
6532 encoded.to_string(),
6533 error,
6534 ));
6535 }
6536 }
6537 };
6538
6539 dlg.finished(true);
6540 return Ok(response);
6541 }
6542 }
6543 }
6544 }
6545
6546 /// Required. Share token of the album to be requested.
6547 ///
6548 /// Sets the *share token* path property to the given value.
6549 ///
6550 /// Even though the property as already been set when instantiating this call,
6551 /// we provide this method for API completeness.
6552 pub fn share_token(mut self, new_value: &str) -> SharedAlbumGetCall<'a, C> {
6553 self._share_token = new_value.to_string();
6554 self
6555 }
6556 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6557 /// while executing the actual API request.
6558 ///
6559 /// ````text
6560 /// It should be used to handle progress information, and to implement a certain level of resilience.
6561 /// ````
6562 ///
6563 /// Sets the *delegate* property to the given value.
6564 pub fn delegate(
6565 mut self,
6566 new_value: &'a mut dyn common::Delegate,
6567 ) -> SharedAlbumGetCall<'a, C> {
6568 self._delegate = Some(new_value);
6569 self
6570 }
6571
6572 /// Set any additional parameter of the query string used in the request.
6573 /// It should be used to set parameters which are not yet available through their own
6574 /// setters.
6575 ///
6576 /// Please note that this method must not be used to set any of the known parameters
6577 /// which have their own setter method. If done anyway, the request will fail.
6578 ///
6579 /// # Additional Parameters
6580 ///
6581 /// * *$.xgafv* (query-string) - V1 error format.
6582 /// * *access_token* (query-string) - OAuth access token.
6583 /// * *alt* (query-string) - Data format for response.
6584 /// * *callback* (query-string) - JSONP
6585 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6586 /// * *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.
6587 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6588 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6589 /// * *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.
6590 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6591 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6592 pub fn param<T>(mut self, name: T, value: T) -> SharedAlbumGetCall<'a, C>
6593 where
6594 T: AsRef<str>,
6595 {
6596 self._additional_params
6597 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6598 self
6599 }
6600
6601 /// Identifies the authorization scope for the method you are building.
6602 ///
6603 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6604 /// [`Scope::Sharing`].
6605 ///
6606 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6607 /// tokens for more than one scope.
6608 ///
6609 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6610 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6611 /// sufficient, a read-write scope will do as well.
6612 pub fn add_scope<St>(mut self, scope: St) -> SharedAlbumGetCall<'a, C>
6613 where
6614 St: AsRef<str>,
6615 {
6616 self._scopes.insert(String::from(scope.as_ref()));
6617 self
6618 }
6619 /// Identifies the authorization scope(s) for the method you are building.
6620 ///
6621 /// See [`Self::add_scope()`] for details.
6622 pub fn add_scopes<I, St>(mut self, scopes: I) -> SharedAlbumGetCall<'a, C>
6623 where
6624 I: IntoIterator<Item = St>,
6625 St: AsRef<str>,
6626 {
6627 self._scopes
6628 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6629 self
6630 }
6631
6632 /// Removes all scopes, and no default scope will be used either.
6633 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6634 /// for details).
6635 pub fn clear_scopes(mut self) -> SharedAlbumGetCall<'a, C> {
6636 self._scopes.clear();
6637 self
6638 }
6639}
6640
6641/// Joins a shared album on behalf of the Google Photos user.
6642///
6643/// A builder for the *join* method supported by a *sharedAlbum* resource.
6644/// It is not used directly, but through a [`SharedAlbumMethods`] instance.
6645///
6646/// # Example
6647///
6648/// Instantiate a resource method builder
6649///
6650/// ```test_harness,no_run
6651/// # extern crate hyper;
6652/// # extern crate hyper_rustls;
6653/// # extern crate google_photoslibrary1 as photoslibrary1;
6654/// use photoslibrary1::api::JoinSharedAlbumRequest;
6655/// # async fn dox() {
6656/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6657///
6658/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6659/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6660/// # secret,
6661/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6662/// # ).build().await.unwrap();
6663///
6664/// # let client = hyper_util::client::legacy::Client::builder(
6665/// # hyper_util::rt::TokioExecutor::new()
6666/// # )
6667/// # .build(
6668/// # hyper_rustls::HttpsConnectorBuilder::new()
6669/// # .with_native_roots()
6670/// # .unwrap()
6671/// # .https_or_http()
6672/// # .enable_http1()
6673/// # .build()
6674/// # );
6675/// # let mut hub = PhotosLibrary::new(client, auth);
6676/// // As the method needs a request, you would usually fill it with the desired information
6677/// // into the respective structure. Some of the parts shown here might not be applicable !
6678/// // Values shown here are possibly random and not representative !
6679/// let mut req = JoinSharedAlbumRequest::default();
6680///
6681/// // You can configure optional parameters by calling the respective setters at will, and
6682/// // execute the final call using `doit()`.
6683/// // Values shown here are possibly random and not representative !
6684/// let result = hub.shared_albums().join(req)
6685/// .doit().await;
6686/// # }
6687/// ```
6688pub struct SharedAlbumJoinCall<'a, C>
6689where
6690 C: 'a,
6691{
6692 hub: &'a PhotosLibrary<C>,
6693 _request: JoinSharedAlbumRequest,
6694 _delegate: Option<&'a mut dyn common::Delegate>,
6695 _additional_params: HashMap<String, String>,
6696 _scopes: BTreeSet<String>,
6697}
6698
6699impl<'a, C> common::CallBuilder for SharedAlbumJoinCall<'a, C> {}
6700
6701impl<'a, C> SharedAlbumJoinCall<'a, C>
6702where
6703 C: common::Connector,
6704{
6705 /// Perform the operation you have build so far.
6706 pub async fn doit(mut self) -> common::Result<(common::Response, JoinSharedAlbumResponse)> {
6707 use std::borrow::Cow;
6708 use std::io::{Read, Seek};
6709
6710 use common::{url::Params, ToParts};
6711 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6712
6713 let mut dd = common::DefaultDelegate;
6714 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6715 dlg.begin(common::MethodInfo {
6716 id: "photoslibrary.sharedAlbums.join",
6717 http_method: hyper::Method::POST,
6718 });
6719
6720 for &field in ["alt"].iter() {
6721 if self._additional_params.contains_key(field) {
6722 dlg.finished(false);
6723 return Err(common::Error::FieldClash(field));
6724 }
6725 }
6726
6727 let mut params = Params::with_capacity(3 + self._additional_params.len());
6728
6729 params.extend(self._additional_params.iter());
6730
6731 params.push("alt", "json");
6732 let mut url = self.hub._base_url.clone() + "v1/sharedAlbums:join";
6733 if self._scopes.is_empty() {
6734 self._scopes.insert(Scope::Sharing.as_ref().to_string());
6735 }
6736
6737 let url = params.parse_with_url(&url);
6738
6739 let mut json_mime_type = mime::APPLICATION_JSON;
6740 let mut request_value_reader = {
6741 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6742 common::remove_json_null_values(&mut value);
6743 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6744 serde_json::to_writer(&mut dst, &value).unwrap();
6745 dst
6746 };
6747 let request_size = request_value_reader
6748 .seek(std::io::SeekFrom::End(0))
6749 .unwrap();
6750 request_value_reader
6751 .seek(std::io::SeekFrom::Start(0))
6752 .unwrap();
6753
6754 loop {
6755 let token = match self
6756 .hub
6757 .auth
6758 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6759 .await
6760 {
6761 Ok(token) => token,
6762 Err(e) => match dlg.token(e) {
6763 Ok(token) => token,
6764 Err(e) => {
6765 dlg.finished(false);
6766 return Err(common::Error::MissingToken(e));
6767 }
6768 },
6769 };
6770 request_value_reader
6771 .seek(std::io::SeekFrom::Start(0))
6772 .unwrap();
6773 let mut req_result = {
6774 let client = &self.hub.client;
6775 dlg.pre_request();
6776 let mut req_builder = hyper::Request::builder()
6777 .method(hyper::Method::POST)
6778 .uri(url.as_str())
6779 .header(USER_AGENT, self.hub._user_agent.clone());
6780
6781 if let Some(token) = token.as_ref() {
6782 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6783 }
6784
6785 let request = req_builder
6786 .header(CONTENT_TYPE, json_mime_type.to_string())
6787 .header(CONTENT_LENGTH, request_size as u64)
6788 .body(common::to_body(
6789 request_value_reader.get_ref().clone().into(),
6790 ));
6791
6792 client.request(request.unwrap()).await
6793 };
6794
6795 match req_result {
6796 Err(err) => {
6797 if let common::Retry::After(d) = dlg.http_error(&err) {
6798 sleep(d).await;
6799 continue;
6800 }
6801 dlg.finished(false);
6802 return Err(common::Error::HttpError(err));
6803 }
6804 Ok(res) => {
6805 let (mut parts, body) = res.into_parts();
6806 let mut body = common::Body::new(body);
6807 if !parts.status.is_success() {
6808 let bytes = common::to_bytes(body).await.unwrap_or_default();
6809 let error = serde_json::from_str(&common::to_string(&bytes));
6810 let response = common::to_response(parts, bytes.into());
6811
6812 if let common::Retry::After(d) =
6813 dlg.http_failure(&response, error.as_ref().ok())
6814 {
6815 sleep(d).await;
6816 continue;
6817 }
6818
6819 dlg.finished(false);
6820
6821 return Err(match error {
6822 Ok(value) => common::Error::BadRequest(value),
6823 _ => common::Error::Failure(response),
6824 });
6825 }
6826 let response = {
6827 let bytes = common::to_bytes(body).await.unwrap_or_default();
6828 let encoded = common::to_string(&bytes);
6829 match serde_json::from_str(&encoded) {
6830 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6831 Err(error) => {
6832 dlg.response_json_decode_error(&encoded, &error);
6833 return Err(common::Error::JsonDecodeError(
6834 encoded.to_string(),
6835 error,
6836 ));
6837 }
6838 }
6839 };
6840
6841 dlg.finished(true);
6842 return Ok(response);
6843 }
6844 }
6845 }
6846 }
6847
6848 ///
6849 /// Sets the *request* property to the given value.
6850 ///
6851 /// Even though the property as already been set when instantiating this call,
6852 /// we provide this method for API completeness.
6853 pub fn request(mut self, new_value: JoinSharedAlbumRequest) -> SharedAlbumJoinCall<'a, C> {
6854 self._request = new_value;
6855 self
6856 }
6857 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6858 /// while executing the actual API request.
6859 ///
6860 /// ````text
6861 /// It should be used to handle progress information, and to implement a certain level of resilience.
6862 /// ````
6863 ///
6864 /// Sets the *delegate* property to the given value.
6865 pub fn delegate(
6866 mut self,
6867 new_value: &'a mut dyn common::Delegate,
6868 ) -> SharedAlbumJoinCall<'a, C> {
6869 self._delegate = Some(new_value);
6870 self
6871 }
6872
6873 /// Set any additional parameter of the query string used in the request.
6874 /// It should be used to set parameters which are not yet available through their own
6875 /// setters.
6876 ///
6877 /// Please note that this method must not be used to set any of the known parameters
6878 /// which have their own setter method. If done anyway, the request will fail.
6879 ///
6880 /// # Additional Parameters
6881 ///
6882 /// * *$.xgafv* (query-string) - V1 error format.
6883 /// * *access_token* (query-string) - OAuth access token.
6884 /// * *alt* (query-string) - Data format for response.
6885 /// * *callback* (query-string) - JSONP
6886 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6887 /// * *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.
6888 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6889 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6890 /// * *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.
6891 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6892 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6893 pub fn param<T>(mut self, name: T, value: T) -> SharedAlbumJoinCall<'a, C>
6894 where
6895 T: AsRef<str>,
6896 {
6897 self._additional_params
6898 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6899 self
6900 }
6901
6902 /// Identifies the authorization scope for the method you are building.
6903 ///
6904 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6905 /// [`Scope::Sharing`].
6906 ///
6907 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6908 /// tokens for more than one scope.
6909 ///
6910 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6911 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6912 /// sufficient, a read-write scope will do as well.
6913 pub fn add_scope<St>(mut self, scope: St) -> SharedAlbumJoinCall<'a, C>
6914 where
6915 St: AsRef<str>,
6916 {
6917 self._scopes.insert(String::from(scope.as_ref()));
6918 self
6919 }
6920 /// Identifies the authorization scope(s) for the method you are building.
6921 ///
6922 /// See [`Self::add_scope()`] for details.
6923 pub fn add_scopes<I, St>(mut self, scopes: I) -> SharedAlbumJoinCall<'a, C>
6924 where
6925 I: IntoIterator<Item = St>,
6926 St: AsRef<str>,
6927 {
6928 self._scopes
6929 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6930 self
6931 }
6932
6933 /// Removes all scopes, and no default scope will be used either.
6934 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6935 /// for details).
6936 pub fn clear_scopes(mut self) -> SharedAlbumJoinCall<'a, C> {
6937 self._scopes.clear();
6938 self
6939 }
6940}
6941
6942/// Leaves a previously-joined shared album on behalf of the Google Photos user. The user must not own this album.
6943///
6944/// A builder for the *leave* method supported by a *sharedAlbum* resource.
6945/// It is not used directly, but through a [`SharedAlbumMethods`] instance.
6946///
6947/// # Example
6948///
6949/// Instantiate a resource method builder
6950///
6951/// ```test_harness,no_run
6952/// # extern crate hyper;
6953/// # extern crate hyper_rustls;
6954/// # extern crate google_photoslibrary1 as photoslibrary1;
6955/// use photoslibrary1::api::LeaveSharedAlbumRequest;
6956/// # async fn dox() {
6957/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6958///
6959/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6960/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6961/// # secret,
6962/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6963/// # ).build().await.unwrap();
6964///
6965/// # let client = hyper_util::client::legacy::Client::builder(
6966/// # hyper_util::rt::TokioExecutor::new()
6967/// # )
6968/// # .build(
6969/// # hyper_rustls::HttpsConnectorBuilder::new()
6970/// # .with_native_roots()
6971/// # .unwrap()
6972/// # .https_or_http()
6973/// # .enable_http1()
6974/// # .build()
6975/// # );
6976/// # let mut hub = PhotosLibrary::new(client, auth);
6977/// // As the method needs a request, you would usually fill it with the desired information
6978/// // into the respective structure. Some of the parts shown here might not be applicable !
6979/// // Values shown here are possibly random and not representative !
6980/// let mut req = LeaveSharedAlbumRequest::default();
6981///
6982/// // You can configure optional parameters by calling the respective setters at will, and
6983/// // execute the final call using `doit()`.
6984/// // Values shown here are possibly random and not representative !
6985/// let result = hub.shared_albums().leave(req)
6986/// .doit().await;
6987/// # }
6988/// ```
6989pub struct SharedAlbumLeaveCall<'a, C>
6990where
6991 C: 'a,
6992{
6993 hub: &'a PhotosLibrary<C>,
6994 _request: LeaveSharedAlbumRequest,
6995 _delegate: Option<&'a mut dyn common::Delegate>,
6996 _additional_params: HashMap<String, String>,
6997 _scopes: BTreeSet<String>,
6998}
6999
7000impl<'a, C> common::CallBuilder for SharedAlbumLeaveCall<'a, C> {}
7001
7002impl<'a, C> SharedAlbumLeaveCall<'a, C>
7003where
7004 C: common::Connector,
7005{
7006 /// Perform the operation you have build so far.
7007 pub async fn doit(mut self) -> common::Result<(common::Response, LeaveSharedAlbumResponse)> {
7008 use std::borrow::Cow;
7009 use std::io::{Read, Seek};
7010
7011 use common::{url::Params, ToParts};
7012 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7013
7014 let mut dd = common::DefaultDelegate;
7015 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7016 dlg.begin(common::MethodInfo {
7017 id: "photoslibrary.sharedAlbums.leave",
7018 http_method: hyper::Method::POST,
7019 });
7020
7021 for &field in ["alt"].iter() {
7022 if self._additional_params.contains_key(field) {
7023 dlg.finished(false);
7024 return Err(common::Error::FieldClash(field));
7025 }
7026 }
7027
7028 let mut params = Params::with_capacity(3 + self._additional_params.len());
7029
7030 params.extend(self._additional_params.iter());
7031
7032 params.push("alt", "json");
7033 let mut url = self.hub._base_url.clone() + "v1/sharedAlbums:leave";
7034 if self._scopes.is_empty() {
7035 self._scopes.insert(Scope::Sharing.as_ref().to_string());
7036 }
7037
7038 let url = params.parse_with_url(&url);
7039
7040 let mut json_mime_type = mime::APPLICATION_JSON;
7041 let mut request_value_reader = {
7042 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7043 common::remove_json_null_values(&mut value);
7044 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7045 serde_json::to_writer(&mut dst, &value).unwrap();
7046 dst
7047 };
7048 let request_size = request_value_reader
7049 .seek(std::io::SeekFrom::End(0))
7050 .unwrap();
7051 request_value_reader
7052 .seek(std::io::SeekFrom::Start(0))
7053 .unwrap();
7054
7055 loop {
7056 let token = match self
7057 .hub
7058 .auth
7059 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7060 .await
7061 {
7062 Ok(token) => token,
7063 Err(e) => match dlg.token(e) {
7064 Ok(token) => token,
7065 Err(e) => {
7066 dlg.finished(false);
7067 return Err(common::Error::MissingToken(e));
7068 }
7069 },
7070 };
7071 request_value_reader
7072 .seek(std::io::SeekFrom::Start(0))
7073 .unwrap();
7074 let mut req_result = {
7075 let client = &self.hub.client;
7076 dlg.pre_request();
7077 let mut req_builder = hyper::Request::builder()
7078 .method(hyper::Method::POST)
7079 .uri(url.as_str())
7080 .header(USER_AGENT, self.hub._user_agent.clone());
7081
7082 if let Some(token) = token.as_ref() {
7083 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7084 }
7085
7086 let request = req_builder
7087 .header(CONTENT_TYPE, json_mime_type.to_string())
7088 .header(CONTENT_LENGTH, request_size as u64)
7089 .body(common::to_body(
7090 request_value_reader.get_ref().clone().into(),
7091 ));
7092
7093 client.request(request.unwrap()).await
7094 };
7095
7096 match req_result {
7097 Err(err) => {
7098 if let common::Retry::After(d) = dlg.http_error(&err) {
7099 sleep(d).await;
7100 continue;
7101 }
7102 dlg.finished(false);
7103 return Err(common::Error::HttpError(err));
7104 }
7105 Ok(res) => {
7106 let (mut parts, body) = res.into_parts();
7107 let mut body = common::Body::new(body);
7108 if !parts.status.is_success() {
7109 let bytes = common::to_bytes(body).await.unwrap_or_default();
7110 let error = serde_json::from_str(&common::to_string(&bytes));
7111 let response = common::to_response(parts, bytes.into());
7112
7113 if let common::Retry::After(d) =
7114 dlg.http_failure(&response, error.as_ref().ok())
7115 {
7116 sleep(d).await;
7117 continue;
7118 }
7119
7120 dlg.finished(false);
7121
7122 return Err(match error {
7123 Ok(value) => common::Error::BadRequest(value),
7124 _ => common::Error::Failure(response),
7125 });
7126 }
7127 let response = {
7128 let bytes = common::to_bytes(body).await.unwrap_or_default();
7129 let encoded = common::to_string(&bytes);
7130 match serde_json::from_str(&encoded) {
7131 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7132 Err(error) => {
7133 dlg.response_json_decode_error(&encoded, &error);
7134 return Err(common::Error::JsonDecodeError(
7135 encoded.to_string(),
7136 error,
7137 ));
7138 }
7139 }
7140 };
7141
7142 dlg.finished(true);
7143 return Ok(response);
7144 }
7145 }
7146 }
7147 }
7148
7149 ///
7150 /// Sets the *request* property to the given value.
7151 ///
7152 /// Even though the property as already been set when instantiating this call,
7153 /// we provide this method for API completeness.
7154 pub fn request(mut self, new_value: LeaveSharedAlbumRequest) -> SharedAlbumLeaveCall<'a, C> {
7155 self._request = new_value;
7156 self
7157 }
7158 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7159 /// while executing the actual API request.
7160 ///
7161 /// ````text
7162 /// It should be used to handle progress information, and to implement a certain level of resilience.
7163 /// ````
7164 ///
7165 /// Sets the *delegate* property to the given value.
7166 pub fn delegate(
7167 mut self,
7168 new_value: &'a mut dyn common::Delegate,
7169 ) -> SharedAlbumLeaveCall<'a, C> {
7170 self._delegate = Some(new_value);
7171 self
7172 }
7173
7174 /// Set any additional parameter of the query string used in the request.
7175 /// It should be used to set parameters which are not yet available through their own
7176 /// setters.
7177 ///
7178 /// Please note that this method must not be used to set any of the known parameters
7179 /// which have their own setter method. If done anyway, the request will fail.
7180 ///
7181 /// # Additional Parameters
7182 ///
7183 /// * *$.xgafv* (query-string) - V1 error format.
7184 /// * *access_token* (query-string) - OAuth access token.
7185 /// * *alt* (query-string) - Data format for response.
7186 /// * *callback* (query-string) - JSONP
7187 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7188 /// * *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.
7189 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7190 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7191 /// * *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.
7192 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7193 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7194 pub fn param<T>(mut self, name: T, value: T) -> SharedAlbumLeaveCall<'a, C>
7195 where
7196 T: AsRef<str>,
7197 {
7198 self._additional_params
7199 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7200 self
7201 }
7202
7203 /// Identifies the authorization scope for the method you are building.
7204 ///
7205 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7206 /// [`Scope::Sharing`].
7207 ///
7208 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7209 /// tokens for more than one scope.
7210 ///
7211 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7212 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7213 /// sufficient, a read-write scope will do as well.
7214 pub fn add_scope<St>(mut self, scope: St) -> SharedAlbumLeaveCall<'a, C>
7215 where
7216 St: AsRef<str>,
7217 {
7218 self._scopes.insert(String::from(scope.as_ref()));
7219 self
7220 }
7221 /// Identifies the authorization scope(s) for the method you are building.
7222 ///
7223 /// See [`Self::add_scope()`] for details.
7224 pub fn add_scopes<I, St>(mut self, scopes: I) -> SharedAlbumLeaveCall<'a, C>
7225 where
7226 I: IntoIterator<Item = St>,
7227 St: AsRef<str>,
7228 {
7229 self._scopes
7230 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7231 self
7232 }
7233
7234 /// Removes all scopes, and no default scope will be used either.
7235 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7236 /// for details).
7237 pub fn clear_scopes(mut self) -> SharedAlbumLeaveCall<'a, C> {
7238 self._scopes.clear();
7239 self
7240 }
7241}
7242
7243/// Lists all shared albums available in the Sharing tab of the user's Google Photos app.
7244///
7245/// A builder for the *list* method supported by a *sharedAlbum* resource.
7246/// It is not used directly, but through a [`SharedAlbumMethods`] instance.
7247///
7248/// # Example
7249///
7250/// Instantiate a resource method builder
7251///
7252/// ```test_harness,no_run
7253/// # extern crate hyper;
7254/// # extern crate hyper_rustls;
7255/// # extern crate google_photoslibrary1 as photoslibrary1;
7256/// # async fn dox() {
7257/// # use photoslibrary1::{PhotosLibrary, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7258///
7259/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7260/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7261/// # secret,
7262/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7263/// # ).build().await.unwrap();
7264///
7265/// # let client = hyper_util::client::legacy::Client::builder(
7266/// # hyper_util::rt::TokioExecutor::new()
7267/// # )
7268/// # .build(
7269/// # hyper_rustls::HttpsConnectorBuilder::new()
7270/// # .with_native_roots()
7271/// # .unwrap()
7272/// # .https_or_http()
7273/// # .enable_http1()
7274/// # .build()
7275/// # );
7276/// # let mut hub = PhotosLibrary::new(client, auth);
7277/// // You can configure optional parameters by calling the respective setters at will, and
7278/// // execute the final call using `doit()`.
7279/// // Values shown here are possibly random and not representative !
7280/// let result = hub.shared_albums().list()
7281/// .page_token("ipsum")
7282/// .page_size(-50)
7283/// .exclude_non_app_created_data(true)
7284/// .doit().await;
7285/// # }
7286/// ```
7287pub struct SharedAlbumListCall<'a, C>
7288where
7289 C: 'a,
7290{
7291 hub: &'a PhotosLibrary<C>,
7292 _page_token: Option<String>,
7293 _page_size: Option<i32>,
7294 _exclude_non_app_created_data: Option<bool>,
7295 _delegate: Option<&'a mut dyn common::Delegate>,
7296 _additional_params: HashMap<String, String>,
7297 _scopes: BTreeSet<String>,
7298}
7299
7300impl<'a, C> common::CallBuilder for SharedAlbumListCall<'a, C> {}
7301
7302impl<'a, C> SharedAlbumListCall<'a, C>
7303where
7304 C: common::Connector,
7305{
7306 /// Perform the operation you have build so far.
7307 pub async fn doit(mut self) -> common::Result<(common::Response, ListSharedAlbumsResponse)> {
7308 use std::borrow::Cow;
7309 use std::io::{Read, Seek};
7310
7311 use common::{url::Params, ToParts};
7312 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7313
7314 let mut dd = common::DefaultDelegate;
7315 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7316 dlg.begin(common::MethodInfo {
7317 id: "photoslibrary.sharedAlbums.list",
7318 http_method: hyper::Method::GET,
7319 });
7320
7321 for &field in ["alt", "pageToken", "pageSize", "excludeNonAppCreatedData"].iter() {
7322 if self._additional_params.contains_key(field) {
7323 dlg.finished(false);
7324 return Err(common::Error::FieldClash(field));
7325 }
7326 }
7327
7328 let mut params = Params::with_capacity(5 + self._additional_params.len());
7329 if let Some(value) = self._page_token.as_ref() {
7330 params.push("pageToken", value);
7331 }
7332 if let Some(value) = self._page_size.as_ref() {
7333 params.push("pageSize", value.to_string());
7334 }
7335 if let Some(value) = self._exclude_non_app_created_data.as_ref() {
7336 params.push("excludeNonAppCreatedData", value.to_string());
7337 }
7338
7339 params.extend(self._additional_params.iter());
7340
7341 params.push("alt", "json");
7342 let mut url = self.hub._base_url.clone() + "v1/sharedAlbums";
7343 if self._scopes.is_empty() {
7344 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7345 }
7346
7347 let url = params.parse_with_url(&url);
7348
7349 loop {
7350 let token = match self
7351 .hub
7352 .auth
7353 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7354 .await
7355 {
7356 Ok(token) => token,
7357 Err(e) => match dlg.token(e) {
7358 Ok(token) => token,
7359 Err(e) => {
7360 dlg.finished(false);
7361 return Err(common::Error::MissingToken(e));
7362 }
7363 },
7364 };
7365 let mut req_result = {
7366 let client = &self.hub.client;
7367 dlg.pre_request();
7368 let mut req_builder = hyper::Request::builder()
7369 .method(hyper::Method::GET)
7370 .uri(url.as_str())
7371 .header(USER_AGENT, self.hub._user_agent.clone());
7372
7373 if let Some(token) = token.as_ref() {
7374 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7375 }
7376
7377 let request = req_builder
7378 .header(CONTENT_LENGTH, 0_u64)
7379 .body(common::to_body::<String>(None));
7380
7381 client.request(request.unwrap()).await
7382 };
7383
7384 match req_result {
7385 Err(err) => {
7386 if let common::Retry::After(d) = dlg.http_error(&err) {
7387 sleep(d).await;
7388 continue;
7389 }
7390 dlg.finished(false);
7391 return Err(common::Error::HttpError(err));
7392 }
7393 Ok(res) => {
7394 let (mut parts, body) = res.into_parts();
7395 let mut body = common::Body::new(body);
7396 if !parts.status.is_success() {
7397 let bytes = common::to_bytes(body).await.unwrap_or_default();
7398 let error = serde_json::from_str(&common::to_string(&bytes));
7399 let response = common::to_response(parts, bytes.into());
7400
7401 if let common::Retry::After(d) =
7402 dlg.http_failure(&response, error.as_ref().ok())
7403 {
7404 sleep(d).await;
7405 continue;
7406 }
7407
7408 dlg.finished(false);
7409
7410 return Err(match error {
7411 Ok(value) => common::Error::BadRequest(value),
7412 _ => common::Error::Failure(response),
7413 });
7414 }
7415 let response = {
7416 let bytes = common::to_bytes(body).await.unwrap_or_default();
7417 let encoded = common::to_string(&bytes);
7418 match serde_json::from_str(&encoded) {
7419 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7420 Err(error) => {
7421 dlg.response_json_decode_error(&encoded, &error);
7422 return Err(common::Error::JsonDecodeError(
7423 encoded.to_string(),
7424 error,
7425 ));
7426 }
7427 }
7428 };
7429
7430 dlg.finished(true);
7431 return Ok(response);
7432 }
7433 }
7434 }
7435 }
7436
7437 /// A continuation token to get the next page of the results. Adding this to the request returns the rows after the `pageToken`. The `pageToken` should be the value returned in the `nextPageToken` parameter in the response to the `listSharedAlbums` request.
7438 ///
7439 /// Sets the *page token* query property to the given value.
7440 pub fn page_token(mut self, new_value: &str) -> SharedAlbumListCall<'a, C> {
7441 self._page_token = Some(new_value.to_string());
7442 self
7443 }
7444 /// Maximum number of albums to return in the response. Fewer albums might be returned than the specified number. The default `pageSize` is 20, the maximum is 50.
7445 ///
7446 /// Sets the *page size* query property to the given value.
7447 pub fn page_size(mut self, new_value: i32) -> SharedAlbumListCall<'a, C> {
7448 self._page_size = Some(new_value);
7449 self
7450 }
7451 /// If set, the results exclude media items that were not created by this app. Defaults to false (all albums are returned). This field is ignored if the photoslibrary.readonly.appcreateddata scope is used.
7452 ///
7453 /// Sets the *exclude non app created data* query property to the given value.
7454 pub fn exclude_non_app_created_data(mut self, new_value: bool) -> SharedAlbumListCall<'a, C> {
7455 self._exclude_non_app_created_data = Some(new_value);
7456 self
7457 }
7458 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7459 /// while executing the actual API request.
7460 ///
7461 /// ````text
7462 /// It should be used to handle progress information, and to implement a certain level of resilience.
7463 /// ````
7464 ///
7465 /// Sets the *delegate* property to the given value.
7466 pub fn delegate(
7467 mut self,
7468 new_value: &'a mut dyn common::Delegate,
7469 ) -> SharedAlbumListCall<'a, C> {
7470 self._delegate = Some(new_value);
7471 self
7472 }
7473
7474 /// Set any additional parameter of the query string used in the request.
7475 /// It should be used to set parameters which are not yet available through their own
7476 /// setters.
7477 ///
7478 /// Please note that this method must not be used to set any of the known parameters
7479 /// which have their own setter method. If done anyway, the request will fail.
7480 ///
7481 /// # Additional Parameters
7482 ///
7483 /// * *$.xgafv* (query-string) - V1 error format.
7484 /// * *access_token* (query-string) - OAuth access token.
7485 /// * *alt* (query-string) - Data format for response.
7486 /// * *callback* (query-string) - JSONP
7487 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7488 /// * *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.
7489 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7490 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7491 /// * *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.
7492 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7493 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7494 pub fn param<T>(mut self, name: T, value: T) -> SharedAlbumListCall<'a, C>
7495 where
7496 T: AsRef<str>,
7497 {
7498 self._additional_params
7499 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7500 self
7501 }
7502
7503 /// Identifies the authorization scope for the method you are building.
7504 ///
7505 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7506 /// [`Scope::Readonly`].
7507 ///
7508 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7509 /// tokens for more than one scope.
7510 ///
7511 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7512 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7513 /// sufficient, a read-write scope will do as well.
7514 pub fn add_scope<St>(mut self, scope: St) -> SharedAlbumListCall<'a, C>
7515 where
7516 St: AsRef<str>,
7517 {
7518 self._scopes.insert(String::from(scope.as_ref()));
7519 self
7520 }
7521 /// Identifies the authorization scope(s) for the method you are building.
7522 ///
7523 /// See [`Self::add_scope()`] for details.
7524 pub fn add_scopes<I, St>(mut self, scopes: I) -> SharedAlbumListCall<'a, C>
7525 where
7526 I: IntoIterator<Item = St>,
7527 St: AsRef<str>,
7528 {
7529 self._scopes
7530 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7531 self
7532 }
7533
7534 /// Removes all scopes, and no default scope will be used either.
7535 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7536 /// for details).
7537 pub fn clear_scopes(mut self) -> SharedAlbumListCall<'a, C> {
7538 self._scopes.clear();
7539 self
7540 }
7541}