google_cloudprivatecatalog1_beta1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// View and manage your data across Google Cloud Platform services
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudPrivateCatalog related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
49/// use cloudprivatecatalog1_beta1::{Result, Error};
50/// # async fn dox() {
51/// use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace  `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62///     .with_native_roots()
63///     .unwrap()
64///     .https_only()
65///     .enable_http2()
66///     .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70///     secret,
71///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72///     yup_oauth2::client::CustomHyperClientBuilder::from(
73///         hyper_util::client::legacy::Client::builder(executor).build(connector),
74///     ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78///     hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81///     hyper_rustls::HttpsConnectorBuilder::new()
82///         .with_native_roots()
83///         .unwrap()
84///         .https_or_http()
85///         .enable_http2()
86///         .build()
87/// );
88/// let mut hub = CloudPrivateCatalog::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.folders().catalogs_search("resource")
93///              .query("takimata")
94///              .page_token("amet.")
95///              .page_size(-20)
96///              .doit().await;
97///
98/// match result {
99///     Err(e) => match e {
100///         // The Error enum provides details about what exactly happened.
101///         // You can also just use its `Debug`, `Display` or `Error` traits
102///          Error::HttpError(_)
103///         |Error::Io(_)
104///         |Error::MissingAPIKey
105///         |Error::MissingToken(_)
106///         |Error::Cancelled
107///         |Error::UploadSizeLimitExceeded(_, _)
108///         |Error::Failure(_)
109///         |Error::BadRequest(_)
110///         |Error::FieldClash(_)
111///         |Error::JsonDecodeError(_, _) => println!("{}", e),
112///     },
113///     Ok(res) => println!("Success: {:?}", res),
114/// }
115/// # }
116/// ```
117#[derive(Clone)]
118pub struct CloudPrivateCatalog<C> {
119    pub client: common::Client<C>,
120    pub auth: Box<dyn common::GetToken>,
121    _user_agent: String,
122    _base_url: String,
123    _root_url: String,
124}
125
126impl<C> common::Hub for CloudPrivateCatalog<C> {}
127
128impl<'a, C> CloudPrivateCatalog<C> {
129    pub fn new<A: 'static + common::GetToken>(
130        client: common::Client<C>,
131        auth: A,
132    ) -> CloudPrivateCatalog<C> {
133        CloudPrivateCatalog {
134            client,
135            auth: Box::new(auth),
136            _user_agent: "google-api-rust-client/7.0.0".to_string(),
137            _base_url: "https://cloudprivatecatalog.googleapis.com/".to_string(),
138            _root_url: "https://cloudprivatecatalog.googleapis.com/".to_string(),
139        }
140    }
141
142    pub fn folders(&'a self) -> FolderMethods<'a, C> {
143        FolderMethods { hub: self }
144    }
145    pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
146        OrganizationMethods { hub: self }
147    }
148    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
149        ProjectMethods { hub: self }
150    }
151
152    /// Set the user-agent header field to use in all requests to the server.
153    /// It defaults to `google-api-rust-client/7.0.0`.
154    ///
155    /// Returns the previously set user-agent.
156    pub fn user_agent(&mut self, agent_name: String) -> String {
157        std::mem::replace(&mut self._user_agent, agent_name)
158    }
159
160    /// Set the base url to use in all requests to the server.
161    /// It defaults to `https://cloudprivatecatalog.googleapis.com/`.
162    ///
163    /// Returns the previously set base url.
164    pub fn base_url(&mut self, new_base_url: String) -> String {
165        std::mem::replace(&mut self._base_url, new_base_url)
166    }
167
168    /// Set the root url to use in all requests to the server.
169    /// It defaults to `https://cloudprivatecatalog.googleapis.com/`.
170    ///
171    /// Returns the previously set root url.
172    pub fn root_url(&mut self, new_root_url: String) -> String {
173        std::mem::replace(&mut self._root_url, new_root_url)
174    }
175}
176
177// ############
178// SCHEMAS ###
179// ##########
180/// The readonly representation of a catalog computed with a given resource
181/// context.
182///
183/// This type is not used in any activity, and only used as *part* of another schema.
184///
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186#[serde_with::serde_as]
187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
188pub struct GoogleCloudPrivatecatalogV1beta1Catalog {
189    /// Output only. The time when the catalog was created.
190    #[serde(rename = "createTime")]
191    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
192    /// Output only. The description of the catalog.
193    pub description: Option<String>,
194    /// Output only. The descriptive name of the catalog as it appears in UIs.
195    #[serde(rename = "displayName")]
196    pub display_name: Option<String>,
197    /// Output only. The resource name of the target catalog, in the format of
198    /// `catalogs/{catalog_id}'.
199    pub name: Option<String>,
200    /// Output only. The time when the catalog was last updated.
201    #[serde(rename = "updateTime")]
202    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
203}
204
205impl common::Part for GoogleCloudPrivatecatalogV1beta1Catalog {}
206
207/// The readonly representation of a product computed with a given resource
208/// context.
209///
210/// This type is not used in any activity, and only used as *part* of another schema.
211///
212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
213#[serde_with::serde_as]
214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
215pub struct GoogleCloudPrivatecatalogV1beta1Product {
216    /// Output only. The type of the product asset. It can be one of the
217    /// following values:
218    ///
219    /// * `google.deploymentmanager.Template`
220    /// * `google.cloudprivatecatalog.ListingOnly`
221    #[serde(rename = "assetType")]
222    pub asset_type: Option<String>,
223    /// Output only. The time when the product was created.
224    #[serde(rename = "createTime")]
225    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
226    /// Output only. The display metadata to describe the product.
227    /// The JSON schema of the metadata differs by Product.asset_type.
228    /// When the type is `google.deploymentmanager.Template`, the schema is as
229    /// follows:
230    ///
231    /// ````
232    /// "$schema": http://json-schema.org/draft-04/schema#
233    /// type: object
234    /// properties:
235    ///   name:
236    ///     type: string
237    ///     minLength: 1
238    ///     maxLength: 64
239    ///   description:
240    ///     type: string
241    ///     minLength: 1
242    ///     maxLength: 2048
243    ///   tagline:
244    ///     type: string
245    ///     minLength: 1
246    ///     maxLength: 100
247    ///   support_info:
248    ///     type: string
249    ///     minLength: 1
250    ///     maxLength: 2048
251    ///   creator:
252    ///     type: string
253    ///     minLength: 1
254    ///     maxLength: 100
255    ///   documentation:
256    ///     type: array
257    ///     items:
258    ///       type: object
259    ///       properties:
260    ///         url:
261    ///           type: string
262    ///           pattern:
263    ///           "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"
264    ///         title:
265    ///           type: string
266    ///           minLength: 1
267    ///           maxLength: 64
268    ///         description:
269    ///           type: string
270    ///           minLength: 1
271    ///           maxLength: 2048
272    /// required:
273    /// - name
274    /// - description
275    /// additionalProperties: false
276    ///
277    /// ````
278    ///
279    /// When the asset type is `google.cloudprivatecatalog.ListingOnly`, the schema
280    /// is as follows:
281    ///
282    /// ````
283    /// "$schema": http://json-schema.org/draft-04/schema#
284    /// type: object
285    /// properties:
286    ///   name:
287    ///     type: string
288    ///     minLength: 1
289    ///     maxLength: 64
290    ///   description:
291    ///     type: string
292    ///     minLength: 1
293    ///     maxLength: 2048
294    ///   tagline:
295    ///     type: string
296    ///     minLength: 1
297    ///     maxLength: 100
298    ///   support_info:
299    ///     type: string
300    ///     minLength: 1
301    ///     maxLength: 2048
302    ///   creator:
303    ///     type: string
304    ///     minLength: 1
305    ///     maxLength: 100
306    ///   documentation:
307    ///     type: array
308    ///     items:
309    ///       type: object
310    ///       properties:
311    ///         url:
312    ///           type: string
313    ///           pattern:
314    ///           "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"
315    ///         title:
316    ///           type: string
317    ///           minLength: 1
318    ///           maxLength: 64
319    ///         description:
320    ///           type: string
321    ///           minLength: 1
322    ///           maxLength: 2048
323    ///   signup_url:
324    ///     type: string
325    ///     pattern:
326    ///     "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"
327    /// required:
328    /// - name
329    /// - description
330    /// - signup_url
331    /// additionalProperties: false
332    /// ````
333    #[serde(rename = "displayMetadata")]
334    pub display_metadata: Option<HashMap<String, serde_json::Value>>,
335    /// Output only. The icon URI of the product.
336    #[serde(rename = "iconUri")]
337    pub icon_uri: Option<String>,
338    /// Output only. The resource name of the target product, in the format of
339    /// `products/a-z*[a-z0-9]'.
340    ///
341    /// A unique identifier for the product under a catalog.
342    pub name: Option<String>,
343    /// Output only. The time when the product was last updated.
344    #[serde(rename = "updateTime")]
345    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
346}
347
348impl common::Part for GoogleCloudPrivatecatalogV1beta1Product {}
349
350/// Response message for PrivateCatalog.SearchCatalogs.
351///
352/// # Activities
353///
354/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
355/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
356///
357/// * [catalogs search folders](FolderCatalogSearchCall) (response)
358/// * [catalogs search organizations](OrganizationCatalogSearchCall) (response)
359/// * [catalogs search projects](ProjectCatalogSearchCall) (response)
360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
361#[serde_with::serde_as]
362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
363pub struct GoogleCloudPrivatecatalogV1beta1SearchCatalogsResponse {
364    /// The `Catalog`s computed from the resource context.
365    pub catalogs: Option<Vec<GoogleCloudPrivatecatalogV1beta1Catalog>>,
366    /// A pagination token returned from a previous call to SearchCatalogs that
367    /// indicates from where listing should continue.
368    /// This field is optional.
369    #[serde(rename = "nextPageToken")]
370    pub next_page_token: Option<String>,
371}
372
373impl common::ResponseResult for GoogleCloudPrivatecatalogV1beta1SearchCatalogsResponse {}
374
375/// Response message for PrivateCatalog.SearchProducts.
376///
377/// # Activities
378///
379/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
380/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
381///
382/// * [products search folders](FolderProductSearchCall) (response)
383/// * [products search organizations](OrganizationProductSearchCall) (response)
384/// * [products search projects](ProjectProductSearchCall) (response)
385#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
386#[serde_with::serde_as]
387#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
388pub struct GoogleCloudPrivatecatalogV1beta1SearchProductsResponse {
389    /// A pagination token returned from a previous call to SearchProducts that
390    /// indicates from where listing should continue.
391    /// This field is optional.
392    #[serde(rename = "nextPageToken")]
393    pub next_page_token: Option<String>,
394    /// The `Product` resources computed from the resource context.
395    pub products: Option<Vec<GoogleCloudPrivatecatalogV1beta1Product>>,
396}
397
398impl common::ResponseResult for GoogleCloudPrivatecatalogV1beta1SearchProductsResponse {}
399
400/// Response message for PrivateCatalog.SearchVersions.
401///
402/// # Activities
403///
404/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
405/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
406///
407/// * [versions search folders](FolderVersionSearchCall) (response)
408/// * [versions search organizations](OrganizationVersionSearchCall) (response)
409/// * [versions search projects](ProjectVersionSearchCall) (response)
410#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
411#[serde_with::serde_as]
412#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
413pub struct GoogleCloudPrivatecatalogV1beta1SearchVersionsResponse {
414    /// A pagination token returned from a previous call to SearchVersions that
415    /// indicates from where the listing should continue.
416    /// This field is optional.
417    #[serde(rename = "nextPageToken")]
418    pub next_page_token: Option<String>,
419    /// The `Version` resources computed from the resource context.
420    pub versions: Option<Vec<GoogleCloudPrivatecatalogV1beta1Version>>,
421}
422
423impl common::ResponseResult for GoogleCloudPrivatecatalogV1beta1SearchVersionsResponse {}
424
425/// The consumer representation of a version which is a child resource under a
426/// `Product` with asset data.
427///
428/// This type is not used in any activity, and only used as *part* of another schema.
429///
430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
431#[serde_with::serde_as]
432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
433pub struct GoogleCloudPrivatecatalogV1beta1Version {
434    /// Output only. The asset which has been validated and is ready to be
435    /// provisioned. See
436    /// google.cloud.privatecatalogproducer.v1beta.Version.asset for details.
437    pub asset: Option<HashMap<String, serde_json::Value>>,
438    /// Output only. The time when the version was created.
439    #[serde(rename = "createTime")]
440    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
441    /// Output only. The user-supplied description of the version. Maximum of 256
442    /// characters.
443    pub description: Option<String>,
444    /// Output only. The resource name of the version, in the format
445    /// `catalogs/{catalog_id}/products/{product_id}/versions/a-z*[a-z0-9]'.
446    ///
447    /// A unique identifier for the version under a product.
448    pub name: Option<String>,
449    /// Output only. The time when the version was last updated.
450    #[serde(rename = "updateTime")]
451    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
452}
453
454impl common::Part for GoogleCloudPrivatecatalogV1beta1Version {}
455
456// ###################
457// MethodBuilders ###
458// #################
459
460/// A builder providing access to all methods supported on *folder* resources.
461/// It is not used directly, but through the [`CloudPrivateCatalog`] hub.
462///
463/// # Example
464///
465/// Instantiate a resource builder
466///
467/// ```test_harness,no_run
468/// extern crate hyper;
469/// extern crate hyper_rustls;
470/// extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
471///
472/// # async fn dox() {
473/// use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
474///
475/// let secret: yup_oauth2::ApplicationSecret = Default::default();
476/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
477///     .with_native_roots()
478///     .unwrap()
479///     .https_only()
480///     .enable_http2()
481///     .build();
482///
483/// let executor = hyper_util::rt::TokioExecutor::new();
484/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
485///     secret,
486///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
487///     yup_oauth2::client::CustomHyperClientBuilder::from(
488///         hyper_util::client::legacy::Client::builder(executor).build(connector),
489///     ),
490/// ).build().await.unwrap();
491///
492/// let client = hyper_util::client::legacy::Client::builder(
493///     hyper_util::rt::TokioExecutor::new()
494/// )
495/// .build(
496///     hyper_rustls::HttpsConnectorBuilder::new()
497///         .with_native_roots()
498///         .unwrap()
499///         .https_or_http()
500///         .enable_http2()
501///         .build()
502/// );
503/// let mut hub = CloudPrivateCatalog::new(client, auth);
504/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
505/// // like `catalogs_search(...)`, `products_search(...)` and `versions_search(...)`
506/// // to build up your call.
507/// let rb = hub.folders();
508/// # }
509/// ```
510pub struct FolderMethods<'a, C>
511where
512    C: 'a,
513{
514    hub: &'a CloudPrivateCatalog<C>,
515}
516
517impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
518
519impl<'a, C> FolderMethods<'a, C> {
520    /// Create a builder to help you perform the following task:
521    ///
522    /// Search Catalog resources that consumers have access to, within the
523    /// scope of the consumer cloud resource hierarchy context.
524    ///
525    /// # Arguments
526    ///
527    /// * `resource` - Required. The name of the resource context. It can be in following formats:
528    ///                * `projects/{project_id}`
529    ///                * `folders/{folder_id}`
530    ///                * `organizations/{organization_id}`
531    pub fn catalogs_search(&self, resource: &str) -> FolderCatalogSearchCall<'a, C> {
532        FolderCatalogSearchCall {
533            hub: self.hub,
534            _resource: resource.to_string(),
535            _query: Default::default(),
536            _page_token: Default::default(),
537            _page_size: Default::default(),
538            _delegate: Default::default(),
539            _additional_params: Default::default(),
540            _scopes: Default::default(),
541        }
542    }
543
544    /// Create a builder to help you perform the following task:
545    ///
546    /// Search Product resources that consumers have access to, within the
547    /// scope of the consumer cloud resource hierarchy context.
548    ///
549    /// # Arguments
550    ///
551    /// * `resource` - Required. The name of the resource context. See
552    ///                SearchCatalogsRequest.resource for details.
553    pub fn products_search(&self, resource: &str) -> FolderProductSearchCall<'a, C> {
554        FolderProductSearchCall {
555            hub: self.hub,
556            _resource: resource.to_string(),
557            _query: Default::default(),
558            _page_token: Default::default(),
559            _page_size: Default::default(),
560            _delegate: Default::default(),
561            _additional_params: Default::default(),
562            _scopes: Default::default(),
563        }
564    }
565
566    /// Create a builder to help you perform the following task:
567    ///
568    /// Search Version resources that consumers have access to, within the
569    /// scope of the consumer cloud resource hierarchy context.
570    ///
571    /// # Arguments
572    ///
573    /// * `resource` - Required. The name of the resource context. See
574    ///                SearchCatalogsRequest.resource for details.
575    pub fn versions_search(&self, resource: &str) -> FolderVersionSearchCall<'a, C> {
576        FolderVersionSearchCall {
577            hub: self.hub,
578            _resource: resource.to_string(),
579            _query: Default::default(),
580            _page_token: Default::default(),
581            _page_size: Default::default(),
582            _delegate: Default::default(),
583            _additional_params: Default::default(),
584            _scopes: Default::default(),
585        }
586    }
587}
588
589/// A builder providing access to all methods supported on *organization* resources.
590/// It is not used directly, but through the [`CloudPrivateCatalog`] hub.
591///
592/// # Example
593///
594/// Instantiate a resource builder
595///
596/// ```test_harness,no_run
597/// extern crate hyper;
598/// extern crate hyper_rustls;
599/// extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
600///
601/// # async fn dox() {
602/// use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
603///
604/// let secret: yup_oauth2::ApplicationSecret = Default::default();
605/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
606///     .with_native_roots()
607///     .unwrap()
608///     .https_only()
609///     .enable_http2()
610///     .build();
611///
612/// let executor = hyper_util::rt::TokioExecutor::new();
613/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
614///     secret,
615///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
616///     yup_oauth2::client::CustomHyperClientBuilder::from(
617///         hyper_util::client::legacy::Client::builder(executor).build(connector),
618///     ),
619/// ).build().await.unwrap();
620///
621/// let client = hyper_util::client::legacy::Client::builder(
622///     hyper_util::rt::TokioExecutor::new()
623/// )
624/// .build(
625///     hyper_rustls::HttpsConnectorBuilder::new()
626///         .with_native_roots()
627///         .unwrap()
628///         .https_or_http()
629///         .enable_http2()
630///         .build()
631/// );
632/// let mut hub = CloudPrivateCatalog::new(client, auth);
633/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
634/// // like `catalogs_search(...)`, `products_search(...)` and `versions_search(...)`
635/// // to build up your call.
636/// let rb = hub.organizations();
637/// # }
638/// ```
639pub struct OrganizationMethods<'a, C>
640where
641    C: 'a,
642{
643    hub: &'a CloudPrivateCatalog<C>,
644}
645
646impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
647
648impl<'a, C> OrganizationMethods<'a, C> {
649    /// Create a builder to help you perform the following task:
650    ///
651    /// Search Catalog resources that consumers have access to, within the
652    /// scope of the consumer cloud resource hierarchy context.
653    ///
654    /// # Arguments
655    ///
656    /// * `resource` - Required. The name of the resource context. It can be in following formats:
657    ///                * `projects/{project_id}`
658    ///                * `folders/{folder_id}`
659    ///                * `organizations/{organization_id}`
660    pub fn catalogs_search(&self, resource: &str) -> OrganizationCatalogSearchCall<'a, C> {
661        OrganizationCatalogSearchCall {
662            hub: self.hub,
663            _resource: resource.to_string(),
664            _query: Default::default(),
665            _page_token: Default::default(),
666            _page_size: Default::default(),
667            _delegate: Default::default(),
668            _additional_params: Default::default(),
669            _scopes: Default::default(),
670        }
671    }
672
673    /// Create a builder to help you perform the following task:
674    ///
675    /// Search Product resources that consumers have access to, within the
676    /// scope of the consumer cloud resource hierarchy context.
677    ///
678    /// # Arguments
679    ///
680    /// * `resource` - Required. The name of the resource context. See
681    ///                SearchCatalogsRequest.resource for details.
682    pub fn products_search(&self, resource: &str) -> OrganizationProductSearchCall<'a, C> {
683        OrganizationProductSearchCall {
684            hub: self.hub,
685            _resource: resource.to_string(),
686            _query: Default::default(),
687            _page_token: Default::default(),
688            _page_size: Default::default(),
689            _delegate: Default::default(),
690            _additional_params: Default::default(),
691            _scopes: Default::default(),
692        }
693    }
694
695    /// Create a builder to help you perform the following task:
696    ///
697    /// Search Version resources that consumers have access to, within the
698    /// scope of the consumer cloud resource hierarchy context.
699    ///
700    /// # Arguments
701    ///
702    /// * `resource` - Required. The name of the resource context. See
703    ///                SearchCatalogsRequest.resource for details.
704    pub fn versions_search(&self, resource: &str) -> OrganizationVersionSearchCall<'a, C> {
705        OrganizationVersionSearchCall {
706            hub: self.hub,
707            _resource: resource.to_string(),
708            _query: Default::default(),
709            _page_token: Default::default(),
710            _page_size: Default::default(),
711            _delegate: Default::default(),
712            _additional_params: Default::default(),
713            _scopes: Default::default(),
714        }
715    }
716}
717
718/// A builder providing access to all methods supported on *project* resources.
719/// It is not used directly, but through the [`CloudPrivateCatalog`] hub.
720///
721/// # Example
722///
723/// Instantiate a resource builder
724///
725/// ```test_harness,no_run
726/// extern crate hyper;
727/// extern crate hyper_rustls;
728/// extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
729///
730/// # async fn dox() {
731/// use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
732///
733/// let secret: yup_oauth2::ApplicationSecret = Default::default();
734/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
735///     .with_native_roots()
736///     .unwrap()
737///     .https_only()
738///     .enable_http2()
739///     .build();
740///
741/// let executor = hyper_util::rt::TokioExecutor::new();
742/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
743///     secret,
744///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
745///     yup_oauth2::client::CustomHyperClientBuilder::from(
746///         hyper_util::client::legacy::Client::builder(executor).build(connector),
747///     ),
748/// ).build().await.unwrap();
749///
750/// let client = hyper_util::client::legacy::Client::builder(
751///     hyper_util::rt::TokioExecutor::new()
752/// )
753/// .build(
754///     hyper_rustls::HttpsConnectorBuilder::new()
755///         .with_native_roots()
756///         .unwrap()
757///         .https_or_http()
758///         .enable_http2()
759///         .build()
760/// );
761/// let mut hub = CloudPrivateCatalog::new(client, auth);
762/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
763/// // like `catalogs_search(...)`, `products_search(...)` and `versions_search(...)`
764/// // to build up your call.
765/// let rb = hub.projects();
766/// # }
767/// ```
768pub struct ProjectMethods<'a, C>
769where
770    C: 'a,
771{
772    hub: &'a CloudPrivateCatalog<C>,
773}
774
775impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
776
777impl<'a, C> ProjectMethods<'a, C> {
778    /// Create a builder to help you perform the following task:
779    ///
780    /// Search Catalog resources that consumers have access to, within the
781    /// scope of the consumer cloud resource hierarchy context.
782    ///
783    /// # Arguments
784    ///
785    /// * `resource` - Required. The name of the resource context. It can be in following formats:
786    ///                * `projects/{project_id}`
787    ///                * `folders/{folder_id}`
788    ///                * `organizations/{organization_id}`
789    pub fn catalogs_search(&self, resource: &str) -> ProjectCatalogSearchCall<'a, C> {
790        ProjectCatalogSearchCall {
791            hub: self.hub,
792            _resource: resource.to_string(),
793            _query: Default::default(),
794            _page_token: Default::default(),
795            _page_size: Default::default(),
796            _delegate: Default::default(),
797            _additional_params: Default::default(),
798            _scopes: Default::default(),
799        }
800    }
801
802    /// Create a builder to help you perform the following task:
803    ///
804    /// Search Product resources that consumers have access to, within the
805    /// scope of the consumer cloud resource hierarchy context.
806    ///
807    /// # Arguments
808    ///
809    /// * `resource` - Required. The name of the resource context. See
810    ///                SearchCatalogsRequest.resource for details.
811    pub fn products_search(&self, resource: &str) -> ProjectProductSearchCall<'a, C> {
812        ProjectProductSearchCall {
813            hub: self.hub,
814            _resource: resource.to_string(),
815            _query: Default::default(),
816            _page_token: Default::default(),
817            _page_size: Default::default(),
818            _delegate: Default::default(),
819            _additional_params: Default::default(),
820            _scopes: Default::default(),
821        }
822    }
823
824    /// Create a builder to help you perform the following task:
825    ///
826    /// Search Version resources that consumers have access to, within the
827    /// scope of the consumer cloud resource hierarchy context.
828    ///
829    /// # Arguments
830    ///
831    /// * `resource` - Required. The name of the resource context. See
832    ///                SearchCatalogsRequest.resource for details.
833    pub fn versions_search(&self, resource: &str) -> ProjectVersionSearchCall<'a, C> {
834        ProjectVersionSearchCall {
835            hub: self.hub,
836            _resource: resource.to_string(),
837            _query: Default::default(),
838            _page_token: Default::default(),
839            _page_size: Default::default(),
840            _delegate: Default::default(),
841            _additional_params: Default::default(),
842            _scopes: Default::default(),
843        }
844    }
845}
846
847// ###################
848// CallBuilders   ###
849// #################
850
851/// Search Catalog resources that consumers have access to, within the
852/// scope of the consumer cloud resource hierarchy context.
853///
854/// A builder for the *catalogs.search* method supported by a *folder* resource.
855/// It is not used directly, but through a [`FolderMethods`] instance.
856///
857/// # Example
858///
859/// Instantiate a resource method builder
860///
861/// ```test_harness,no_run
862/// # extern crate hyper;
863/// # extern crate hyper_rustls;
864/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
865/// # async fn dox() {
866/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
867///
868/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
869/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
870/// #     .with_native_roots()
871/// #     .unwrap()
872/// #     .https_only()
873/// #     .enable_http2()
874/// #     .build();
875///
876/// # let executor = hyper_util::rt::TokioExecutor::new();
877/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
878/// #     secret,
879/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
880/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
881/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
882/// #     ),
883/// # ).build().await.unwrap();
884///
885/// # let client = hyper_util::client::legacy::Client::builder(
886/// #     hyper_util::rt::TokioExecutor::new()
887/// # )
888/// # .build(
889/// #     hyper_rustls::HttpsConnectorBuilder::new()
890/// #         .with_native_roots()
891/// #         .unwrap()
892/// #         .https_or_http()
893/// #         .enable_http2()
894/// #         .build()
895/// # );
896/// # let mut hub = CloudPrivateCatalog::new(client, auth);
897/// // You can configure optional parameters by calling the respective setters at will, and
898/// // execute the final call using `doit()`.
899/// // Values shown here are possibly random and not representative !
900/// let result = hub.folders().catalogs_search("resource")
901///              .query("gubergren")
902///              .page_token("Lorem")
903///              .page_size(-12)
904///              .doit().await;
905/// # }
906/// ```
907pub struct FolderCatalogSearchCall<'a, C>
908where
909    C: 'a,
910{
911    hub: &'a CloudPrivateCatalog<C>,
912    _resource: String,
913    _query: Option<String>,
914    _page_token: Option<String>,
915    _page_size: Option<i32>,
916    _delegate: Option<&'a mut dyn common::Delegate>,
917    _additional_params: HashMap<String, String>,
918    _scopes: BTreeSet<String>,
919}
920
921impl<'a, C> common::CallBuilder for FolderCatalogSearchCall<'a, C> {}
922
923impl<'a, C> FolderCatalogSearchCall<'a, C>
924where
925    C: common::Connector,
926{
927    /// Perform the operation you have build so far.
928    pub async fn doit(
929        mut self,
930    ) -> common::Result<(
931        common::Response,
932        GoogleCloudPrivatecatalogV1beta1SearchCatalogsResponse,
933    )> {
934        use std::borrow::Cow;
935        use std::io::{Read, Seek};
936
937        use common::{url::Params, ToParts};
938        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
939
940        let mut dd = common::DefaultDelegate;
941        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
942        dlg.begin(common::MethodInfo {
943            id: "cloudprivatecatalog.folders.catalogs.search",
944            http_method: hyper::Method::GET,
945        });
946
947        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
948            if self._additional_params.contains_key(field) {
949                dlg.finished(false);
950                return Err(common::Error::FieldClash(field));
951            }
952        }
953
954        let mut params = Params::with_capacity(6 + self._additional_params.len());
955        params.push("resource", self._resource);
956        if let Some(value) = self._query.as_ref() {
957            params.push("query", value);
958        }
959        if let Some(value) = self._page_token.as_ref() {
960            params.push("pageToken", value);
961        }
962        if let Some(value) = self._page_size.as_ref() {
963            params.push("pageSize", value.to_string());
964        }
965
966        params.extend(self._additional_params.iter());
967
968        params.push("alt", "json");
969        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/catalogs:search";
970        if self._scopes.is_empty() {
971            self._scopes
972                .insert(Scope::CloudPlatform.as_ref().to_string());
973        }
974
975        #[allow(clippy::single_element_loop)]
976        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
977            url = params.uri_replacement(url, param_name, find_this, true);
978        }
979        {
980            let to_remove = ["resource"];
981            params.remove_params(&to_remove);
982        }
983
984        let url = params.parse_with_url(&url);
985
986        loop {
987            let token = match self
988                .hub
989                .auth
990                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
991                .await
992            {
993                Ok(token) => token,
994                Err(e) => match dlg.token(e) {
995                    Ok(token) => token,
996                    Err(e) => {
997                        dlg.finished(false);
998                        return Err(common::Error::MissingToken(e));
999                    }
1000                },
1001            };
1002            let mut req_result = {
1003                let client = &self.hub.client;
1004                dlg.pre_request();
1005                let mut req_builder = hyper::Request::builder()
1006                    .method(hyper::Method::GET)
1007                    .uri(url.as_str())
1008                    .header(USER_AGENT, self.hub._user_agent.clone());
1009
1010                if let Some(token) = token.as_ref() {
1011                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1012                }
1013
1014                let request = req_builder
1015                    .header(CONTENT_LENGTH, 0_u64)
1016                    .body(common::to_body::<String>(None));
1017
1018                client.request(request.unwrap()).await
1019            };
1020
1021            match req_result {
1022                Err(err) => {
1023                    if let common::Retry::After(d) = dlg.http_error(&err) {
1024                        sleep(d).await;
1025                        continue;
1026                    }
1027                    dlg.finished(false);
1028                    return Err(common::Error::HttpError(err));
1029                }
1030                Ok(res) => {
1031                    let (mut parts, body) = res.into_parts();
1032                    let mut body = common::Body::new(body);
1033                    if !parts.status.is_success() {
1034                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1035                        let error = serde_json::from_str(&common::to_string(&bytes));
1036                        let response = common::to_response(parts, bytes.into());
1037
1038                        if let common::Retry::After(d) =
1039                            dlg.http_failure(&response, error.as_ref().ok())
1040                        {
1041                            sleep(d).await;
1042                            continue;
1043                        }
1044
1045                        dlg.finished(false);
1046
1047                        return Err(match error {
1048                            Ok(value) => common::Error::BadRequest(value),
1049                            _ => common::Error::Failure(response),
1050                        });
1051                    }
1052                    let response = {
1053                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1054                        let encoded = common::to_string(&bytes);
1055                        match serde_json::from_str(&encoded) {
1056                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1057                            Err(error) => {
1058                                dlg.response_json_decode_error(&encoded, &error);
1059                                return Err(common::Error::JsonDecodeError(
1060                                    encoded.to_string(),
1061                                    error,
1062                                ));
1063                            }
1064                        }
1065                    };
1066
1067                    dlg.finished(true);
1068                    return Ok(response);
1069                }
1070            }
1071        }
1072    }
1073
1074    /// Required. The name of the resource context. It can be in following formats:
1075    ///
1076    /// * `projects/{project_id}`
1077    /// * `folders/{folder_id}`
1078    /// * `organizations/{organization_id}`
1079    ///
1080    /// Sets the *resource* path property to the given value.
1081    ///
1082    /// Even though the property as already been set when instantiating this call,
1083    /// we provide this method for API completeness.
1084    pub fn resource(mut self, new_value: &str) -> FolderCatalogSearchCall<'a, C> {
1085        self._resource = new_value.to_string();
1086        self
1087    }
1088    /// The query to filter the catalogs. The supported queries are:
1089    ///
1090    /// * Get a single catalog: `name=catalogs/{catalog_id}`
1091    ///
1092    /// Sets the *query* query property to the given value.
1093    pub fn query(mut self, new_value: &str) -> FolderCatalogSearchCall<'a, C> {
1094        self._query = Some(new_value.to_string());
1095        self
1096    }
1097    /// A pagination token returned from a previous call to SearchCatalogs that
1098    /// indicates where this listing should continue from.
1099    /// This field is optional.
1100    ///
1101    /// Sets the *page token* query property to the given value.
1102    pub fn page_token(mut self, new_value: &str) -> FolderCatalogSearchCall<'a, C> {
1103        self._page_token = Some(new_value.to_string());
1104        self
1105    }
1106    /// The maximum number of entries that are requested.
1107    ///
1108    /// Sets the *page size* query property to the given value.
1109    pub fn page_size(mut self, new_value: i32) -> FolderCatalogSearchCall<'a, C> {
1110        self._page_size = Some(new_value);
1111        self
1112    }
1113    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1114    /// while executing the actual API request.
1115    ///
1116    /// ````text
1117    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1118    /// ````
1119    ///
1120    /// Sets the *delegate* property to the given value.
1121    pub fn delegate(
1122        mut self,
1123        new_value: &'a mut dyn common::Delegate,
1124    ) -> FolderCatalogSearchCall<'a, C> {
1125        self._delegate = Some(new_value);
1126        self
1127    }
1128
1129    /// Set any additional parameter of the query string used in the request.
1130    /// It should be used to set parameters which are not yet available through their own
1131    /// setters.
1132    ///
1133    /// Please note that this method must not be used to set any of the known parameters
1134    /// which have their own setter method. If done anyway, the request will fail.
1135    ///
1136    /// # Additional Parameters
1137    ///
1138    /// * *$.xgafv* (query-string) - V1 error format.
1139    /// * *access_token* (query-string) - OAuth access token.
1140    /// * *alt* (query-string) - Data format for response.
1141    /// * *callback* (query-string) - JSONP
1142    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1143    /// * *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.
1144    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1145    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1146    /// * *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.
1147    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1148    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1149    pub fn param<T>(mut self, name: T, value: T) -> FolderCatalogSearchCall<'a, C>
1150    where
1151        T: AsRef<str>,
1152    {
1153        self._additional_params
1154            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1155        self
1156    }
1157
1158    /// Identifies the authorization scope for the method you are building.
1159    ///
1160    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1161    /// [`Scope::CloudPlatform`].
1162    ///
1163    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1164    /// tokens for more than one scope.
1165    ///
1166    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1167    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1168    /// sufficient, a read-write scope will do as well.
1169    pub fn add_scope<St>(mut self, scope: St) -> FolderCatalogSearchCall<'a, C>
1170    where
1171        St: AsRef<str>,
1172    {
1173        self._scopes.insert(String::from(scope.as_ref()));
1174        self
1175    }
1176    /// Identifies the authorization scope(s) for the method you are building.
1177    ///
1178    /// See [`Self::add_scope()`] for details.
1179    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderCatalogSearchCall<'a, C>
1180    where
1181        I: IntoIterator<Item = St>,
1182        St: AsRef<str>,
1183    {
1184        self._scopes
1185            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1186        self
1187    }
1188
1189    /// Removes all scopes, and no default scope will be used either.
1190    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1191    /// for details).
1192    pub fn clear_scopes(mut self) -> FolderCatalogSearchCall<'a, C> {
1193        self._scopes.clear();
1194        self
1195    }
1196}
1197
1198/// Search Product resources that consumers have access to, within the
1199/// scope of the consumer cloud resource hierarchy context.
1200///
1201/// A builder for the *products.search* method supported by a *folder* resource.
1202/// It is not used directly, but through a [`FolderMethods`] instance.
1203///
1204/// # Example
1205///
1206/// Instantiate a resource method builder
1207///
1208/// ```test_harness,no_run
1209/// # extern crate hyper;
1210/// # extern crate hyper_rustls;
1211/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
1212/// # async fn dox() {
1213/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1214///
1215/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1216/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1217/// #     .with_native_roots()
1218/// #     .unwrap()
1219/// #     .https_only()
1220/// #     .enable_http2()
1221/// #     .build();
1222///
1223/// # let executor = hyper_util::rt::TokioExecutor::new();
1224/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1225/// #     secret,
1226/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1227/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1228/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1229/// #     ),
1230/// # ).build().await.unwrap();
1231///
1232/// # let client = hyper_util::client::legacy::Client::builder(
1233/// #     hyper_util::rt::TokioExecutor::new()
1234/// # )
1235/// # .build(
1236/// #     hyper_rustls::HttpsConnectorBuilder::new()
1237/// #         .with_native_roots()
1238/// #         .unwrap()
1239/// #         .https_or_http()
1240/// #         .enable_http2()
1241/// #         .build()
1242/// # );
1243/// # let mut hub = CloudPrivateCatalog::new(client, auth);
1244/// // You can configure optional parameters by calling the respective setters at will, and
1245/// // execute the final call using `doit()`.
1246/// // Values shown here are possibly random and not representative !
1247/// let result = hub.folders().products_search("resource")
1248///              .query("dolor")
1249///              .page_token("ea")
1250///              .page_size(-55)
1251///              .doit().await;
1252/// # }
1253/// ```
1254pub struct FolderProductSearchCall<'a, C>
1255where
1256    C: 'a,
1257{
1258    hub: &'a CloudPrivateCatalog<C>,
1259    _resource: String,
1260    _query: Option<String>,
1261    _page_token: Option<String>,
1262    _page_size: Option<i32>,
1263    _delegate: Option<&'a mut dyn common::Delegate>,
1264    _additional_params: HashMap<String, String>,
1265    _scopes: BTreeSet<String>,
1266}
1267
1268impl<'a, C> common::CallBuilder for FolderProductSearchCall<'a, C> {}
1269
1270impl<'a, C> FolderProductSearchCall<'a, C>
1271where
1272    C: common::Connector,
1273{
1274    /// Perform the operation you have build so far.
1275    pub async fn doit(
1276        mut self,
1277    ) -> common::Result<(
1278        common::Response,
1279        GoogleCloudPrivatecatalogV1beta1SearchProductsResponse,
1280    )> {
1281        use std::borrow::Cow;
1282        use std::io::{Read, Seek};
1283
1284        use common::{url::Params, ToParts};
1285        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1286
1287        let mut dd = common::DefaultDelegate;
1288        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1289        dlg.begin(common::MethodInfo {
1290            id: "cloudprivatecatalog.folders.products.search",
1291            http_method: hyper::Method::GET,
1292        });
1293
1294        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
1295            if self._additional_params.contains_key(field) {
1296                dlg.finished(false);
1297                return Err(common::Error::FieldClash(field));
1298            }
1299        }
1300
1301        let mut params = Params::with_capacity(6 + self._additional_params.len());
1302        params.push("resource", self._resource);
1303        if let Some(value) = self._query.as_ref() {
1304            params.push("query", value);
1305        }
1306        if let Some(value) = self._page_token.as_ref() {
1307            params.push("pageToken", value);
1308        }
1309        if let Some(value) = self._page_size.as_ref() {
1310            params.push("pageSize", value.to_string());
1311        }
1312
1313        params.extend(self._additional_params.iter());
1314
1315        params.push("alt", "json");
1316        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/products:search";
1317        if self._scopes.is_empty() {
1318            self._scopes
1319                .insert(Scope::CloudPlatform.as_ref().to_string());
1320        }
1321
1322        #[allow(clippy::single_element_loop)]
1323        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
1324            url = params.uri_replacement(url, param_name, find_this, true);
1325        }
1326        {
1327            let to_remove = ["resource"];
1328            params.remove_params(&to_remove);
1329        }
1330
1331        let url = params.parse_with_url(&url);
1332
1333        loop {
1334            let token = match self
1335                .hub
1336                .auth
1337                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1338                .await
1339            {
1340                Ok(token) => token,
1341                Err(e) => match dlg.token(e) {
1342                    Ok(token) => token,
1343                    Err(e) => {
1344                        dlg.finished(false);
1345                        return Err(common::Error::MissingToken(e));
1346                    }
1347                },
1348            };
1349            let mut req_result = {
1350                let client = &self.hub.client;
1351                dlg.pre_request();
1352                let mut req_builder = hyper::Request::builder()
1353                    .method(hyper::Method::GET)
1354                    .uri(url.as_str())
1355                    .header(USER_AGENT, self.hub._user_agent.clone());
1356
1357                if let Some(token) = token.as_ref() {
1358                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1359                }
1360
1361                let request = req_builder
1362                    .header(CONTENT_LENGTH, 0_u64)
1363                    .body(common::to_body::<String>(None));
1364
1365                client.request(request.unwrap()).await
1366            };
1367
1368            match req_result {
1369                Err(err) => {
1370                    if let common::Retry::After(d) = dlg.http_error(&err) {
1371                        sleep(d).await;
1372                        continue;
1373                    }
1374                    dlg.finished(false);
1375                    return Err(common::Error::HttpError(err));
1376                }
1377                Ok(res) => {
1378                    let (mut parts, body) = res.into_parts();
1379                    let mut body = common::Body::new(body);
1380                    if !parts.status.is_success() {
1381                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1382                        let error = serde_json::from_str(&common::to_string(&bytes));
1383                        let response = common::to_response(parts, bytes.into());
1384
1385                        if let common::Retry::After(d) =
1386                            dlg.http_failure(&response, error.as_ref().ok())
1387                        {
1388                            sleep(d).await;
1389                            continue;
1390                        }
1391
1392                        dlg.finished(false);
1393
1394                        return Err(match error {
1395                            Ok(value) => common::Error::BadRequest(value),
1396                            _ => common::Error::Failure(response),
1397                        });
1398                    }
1399                    let response = {
1400                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1401                        let encoded = common::to_string(&bytes);
1402                        match serde_json::from_str(&encoded) {
1403                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1404                            Err(error) => {
1405                                dlg.response_json_decode_error(&encoded, &error);
1406                                return Err(common::Error::JsonDecodeError(
1407                                    encoded.to_string(),
1408                                    error,
1409                                ));
1410                            }
1411                        }
1412                    };
1413
1414                    dlg.finished(true);
1415                    return Ok(response);
1416                }
1417            }
1418        }
1419    }
1420
1421    /// Required. The name of the resource context. See
1422    /// SearchCatalogsRequest.resource for details.
1423    ///
1424    /// Sets the *resource* path property to the given value.
1425    ///
1426    /// Even though the property as already been set when instantiating this call,
1427    /// we provide this method for API completeness.
1428    pub fn resource(mut self, new_value: &str) -> FolderProductSearchCall<'a, C> {
1429        self._resource = new_value.to_string();
1430        self
1431    }
1432    /// The query to filter the products.
1433    ///
1434    /// The supported queries are:
1435    /// * List products of all catalogs: empty
1436    /// * List products under a catalog: `parent=catalogs/{catalog_id}`
1437    /// * Get a product by name:
1438    /// `name=catalogs/{catalog_id}/products/{product_id}`
1439    ///
1440    /// Sets the *query* query property to the given value.
1441    pub fn query(mut self, new_value: &str) -> FolderProductSearchCall<'a, C> {
1442        self._query = Some(new_value.to_string());
1443        self
1444    }
1445    /// A pagination token returned from a previous call to SearchProducts that
1446    /// indicates where this listing should continue from.
1447    /// This field is optional.
1448    ///
1449    /// Sets the *page token* query property to the given value.
1450    pub fn page_token(mut self, new_value: &str) -> FolderProductSearchCall<'a, C> {
1451        self._page_token = Some(new_value.to_string());
1452        self
1453    }
1454    /// The maximum number of entries that are requested.
1455    ///
1456    /// Sets the *page size* query property to the given value.
1457    pub fn page_size(mut self, new_value: i32) -> FolderProductSearchCall<'a, C> {
1458        self._page_size = Some(new_value);
1459        self
1460    }
1461    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1462    /// while executing the actual API request.
1463    ///
1464    /// ````text
1465    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1466    /// ````
1467    ///
1468    /// Sets the *delegate* property to the given value.
1469    pub fn delegate(
1470        mut self,
1471        new_value: &'a mut dyn common::Delegate,
1472    ) -> FolderProductSearchCall<'a, C> {
1473        self._delegate = Some(new_value);
1474        self
1475    }
1476
1477    /// Set any additional parameter of the query string used in the request.
1478    /// It should be used to set parameters which are not yet available through their own
1479    /// setters.
1480    ///
1481    /// Please note that this method must not be used to set any of the known parameters
1482    /// which have their own setter method. If done anyway, the request will fail.
1483    ///
1484    /// # Additional Parameters
1485    ///
1486    /// * *$.xgafv* (query-string) - V1 error format.
1487    /// * *access_token* (query-string) - OAuth access token.
1488    /// * *alt* (query-string) - Data format for response.
1489    /// * *callback* (query-string) - JSONP
1490    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1491    /// * *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.
1492    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1493    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1494    /// * *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.
1495    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1496    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1497    pub fn param<T>(mut self, name: T, value: T) -> FolderProductSearchCall<'a, C>
1498    where
1499        T: AsRef<str>,
1500    {
1501        self._additional_params
1502            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1503        self
1504    }
1505
1506    /// Identifies the authorization scope for the method you are building.
1507    ///
1508    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1509    /// [`Scope::CloudPlatform`].
1510    ///
1511    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1512    /// tokens for more than one scope.
1513    ///
1514    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1515    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1516    /// sufficient, a read-write scope will do as well.
1517    pub fn add_scope<St>(mut self, scope: St) -> FolderProductSearchCall<'a, C>
1518    where
1519        St: AsRef<str>,
1520    {
1521        self._scopes.insert(String::from(scope.as_ref()));
1522        self
1523    }
1524    /// Identifies the authorization scope(s) for the method you are building.
1525    ///
1526    /// See [`Self::add_scope()`] for details.
1527    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderProductSearchCall<'a, C>
1528    where
1529        I: IntoIterator<Item = St>,
1530        St: AsRef<str>,
1531    {
1532        self._scopes
1533            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1534        self
1535    }
1536
1537    /// Removes all scopes, and no default scope will be used either.
1538    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1539    /// for details).
1540    pub fn clear_scopes(mut self) -> FolderProductSearchCall<'a, C> {
1541        self._scopes.clear();
1542        self
1543    }
1544}
1545
1546/// Search Version resources that consumers have access to, within the
1547/// scope of the consumer cloud resource hierarchy context.
1548///
1549/// A builder for the *versions.search* method supported by a *folder* resource.
1550/// It is not used directly, but through a [`FolderMethods`] instance.
1551///
1552/// # Example
1553///
1554/// Instantiate a resource method builder
1555///
1556/// ```test_harness,no_run
1557/// # extern crate hyper;
1558/// # extern crate hyper_rustls;
1559/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
1560/// # async fn dox() {
1561/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1562///
1563/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1564/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1565/// #     .with_native_roots()
1566/// #     .unwrap()
1567/// #     .https_only()
1568/// #     .enable_http2()
1569/// #     .build();
1570///
1571/// # let executor = hyper_util::rt::TokioExecutor::new();
1572/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1573/// #     secret,
1574/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1575/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1576/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1577/// #     ),
1578/// # ).build().await.unwrap();
1579///
1580/// # let client = hyper_util::client::legacy::Client::builder(
1581/// #     hyper_util::rt::TokioExecutor::new()
1582/// # )
1583/// # .build(
1584/// #     hyper_rustls::HttpsConnectorBuilder::new()
1585/// #         .with_native_roots()
1586/// #         .unwrap()
1587/// #         .https_or_http()
1588/// #         .enable_http2()
1589/// #         .build()
1590/// # );
1591/// # let mut hub = CloudPrivateCatalog::new(client, auth);
1592/// // You can configure optional parameters by calling the respective setters at will, and
1593/// // execute the final call using `doit()`.
1594/// // Values shown here are possibly random and not representative !
1595/// let result = hub.folders().versions_search("resource")
1596///              .query("amet")
1597///              .page_token("duo")
1598///              .page_size(-50)
1599///              .doit().await;
1600/// # }
1601/// ```
1602pub struct FolderVersionSearchCall<'a, C>
1603where
1604    C: 'a,
1605{
1606    hub: &'a CloudPrivateCatalog<C>,
1607    _resource: String,
1608    _query: Option<String>,
1609    _page_token: Option<String>,
1610    _page_size: Option<i32>,
1611    _delegate: Option<&'a mut dyn common::Delegate>,
1612    _additional_params: HashMap<String, String>,
1613    _scopes: BTreeSet<String>,
1614}
1615
1616impl<'a, C> common::CallBuilder for FolderVersionSearchCall<'a, C> {}
1617
1618impl<'a, C> FolderVersionSearchCall<'a, C>
1619where
1620    C: common::Connector,
1621{
1622    /// Perform the operation you have build so far.
1623    pub async fn doit(
1624        mut self,
1625    ) -> common::Result<(
1626        common::Response,
1627        GoogleCloudPrivatecatalogV1beta1SearchVersionsResponse,
1628    )> {
1629        use std::borrow::Cow;
1630        use std::io::{Read, Seek};
1631
1632        use common::{url::Params, ToParts};
1633        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1634
1635        let mut dd = common::DefaultDelegate;
1636        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1637        dlg.begin(common::MethodInfo {
1638            id: "cloudprivatecatalog.folders.versions.search",
1639            http_method: hyper::Method::GET,
1640        });
1641
1642        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
1643            if self._additional_params.contains_key(field) {
1644                dlg.finished(false);
1645                return Err(common::Error::FieldClash(field));
1646            }
1647        }
1648
1649        let mut params = Params::with_capacity(6 + self._additional_params.len());
1650        params.push("resource", self._resource);
1651        if let Some(value) = self._query.as_ref() {
1652            params.push("query", value);
1653        }
1654        if let Some(value) = self._page_token.as_ref() {
1655            params.push("pageToken", value);
1656        }
1657        if let Some(value) = self._page_size.as_ref() {
1658            params.push("pageSize", value.to_string());
1659        }
1660
1661        params.extend(self._additional_params.iter());
1662
1663        params.push("alt", "json");
1664        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/versions:search";
1665        if self._scopes.is_empty() {
1666            self._scopes
1667                .insert(Scope::CloudPlatform.as_ref().to_string());
1668        }
1669
1670        #[allow(clippy::single_element_loop)]
1671        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
1672            url = params.uri_replacement(url, param_name, find_this, true);
1673        }
1674        {
1675            let to_remove = ["resource"];
1676            params.remove_params(&to_remove);
1677        }
1678
1679        let url = params.parse_with_url(&url);
1680
1681        loop {
1682            let token = match self
1683                .hub
1684                .auth
1685                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1686                .await
1687            {
1688                Ok(token) => token,
1689                Err(e) => match dlg.token(e) {
1690                    Ok(token) => token,
1691                    Err(e) => {
1692                        dlg.finished(false);
1693                        return Err(common::Error::MissingToken(e));
1694                    }
1695                },
1696            };
1697            let mut req_result = {
1698                let client = &self.hub.client;
1699                dlg.pre_request();
1700                let mut req_builder = hyper::Request::builder()
1701                    .method(hyper::Method::GET)
1702                    .uri(url.as_str())
1703                    .header(USER_AGENT, self.hub._user_agent.clone());
1704
1705                if let Some(token) = token.as_ref() {
1706                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1707                }
1708
1709                let request = req_builder
1710                    .header(CONTENT_LENGTH, 0_u64)
1711                    .body(common::to_body::<String>(None));
1712
1713                client.request(request.unwrap()).await
1714            };
1715
1716            match req_result {
1717                Err(err) => {
1718                    if let common::Retry::After(d) = dlg.http_error(&err) {
1719                        sleep(d).await;
1720                        continue;
1721                    }
1722                    dlg.finished(false);
1723                    return Err(common::Error::HttpError(err));
1724                }
1725                Ok(res) => {
1726                    let (mut parts, body) = res.into_parts();
1727                    let mut body = common::Body::new(body);
1728                    if !parts.status.is_success() {
1729                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1730                        let error = serde_json::from_str(&common::to_string(&bytes));
1731                        let response = common::to_response(parts, bytes.into());
1732
1733                        if let common::Retry::After(d) =
1734                            dlg.http_failure(&response, error.as_ref().ok())
1735                        {
1736                            sleep(d).await;
1737                            continue;
1738                        }
1739
1740                        dlg.finished(false);
1741
1742                        return Err(match error {
1743                            Ok(value) => common::Error::BadRequest(value),
1744                            _ => common::Error::Failure(response),
1745                        });
1746                    }
1747                    let response = {
1748                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1749                        let encoded = common::to_string(&bytes);
1750                        match serde_json::from_str(&encoded) {
1751                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1752                            Err(error) => {
1753                                dlg.response_json_decode_error(&encoded, &error);
1754                                return Err(common::Error::JsonDecodeError(
1755                                    encoded.to_string(),
1756                                    error,
1757                                ));
1758                            }
1759                        }
1760                    };
1761
1762                    dlg.finished(true);
1763                    return Ok(response);
1764                }
1765            }
1766        }
1767    }
1768
1769    /// Required. The name of the resource context. See
1770    /// SearchCatalogsRequest.resource for details.
1771    ///
1772    /// Sets the *resource* path property to the given value.
1773    ///
1774    /// Even though the property as already been set when instantiating this call,
1775    /// we provide this method for API completeness.
1776    pub fn resource(mut self, new_value: &str) -> FolderVersionSearchCall<'a, C> {
1777        self._resource = new_value.to_string();
1778        self
1779    }
1780    /// The query to filter the versions. Required.
1781    ///
1782    /// The supported queries are:
1783    /// * List versions under a product:
1784    /// `parent=catalogs/{catalog_id}/products/{product_id}`
1785    /// * Get a version by name:
1786    /// `name=catalogs/{catalog_id}/products/{product_id}/versions/{version_id}`
1787    ///
1788    /// Sets the *query* query property to the given value.
1789    pub fn query(mut self, new_value: &str) -> FolderVersionSearchCall<'a, C> {
1790        self._query = Some(new_value.to_string());
1791        self
1792    }
1793    /// A pagination token returned from a previous call to SearchVersions
1794    /// that indicates where this listing should continue from.
1795    /// This field is optional.
1796    ///
1797    /// Sets the *page token* query property to the given value.
1798    pub fn page_token(mut self, new_value: &str) -> FolderVersionSearchCall<'a, C> {
1799        self._page_token = Some(new_value.to_string());
1800        self
1801    }
1802    /// The maximum number of entries that are requested.
1803    ///
1804    /// Sets the *page size* query property to the given value.
1805    pub fn page_size(mut self, new_value: i32) -> FolderVersionSearchCall<'a, C> {
1806        self._page_size = Some(new_value);
1807        self
1808    }
1809    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1810    /// while executing the actual API request.
1811    ///
1812    /// ````text
1813    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1814    /// ````
1815    ///
1816    /// Sets the *delegate* property to the given value.
1817    pub fn delegate(
1818        mut self,
1819        new_value: &'a mut dyn common::Delegate,
1820    ) -> FolderVersionSearchCall<'a, C> {
1821        self._delegate = Some(new_value);
1822        self
1823    }
1824
1825    /// Set any additional parameter of the query string used in the request.
1826    /// It should be used to set parameters which are not yet available through their own
1827    /// setters.
1828    ///
1829    /// Please note that this method must not be used to set any of the known parameters
1830    /// which have their own setter method. If done anyway, the request will fail.
1831    ///
1832    /// # Additional Parameters
1833    ///
1834    /// * *$.xgafv* (query-string) - V1 error format.
1835    /// * *access_token* (query-string) - OAuth access token.
1836    /// * *alt* (query-string) - Data format for response.
1837    /// * *callback* (query-string) - JSONP
1838    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1839    /// * *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.
1840    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1841    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1842    /// * *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.
1843    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1844    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1845    pub fn param<T>(mut self, name: T, value: T) -> FolderVersionSearchCall<'a, C>
1846    where
1847        T: AsRef<str>,
1848    {
1849        self._additional_params
1850            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1851        self
1852    }
1853
1854    /// Identifies the authorization scope for the method you are building.
1855    ///
1856    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1857    /// [`Scope::CloudPlatform`].
1858    ///
1859    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1860    /// tokens for more than one scope.
1861    ///
1862    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1863    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1864    /// sufficient, a read-write scope will do as well.
1865    pub fn add_scope<St>(mut self, scope: St) -> FolderVersionSearchCall<'a, C>
1866    where
1867        St: AsRef<str>,
1868    {
1869        self._scopes.insert(String::from(scope.as_ref()));
1870        self
1871    }
1872    /// Identifies the authorization scope(s) for the method you are building.
1873    ///
1874    /// See [`Self::add_scope()`] for details.
1875    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderVersionSearchCall<'a, C>
1876    where
1877        I: IntoIterator<Item = St>,
1878        St: AsRef<str>,
1879    {
1880        self._scopes
1881            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1882        self
1883    }
1884
1885    /// Removes all scopes, and no default scope will be used either.
1886    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1887    /// for details).
1888    pub fn clear_scopes(mut self) -> FolderVersionSearchCall<'a, C> {
1889        self._scopes.clear();
1890        self
1891    }
1892}
1893
1894/// Search Catalog resources that consumers have access to, within the
1895/// scope of the consumer cloud resource hierarchy context.
1896///
1897/// A builder for the *catalogs.search* method supported by a *organization* resource.
1898/// It is not used directly, but through a [`OrganizationMethods`] instance.
1899///
1900/// # Example
1901///
1902/// Instantiate a resource method builder
1903///
1904/// ```test_harness,no_run
1905/// # extern crate hyper;
1906/// # extern crate hyper_rustls;
1907/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
1908/// # async fn dox() {
1909/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1910///
1911/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1912/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1913/// #     .with_native_roots()
1914/// #     .unwrap()
1915/// #     .https_only()
1916/// #     .enable_http2()
1917/// #     .build();
1918///
1919/// # let executor = hyper_util::rt::TokioExecutor::new();
1920/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1921/// #     secret,
1922/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1923/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1924/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1925/// #     ),
1926/// # ).build().await.unwrap();
1927///
1928/// # let client = hyper_util::client::legacy::Client::builder(
1929/// #     hyper_util::rt::TokioExecutor::new()
1930/// # )
1931/// # .build(
1932/// #     hyper_rustls::HttpsConnectorBuilder::new()
1933/// #         .with_native_roots()
1934/// #         .unwrap()
1935/// #         .https_or_http()
1936/// #         .enable_http2()
1937/// #         .build()
1938/// # );
1939/// # let mut hub = CloudPrivateCatalog::new(client, auth);
1940/// // You can configure optional parameters by calling the respective setters at will, and
1941/// // execute the final call using `doit()`.
1942/// // Values shown here are possibly random and not representative !
1943/// let result = hub.organizations().catalogs_search("resource")
1944///              .query("ut")
1945///              .page_token("gubergren")
1946///              .page_size(-16)
1947///              .doit().await;
1948/// # }
1949/// ```
1950pub struct OrganizationCatalogSearchCall<'a, C>
1951where
1952    C: 'a,
1953{
1954    hub: &'a CloudPrivateCatalog<C>,
1955    _resource: String,
1956    _query: Option<String>,
1957    _page_token: Option<String>,
1958    _page_size: Option<i32>,
1959    _delegate: Option<&'a mut dyn common::Delegate>,
1960    _additional_params: HashMap<String, String>,
1961    _scopes: BTreeSet<String>,
1962}
1963
1964impl<'a, C> common::CallBuilder for OrganizationCatalogSearchCall<'a, C> {}
1965
1966impl<'a, C> OrganizationCatalogSearchCall<'a, C>
1967where
1968    C: common::Connector,
1969{
1970    /// Perform the operation you have build so far.
1971    pub async fn doit(
1972        mut self,
1973    ) -> common::Result<(
1974        common::Response,
1975        GoogleCloudPrivatecatalogV1beta1SearchCatalogsResponse,
1976    )> {
1977        use std::borrow::Cow;
1978        use std::io::{Read, Seek};
1979
1980        use common::{url::Params, ToParts};
1981        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1982
1983        let mut dd = common::DefaultDelegate;
1984        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1985        dlg.begin(common::MethodInfo {
1986            id: "cloudprivatecatalog.organizations.catalogs.search",
1987            http_method: hyper::Method::GET,
1988        });
1989
1990        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
1991            if self._additional_params.contains_key(field) {
1992                dlg.finished(false);
1993                return Err(common::Error::FieldClash(field));
1994            }
1995        }
1996
1997        let mut params = Params::with_capacity(6 + self._additional_params.len());
1998        params.push("resource", self._resource);
1999        if let Some(value) = self._query.as_ref() {
2000            params.push("query", value);
2001        }
2002        if let Some(value) = self._page_token.as_ref() {
2003            params.push("pageToken", value);
2004        }
2005        if let Some(value) = self._page_size.as_ref() {
2006            params.push("pageSize", value.to_string());
2007        }
2008
2009        params.extend(self._additional_params.iter());
2010
2011        params.push("alt", "json");
2012        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/catalogs:search";
2013        if self._scopes.is_empty() {
2014            self._scopes
2015                .insert(Scope::CloudPlatform.as_ref().to_string());
2016        }
2017
2018        #[allow(clippy::single_element_loop)]
2019        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2020            url = params.uri_replacement(url, param_name, find_this, true);
2021        }
2022        {
2023            let to_remove = ["resource"];
2024            params.remove_params(&to_remove);
2025        }
2026
2027        let url = params.parse_with_url(&url);
2028
2029        loop {
2030            let token = match self
2031                .hub
2032                .auth
2033                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2034                .await
2035            {
2036                Ok(token) => token,
2037                Err(e) => match dlg.token(e) {
2038                    Ok(token) => token,
2039                    Err(e) => {
2040                        dlg.finished(false);
2041                        return Err(common::Error::MissingToken(e));
2042                    }
2043                },
2044            };
2045            let mut req_result = {
2046                let client = &self.hub.client;
2047                dlg.pre_request();
2048                let mut req_builder = hyper::Request::builder()
2049                    .method(hyper::Method::GET)
2050                    .uri(url.as_str())
2051                    .header(USER_AGENT, self.hub._user_agent.clone());
2052
2053                if let Some(token) = token.as_ref() {
2054                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2055                }
2056
2057                let request = req_builder
2058                    .header(CONTENT_LENGTH, 0_u64)
2059                    .body(common::to_body::<String>(None));
2060
2061                client.request(request.unwrap()).await
2062            };
2063
2064            match req_result {
2065                Err(err) => {
2066                    if let common::Retry::After(d) = dlg.http_error(&err) {
2067                        sleep(d).await;
2068                        continue;
2069                    }
2070                    dlg.finished(false);
2071                    return Err(common::Error::HttpError(err));
2072                }
2073                Ok(res) => {
2074                    let (mut parts, body) = res.into_parts();
2075                    let mut body = common::Body::new(body);
2076                    if !parts.status.is_success() {
2077                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2078                        let error = serde_json::from_str(&common::to_string(&bytes));
2079                        let response = common::to_response(parts, bytes.into());
2080
2081                        if let common::Retry::After(d) =
2082                            dlg.http_failure(&response, error.as_ref().ok())
2083                        {
2084                            sleep(d).await;
2085                            continue;
2086                        }
2087
2088                        dlg.finished(false);
2089
2090                        return Err(match error {
2091                            Ok(value) => common::Error::BadRequest(value),
2092                            _ => common::Error::Failure(response),
2093                        });
2094                    }
2095                    let response = {
2096                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2097                        let encoded = common::to_string(&bytes);
2098                        match serde_json::from_str(&encoded) {
2099                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2100                            Err(error) => {
2101                                dlg.response_json_decode_error(&encoded, &error);
2102                                return Err(common::Error::JsonDecodeError(
2103                                    encoded.to_string(),
2104                                    error,
2105                                ));
2106                            }
2107                        }
2108                    };
2109
2110                    dlg.finished(true);
2111                    return Ok(response);
2112                }
2113            }
2114        }
2115    }
2116
2117    /// Required. The name of the resource context. It can be in following formats:
2118    ///
2119    /// * `projects/{project_id}`
2120    /// * `folders/{folder_id}`
2121    /// * `organizations/{organization_id}`
2122    ///
2123    /// Sets the *resource* path property to the given value.
2124    ///
2125    /// Even though the property as already been set when instantiating this call,
2126    /// we provide this method for API completeness.
2127    pub fn resource(mut self, new_value: &str) -> OrganizationCatalogSearchCall<'a, C> {
2128        self._resource = new_value.to_string();
2129        self
2130    }
2131    /// The query to filter the catalogs. The supported queries are:
2132    ///
2133    /// * Get a single catalog: `name=catalogs/{catalog_id}`
2134    ///
2135    /// Sets the *query* query property to the given value.
2136    pub fn query(mut self, new_value: &str) -> OrganizationCatalogSearchCall<'a, C> {
2137        self._query = Some(new_value.to_string());
2138        self
2139    }
2140    /// A pagination token returned from a previous call to SearchCatalogs that
2141    /// indicates where this listing should continue from.
2142    /// This field is optional.
2143    ///
2144    /// Sets the *page token* query property to the given value.
2145    pub fn page_token(mut self, new_value: &str) -> OrganizationCatalogSearchCall<'a, C> {
2146        self._page_token = Some(new_value.to_string());
2147        self
2148    }
2149    /// The maximum number of entries that are requested.
2150    ///
2151    /// Sets the *page size* query property to the given value.
2152    pub fn page_size(mut self, new_value: i32) -> OrganizationCatalogSearchCall<'a, C> {
2153        self._page_size = Some(new_value);
2154        self
2155    }
2156    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2157    /// while executing the actual API request.
2158    ///
2159    /// ````text
2160    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2161    /// ````
2162    ///
2163    /// Sets the *delegate* property to the given value.
2164    pub fn delegate(
2165        mut self,
2166        new_value: &'a mut dyn common::Delegate,
2167    ) -> OrganizationCatalogSearchCall<'a, C> {
2168        self._delegate = Some(new_value);
2169        self
2170    }
2171
2172    /// Set any additional parameter of the query string used in the request.
2173    /// It should be used to set parameters which are not yet available through their own
2174    /// setters.
2175    ///
2176    /// Please note that this method must not be used to set any of the known parameters
2177    /// which have their own setter method. If done anyway, the request will fail.
2178    ///
2179    /// # Additional Parameters
2180    ///
2181    /// * *$.xgafv* (query-string) - V1 error format.
2182    /// * *access_token* (query-string) - OAuth access token.
2183    /// * *alt* (query-string) - Data format for response.
2184    /// * *callback* (query-string) - JSONP
2185    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2186    /// * *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.
2187    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2188    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2189    /// * *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.
2190    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2191    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2192    pub fn param<T>(mut self, name: T, value: T) -> OrganizationCatalogSearchCall<'a, C>
2193    where
2194        T: AsRef<str>,
2195    {
2196        self._additional_params
2197            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2198        self
2199    }
2200
2201    /// Identifies the authorization scope for the method you are building.
2202    ///
2203    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2204    /// [`Scope::CloudPlatform`].
2205    ///
2206    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2207    /// tokens for more than one scope.
2208    ///
2209    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2210    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2211    /// sufficient, a read-write scope will do as well.
2212    pub fn add_scope<St>(mut self, scope: St) -> OrganizationCatalogSearchCall<'a, C>
2213    where
2214        St: AsRef<str>,
2215    {
2216        self._scopes.insert(String::from(scope.as_ref()));
2217        self
2218    }
2219    /// Identifies the authorization scope(s) for the method you are building.
2220    ///
2221    /// See [`Self::add_scope()`] for details.
2222    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationCatalogSearchCall<'a, C>
2223    where
2224        I: IntoIterator<Item = St>,
2225        St: AsRef<str>,
2226    {
2227        self._scopes
2228            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2229        self
2230    }
2231
2232    /// Removes all scopes, and no default scope will be used either.
2233    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2234    /// for details).
2235    pub fn clear_scopes(mut self) -> OrganizationCatalogSearchCall<'a, C> {
2236        self._scopes.clear();
2237        self
2238    }
2239}
2240
2241/// Search Product resources that consumers have access to, within the
2242/// scope of the consumer cloud resource hierarchy context.
2243///
2244/// A builder for the *products.search* method supported by a *organization* resource.
2245/// It is not used directly, but through a [`OrganizationMethods`] instance.
2246///
2247/// # Example
2248///
2249/// Instantiate a resource method builder
2250///
2251/// ```test_harness,no_run
2252/// # extern crate hyper;
2253/// # extern crate hyper_rustls;
2254/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
2255/// # async fn dox() {
2256/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2257///
2258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2259/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2260/// #     .with_native_roots()
2261/// #     .unwrap()
2262/// #     .https_only()
2263/// #     .enable_http2()
2264/// #     .build();
2265///
2266/// # let executor = hyper_util::rt::TokioExecutor::new();
2267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2268/// #     secret,
2269/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2270/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2271/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2272/// #     ),
2273/// # ).build().await.unwrap();
2274///
2275/// # let client = hyper_util::client::legacy::Client::builder(
2276/// #     hyper_util::rt::TokioExecutor::new()
2277/// # )
2278/// # .build(
2279/// #     hyper_rustls::HttpsConnectorBuilder::new()
2280/// #         .with_native_roots()
2281/// #         .unwrap()
2282/// #         .https_or_http()
2283/// #         .enable_http2()
2284/// #         .build()
2285/// # );
2286/// # let mut hub = CloudPrivateCatalog::new(client, auth);
2287/// // You can configure optional parameters by calling the respective setters at will, and
2288/// // execute the final call using `doit()`.
2289/// // Values shown here are possibly random and not representative !
2290/// let result = hub.organizations().products_search("resource")
2291///              .query("ipsum")
2292///              .page_token("ipsum")
2293///              .page_size(-7)
2294///              .doit().await;
2295/// # }
2296/// ```
2297pub struct OrganizationProductSearchCall<'a, C>
2298where
2299    C: 'a,
2300{
2301    hub: &'a CloudPrivateCatalog<C>,
2302    _resource: String,
2303    _query: Option<String>,
2304    _page_token: Option<String>,
2305    _page_size: Option<i32>,
2306    _delegate: Option<&'a mut dyn common::Delegate>,
2307    _additional_params: HashMap<String, String>,
2308    _scopes: BTreeSet<String>,
2309}
2310
2311impl<'a, C> common::CallBuilder for OrganizationProductSearchCall<'a, C> {}
2312
2313impl<'a, C> OrganizationProductSearchCall<'a, C>
2314where
2315    C: common::Connector,
2316{
2317    /// Perform the operation you have build so far.
2318    pub async fn doit(
2319        mut self,
2320    ) -> common::Result<(
2321        common::Response,
2322        GoogleCloudPrivatecatalogV1beta1SearchProductsResponse,
2323    )> {
2324        use std::borrow::Cow;
2325        use std::io::{Read, Seek};
2326
2327        use common::{url::Params, ToParts};
2328        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2329
2330        let mut dd = common::DefaultDelegate;
2331        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2332        dlg.begin(common::MethodInfo {
2333            id: "cloudprivatecatalog.organizations.products.search",
2334            http_method: hyper::Method::GET,
2335        });
2336
2337        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
2338            if self._additional_params.contains_key(field) {
2339                dlg.finished(false);
2340                return Err(common::Error::FieldClash(field));
2341            }
2342        }
2343
2344        let mut params = Params::with_capacity(6 + self._additional_params.len());
2345        params.push("resource", self._resource);
2346        if let Some(value) = self._query.as_ref() {
2347            params.push("query", value);
2348        }
2349        if let Some(value) = self._page_token.as_ref() {
2350            params.push("pageToken", value);
2351        }
2352        if let Some(value) = self._page_size.as_ref() {
2353            params.push("pageSize", value.to_string());
2354        }
2355
2356        params.extend(self._additional_params.iter());
2357
2358        params.push("alt", "json");
2359        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/products:search";
2360        if self._scopes.is_empty() {
2361            self._scopes
2362                .insert(Scope::CloudPlatform.as_ref().to_string());
2363        }
2364
2365        #[allow(clippy::single_element_loop)]
2366        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2367            url = params.uri_replacement(url, param_name, find_this, true);
2368        }
2369        {
2370            let to_remove = ["resource"];
2371            params.remove_params(&to_remove);
2372        }
2373
2374        let url = params.parse_with_url(&url);
2375
2376        loop {
2377            let token = match self
2378                .hub
2379                .auth
2380                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2381                .await
2382            {
2383                Ok(token) => token,
2384                Err(e) => match dlg.token(e) {
2385                    Ok(token) => token,
2386                    Err(e) => {
2387                        dlg.finished(false);
2388                        return Err(common::Error::MissingToken(e));
2389                    }
2390                },
2391            };
2392            let mut req_result = {
2393                let client = &self.hub.client;
2394                dlg.pre_request();
2395                let mut req_builder = hyper::Request::builder()
2396                    .method(hyper::Method::GET)
2397                    .uri(url.as_str())
2398                    .header(USER_AGENT, self.hub._user_agent.clone());
2399
2400                if let Some(token) = token.as_ref() {
2401                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2402                }
2403
2404                let request = req_builder
2405                    .header(CONTENT_LENGTH, 0_u64)
2406                    .body(common::to_body::<String>(None));
2407
2408                client.request(request.unwrap()).await
2409            };
2410
2411            match req_result {
2412                Err(err) => {
2413                    if let common::Retry::After(d) = dlg.http_error(&err) {
2414                        sleep(d).await;
2415                        continue;
2416                    }
2417                    dlg.finished(false);
2418                    return Err(common::Error::HttpError(err));
2419                }
2420                Ok(res) => {
2421                    let (mut parts, body) = res.into_parts();
2422                    let mut body = common::Body::new(body);
2423                    if !parts.status.is_success() {
2424                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2425                        let error = serde_json::from_str(&common::to_string(&bytes));
2426                        let response = common::to_response(parts, bytes.into());
2427
2428                        if let common::Retry::After(d) =
2429                            dlg.http_failure(&response, error.as_ref().ok())
2430                        {
2431                            sleep(d).await;
2432                            continue;
2433                        }
2434
2435                        dlg.finished(false);
2436
2437                        return Err(match error {
2438                            Ok(value) => common::Error::BadRequest(value),
2439                            _ => common::Error::Failure(response),
2440                        });
2441                    }
2442                    let response = {
2443                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2444                        let encoded = common::to_string(&bytes);
2445                        match serde_json::from_str(&encoded) {
2446                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2447                            Err(error) => {
2448                                dlg.response_json_decode_error(&encoded, &error);
2449                                return Err(common::Error::JsonDecodeError(
2450                                    encoded.to_string(),
2451                                    error,
2452                                ));
2453                            }
2454                        }
2455                    };
2456
2457                    dlg.finished(true);
2458                    return Ok(response);
2459                }
2460            }
2461        }
2462    }
2463
2464    /// Required. The name of the resource context. See
2465    /// SearchCatalogsRequest.resource for details.
2466    ///
2467    /// Sets the *resource* path property to the given value.
2468    ///
2469    /// Even though the property as already been set when instantiating this call,
2470    /// we provide this method for API completeness.
2471    pub fn resource(mut self, new_value: &str) -> OrganizationProductSearchCall<'a, C> {
2472        self._resource = new_value.to_string();
2473        self
2474    }
2475    /// The query to filter the products.
2476    ///
2477    /// The supported queries are:
2478    /// * List products of all catalogs: empty
2479    /// * List products under a catalog: `parent=catalogs/{catalog_id}`
2480    /// * Get a product by name:
2481    /// `name=catalogs/{catalog_id}/products/{product_id}`
2482    ///
2483    /// Sets the *query* query property to the given value.
2484    pub fn query(mut self, new_value: &str) -> OrganizationProductSearchCall<'a, C> {
2485        self._query = Some(new_value.to_string());
2486        self
2487    }
2488    /// A pagination token returned from a previous call to SearchProducts that
2489    /// indicates where this listing should continue from.
2490    /// This field is optional.
2491    ///
2492    /// Sets the *page token* query property to the given value.
2493    pub fn page_token(mut self, new_value: &str) -> OrganizationProductSearchCall<'a, C> {
2494        self._page_token = Some(new_value.to_string());
2495        self
2496    }
2497    /// The maximum number of entries that are requested.
2498    ///
2499    /// Sets the *page size* query property to the given value.
2500    pub fn page_size(mut self, new_value: i32) -> OrganizationProductSearchCall<'a, C> {
2501        self._page_size = Some(new_value);
2502        self
2503    }
2504    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2505    /// while executing the actual API request.
2506    ///
2507    /// ````text
2508    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2509    /// ````
2510    ///
2511    /// Sets the *delegate* property to the given value.
2512    pub fn delegate(
2513        mut self,
2514        new_value: &'a mut dyn common::Delegate,
2515    ) -> OrganizationProductSearchCall<'a, C> {
2516        self._delegate = Some(new_value);
2517        self
2518    }
2519
2520    /// Set any additional parameter of the query string used in the request.
2521    /// It should be used to set parameters which are not yet available through their own
2522    /// setters.
2523    ///
2524    /// Please note that this method must not be used to set any of the known parameters
2525    /// which have their own setter method. If done anyway, the request will fail.
2526    ///
2527    /// # Additional Parameters
2528    ///
2529    /// * *$.xgafv* (query-string) - V1 error format.
2530    /// * *access_token* (query-string) - OAuth access token.
2531    /// * *alt* (query-string) - Data format for response.
2532    /// * *callback* (query-string) - JSONP
2533    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2534    /// * *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.
2535    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2536    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2537    /// * *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.
2538    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2539    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2540    pub fn param<T>(mut self, name: T, value: T) -> OrganizationProductSearchCall<'a, C>
2541    where
2542        T: AsRef<str>,
2543    {
2544        self._additional_params
2545            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2546        self
2547    }
2548
2549    /// Identifies the authorization scope for the method you are building.
2550    ///
2551    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2552    /// [`Scope::CloudPlatform`].
2553    ///
2554    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2555    /// tokens for more than one scope.
2556    ///
2557    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2558    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2559    /// sufficient, a read-write scope will do as well.
2560    pub fn add_scope<St>(mut self, scope: St) -> OrganizationProductSearchCall<'a, C>
2561    where
2562        St: AsRef<str>,
2563    {
2564        self._scopes.insert(String::from(scope.as_ref()));
2565        self
2566    }
2567    /// Identifies the authorization scope(s) for the method you are building.
2568    ///
2569    /// See [`Self::add_scope()`] for details.
2570    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationProductSearchCall<'a, C>
2571    where
2572        I: IntoIterator<Item = St>,
2573        St: AsRef<str>,
2574    {
2575        self._scopes
2576            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2577        self
2578    }
2579
2580    /// Removes all scopes, and no default scope will be used either.
2581    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2582    /// for details).
2583    pub fn clear_scopes(mut self) -> OrganizationProductSearchCall<'a, C> {
2584        self._scopes.clear();
2585        self
2586    }
2587}
2588
2589/// Search Version resources that consumers have access to, within the
2590/// scope of the consumer cloud resource hierarchy context.
2591///
2592/// A builder for the *versions.search* method supported by a *organization* resource.
2593/// It is not used directly, but through a [`OrganizationMethods`] instance.
2594///
2595/// # Example
2596///
2597/// Instantiate a resource method builder
2598///
2599/// ```test_harness,no_run
2600/// # extern crate hyper;
2601/// # extern crate hyper_rustls;
2602/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
2603/// # async fn dox() {
2604/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2605///
2606/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2607/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2608/// #     .with_native_roots()
2609/// #     .unwrap()
2610/// #     .https_only()
2611/// #     .enable_http2()
2612/// #     .build();
2613///
2614/// # let executor = hyper_util::rt::TokioExecutor::new();
2615/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2616/// #     secret,
2617/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2618/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2619/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2620/// #     ),
2621/// # ).build().await.unwrap();
2622///
2623/// # let client = hyper_util::client::legacy::Client::builder(
2624/// #     hyper_util::rt::TokioExecutor::new()
2625/// # )
2626/// # .build(
2627/// #     hyper_rustls::HttpsConnectorBuilder::new()
2628/// #         .with_native_roots()
2629/// #         .unwrap()
2630/// #         .https_or_http()
2631/// #         .enable_http2()
2632/// #         .build()
2633/// # );
2634/// # let mut hub = CloudPrivateCatalog::new(client, auth);
2635/// // You can configure optional parameters by calling the respective setters at will, and
2636/// // execute the final call using `doit()`.
2637/// // Values shown here are possibly random and not representative !
2638/// let result = hub.organizations().versions_search("resource")
2639///              .query("ea")
2640///              .page_token("dolor")
2641///              .page_size(-56)
2642///              .doit().await;
2643/// # }
2644/// ```
2645pub struct OrganizationVersionSearchCall<'a, C>
2646where
2647    C: 'a,
2648{
2649    hub: &'a CloudPrivateCatalog<C>,
2650    _resource: String,
2651    _query: Option<String>,
2652    _page_token: Option<String>,
2653    _page_size: Option<i32>,
2654    _delegate: Option<&'a mut dyn common::Delegate>,
2655    _additional_params: HashMap<String, String>,
2656    _scopes: BTreeSet<String>,
2657}
2658
2659impl<'a, C> common::CallBuilder for OrganizationVersionSearchCall<'a, C> {}
2660
2661impl<'a, C> OrganizationVersionSearchCall<'a, C>
2662where
2663    C: common::Connector,
2664{
2665    /// Perform the operation you have build so far.
2666    pub async fn doit(
2667        mut self,
2668    ) -> common::Result<(
2669        common::Response,
2670        GoogleCloudPrivatecatalogV1beta1SearchVersionsResponse,
2671    )> {
2672        use std::borrow::Cow;
2673        use std::io::{Read, Seek};
2674
2675        use common::{url::Params, ToParts};
2676        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2677
2678        let mut dd = common::DefaultDelegate;
2679        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2680        dlg.begin(common::MethodInfo {
2681            id: "cloudprivatecatalog.organizations.versions.search",
2682            http_method: hyper::Method::GET,
2683        });
2684
2685        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
2686            if self._additional_params.contains_key(field) {
2687                dlg.finished(false);
2688                return Err(common::Error::FieldClash(field));
2689            }
2690        }
2691
2692        let mut params = Params::with_capacity(6 + self._additional_params.len());
2693        params.push("resource", self._resource);
2694        if let Some(value) = self._query.as_ref() {
2695            params.push("query", value);
2696        }
2697        if let Some(value) = self._page_token.as_ref() {
2698            params.push("pageToken", value);
2699        }
2700        if let Some(value) = self._page_size.as_ref() {
2701            params.push("pageSize", value.to_string());
2702        }
2703
2704        params.extend(self._additional_params.iter());
2705
2706        params.push("alt", "json");
2707        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/versions:search";
2708        if self._scopes.is_empty() {
2709            self._scopes
2710                .insert(Scope::CloudPlatform.as_ref().to_string());
2711        }
2712
2713        #[allow(clippy::single_element_loop)]
2714        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2715            url = params.uri_replacement(url, param_name, find_this, true);
2716        }
2717        {
2718            let to_remove = ["resource"];
2719            params.remove_params(&to_remove);
2720        }
2721
2722        let url = params.parse_with_url(&url);
2723
2724        loop {
2725            let token = match self
2726                .hub
2727                .auth
2728                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2729                .await
2730            {
2731                Ok(token) => token,
2732                Err(e) => match dlg.token(e) {
2733                    Ok(token) => token,
2734                    Err(e) => {
2735                        dlg.finished(false);
2736                        return Err(common::Error::MissingToken(e));
2737                    }
2738                },
2739            };
2740            let mut req_result = {
2741                let client = &self.hub.client;
2742                dlg.pre_request();
2743                let mut req_builder = hyper::Request::builder()
2744                    .method(hyper::Method::GET)
2745                    .uri(url.as_str())
2746                    .header(USER_AGENT, self.hub._user_agent.clone());
2747
2748                if let Some(token) = token.as_ref() {
2749                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2750                }
2751
2752                let request = req_builder
2753                    .header(CONTENT_LENGTH, 0_u64)
2754                    .body(common::to_body::<String>(None));
2755
2756                client.request(request.unwrap()).await
2757            };
2758
2759            match req_result {
2760                Err(err) => {
2761                    if let common::Retry::After(d) = dlg.http_error(&err) {
2762                        sleep(d).await;
2763                        continue;
2764                    }
2765                    dlg.finished(false);
2766                    return Err(common::Error::HttpError(err));
2767                }
2768                Ok(res) => {
2769                    let (mut parts, body) = res.into_parts();
2770                    let mut body = common::Body::new(body);
2771                    if !parts.status.is_success() {
2772                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2773                        let error = serde_json::from_str(&common::to_string(&bytes));
2774                        let response = common::to_response(parts, bytes.into());
2775
2776                        if let common::Retry::After(d) =
2777                            dlg.http_failure(&response, error.as_ref().ok())
2778                        {
2779                            sleep(d).await;
2780                            continue;
2781                        }
2782
2783                        dlg.finished(false);
2784
2785                        return Err(match error {
2786                            Ok(value) => common::Error::BadRequest(value),
2787                            _ => common::Error::Failure(response),
2788                        });
2789                    }
2790                    let response = {
2791                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2792                        let encoded = common::to_string(&bytes);
2793                        match serde_json::from_str(&encoded) {
2794                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2795                            Err(error) => {
2796                                dlg.response_json_decode_error(&encoded, &error);
2797                                return Err(common::Error::JsonDecodeError(
2798                                    encoded.to_string(),
2799                                    error,
2800                                ));
2801                            }
2802                        }
2803                    };
2804
2805                    dlg.finished(true);
2806                    return Ok(response);
2807                }
2808            }
2809        }
2810    }
2811
2812    /// Required. The name of the resource context. See
2813    /// SearchCatalogsRequest.resource for details.
2814    ///
2815    /// Sets the *resource* path property to the given value.
2816    ///
2817    /// Even though the property as already been set when instantiating this call,
2818    /// we provide this method for API completeness.
2819    pub fn resource(mut self, new_value: &str) -> OrganizationVersionSearchCall<'a, C> {
2820        self._resource = new_value.to_string();
2821        self
2822    }
2823    /// The query to filter the versions. Required.
2824    ///
2825    /// The supported queries are:
2826    /// * List versions under a product:
2827    /// `parent=catalogs/{catalog_id}/products/{product_id}`
2828    /// * Get a version by name:
2829    /// `name=catalogs/{catalog_id}/products/{product_id}/versions/{version_id}`
2830    ///
2831    /// Sets the *query* query property to the given value.
2832    pub fn query(mut self, new_value: &str) -> OrganizationVersionSearchCall<'a, C> {
2833        self._query = Some(new_value.to_string());
2834        self
2835    }
2836    /// A pagination token returned from a previous call to SearchVersions
2837    /// that indicates where this listing should continue from.
2838    /// This field is optional.
2839    ///
2840    /// Sets the *page token* query property to the given value.
2841    pub fn page_token(mut self, new_value: &str) -> OrganizationVersionSearchCall<'a, C> {
2842        self._page_token = Some(new_value.to_string());
2843        self
2844    }
2845    /// The maximum number of entries that are requested.
2846    ///
2847    /// Sets the *page size* query property to the given value.
2848    pub fn page_size(mut self, new_value: i32) -> OrganizationVersionSearchCall<'a, C> {
2849        self._page_size = Some(new_value);
2850        self
2851    }
2852    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2853    /// while executing the actual API request.
2854    ///
2855    /// ````text
2856    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2857    /// ````
2858    ///
2859    /// Sets the *delegate* property to the given value.
2860    pub fn delegate(
2861        mut self,
2862        new_value: &'a mut dyn common::Delegate,
2863    ) -> OrganizationVersionSearchCall<'a, C> {
2864        self._delegate = Some(new_value);
2865        self
2866    }
2867
2868    /// Set any additional parameter of the query string used in the request.
2869    /// It should be used to set parameters which are not yet available through their own
2870    /// setters.
2871    ///
2872    /// Please note that this method must not be used to set any of the known parameters
2873    /// which have their own setter method. If done anyway, the request will fail.
2874    ///
2875    /// # Additional Parameters
2876    ///
2877    /// * *$.xgafv* (query-string) - V1 error format.
2878    /// * *access_token* (query-string) - OAuth access token.
2879    /// * *alt* (query-string) - Data format for response.
2880    /// * *callback* (query-string) - JSONP
2881    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2882    /// * *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.
2883    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2884    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2885    /// * *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.
2886    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2887    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2888    pub fn param<T>(mut self, name: T, value: T) -> OrganizationVersionSearchCall<'a, C>
2889    where
2890        T: AsRef<str>,
2891    {
2892        self._additional_params
2893            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2894        self
2895    }
2896
2897    /// Identifies the authorization scope for the method you are building.
2898    ///
2899    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2900    /// [`Scope::CloudPlatform`].
2901    ///
2902    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2903    /// tokens for more than one scope.
2904    ///
2905    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2906    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2907    /// sufficient, a read-write scope will do as well.
2908    pub fn add_scope<St>(mut self, scope: St) -> OrganizationVersionSearchCall<'a, C>
2909    where
2910        St: AsRef<str>,
2911    {
2912        self._scopes.insert(String::from(scope.as_ref()));
2913        self
2914    }
2915    /// Identifies the authorization scope(s) for the method you are building.
2916    ///
2917    /// See [`Self::add_scope()`] for details.
2918    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationVersionSearchCall<'a, C>
2919    where
2920        I: IntoIterator<Item = St>,
2921        St: AsRef<str>,
2922    {
2923        self._scopes
2924            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2925        self
2926    }
2927
2928    /// Removes all scopes, and no default scope will be used either.
2929    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2930    /// for details).
2931    pub fn clear_scopes(mut self) -> OrganizationVersionSearchCall<'a, C> {
2932        self._scopes.clear();
2933        self
2934    }
2935}
2936
2937/// Search Catalog resources that consumers have access to, within the
2938/// scope of the consumer cloud resource hierarchy context.
2939///
2940/// A builder for the *catalogs.search* method supported by a *project* resource.
2941/// It is not used directly, but through a [`ProjectMethods`] instance.
2942///
2943/// # Example
2944///
2945/// Instantiate a resource method builder
2946///
2947/// ```test_harness,no_run
2948/// # extern crate hyper;
2949/// # extern crate hyper_rustls;
2950/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
2951/// # async fn dox() {
2952/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2953///
2954/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2955/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2956/// #     .with_native_roots()
2957/// #     .unwrap()
2958/// #     .https_only()
2959/// #     .enable_http2()
2960/// #     .build();
2961///
2962/// # let executor = hyper_util::rt::TokioExecutor::new();
2963/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2964/// #     secret,
2965/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2966/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2967/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2968/// #     ),
2969/// # ).build().await.unwrap();
2970///
2971/// # let client = hyper_util::client::legacy::Client::builder(
2972/// #     hyper_util::rt::TokioExecutor::new()
2973/// # )
2974/// # .build(
2975/// #     hyper_rustls::HttpsConnectorBuilder::new()
2976/// #         .with_native_roots()
2977/// #         .unwrap()
2978/// #         .https_or_http()
2979/// #         .enable_http2()
2980/// #         .build()
2981/// # );
2982/// # let mut hub = CloudPrivateCatalog::new(client, auth);
2983/// // You can configure optional parameters by calling the respective setters at will, and
2984/// // execute the final call using `doit()`.
2985/// // Values shown here are possibly random and not representative !
2986/// let result = hub.projects().catalogs_search("resource")
2987///              .query("labore")
2988///              .page_token("sed")
2989///              .page_size(-70)
2990///              .doit().await;
2991/// # }
2992/// ```
2993pub struct ProjectCatalogSearchCall<'a, C>
2994where
2995    C: 'a,
2996{
2997    hub: &'a CloudPrivateCatalog<C>,
2998    _resource: String,
2999    _query: Option<String>,
3000    _page_token: Option<String>,
3001    _page_size: Option<i32>,
3002    _delegate: Option<&'a mut dyn common::Delegate>,
3003    _additional_params: HashMap<String, String>,
3004    _scopes: BTreeSet<String>,
3005}
3006
3007impl<'a, C> common::CallBuilder for ProjectCatalogSearchCall<'a, C> {}
3008
3009impl<'a, C> ProjectCatalogSearchCall<'a, C>
3010where
3011    C: common::Connector,
3012{
3013    /// Perform the operation you have build so far.
3014    pub async fn doit(
3015        mut self,
3016    ) -> common::Result<(
3017        common::Response,
3018        GoogleCloudPrivatecatalogV1beta1SearchCatalogsResponse,
3019    )> {
3020        use std::borrow::Cow;
3021        use std::io::{Read, Seek};
3022
3023        use common::{url::Params, ToParts};
3024        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3025
3026        let mut dd = common::DefaultDelegate;
3027        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3028        dlg.begin(common::MethodInfo {
3029            id: "cloudprivatecatalog.projects.catalogs.search",
3030            http_method: hyper::Method::GET,
3031        });
3032
3033        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
3034            if self._additional_params.contains_key(field) {
3035                dlg.finished(false);
3036                return Err(common::Error::FieldClash(field));
3037            }
3038        }
3039
3040        let mut params = Params::with_capacity(6 + self._additional_params.len());
3041        params.push("resource", self._resource);
3042        if let Some(value) = self._query.as_ref() {
3043            params.push("query", value);
3044        }
3045        if let Some(value) = self._page_token.as_ref() {
3046            params.push("pageToken", value);
3047        }
3048        if let Some(value) = self._page_size.as_ref() {
3049            params.push("pageSize", value.to_string());
3050        }
3051
3052        params.extend(self._additional_params.iter());
3053
3054        params.push("alt", "json");
3055        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/catalogs:search";
3056        if self._scopes.is_empty() {
3057            self._scopes
3058                .insert(Scope::CloudPlatform.as_ref().to_string());
3059        }
3060
3061        #[allow(clippy::single_element_loop)]
3062        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3063            url = params.uri_replacement(url, param_name, find_this, true);
3064        }
3065        {
3066            let to_remove = ["resource"];
3067            params.remove_params(&to_remove);
3068        }
3069
3070        let url = params.parse_with_url(&url);
3071
3072        loop {
3073            let token = match self
3074                .hub
3075                .auth
3076                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3077                .await
3078            {
3079                Ok(token) => token,
3080                Err(e) => match dlg.token(e) {
3081                    Ok(token) => token,
3082                    Err(e) => {
3083                        dlg.finished(false);
3084                        return Err(common::Error::MissingToken(e));
3085                    }
3086                },
3087            };
3088            let mut req_result = {
3089                let client = &self.hub.client;
3090                dlg.pre_request();
3091                let mut req_builder = hyper::Request::builder()
3092                    .method(hyper::Method::GET)
3093                    .uri(url.as_str())
3094                    .header(USER_AGENT, self.hub._user_agent.clone());
3095
3096                if let Some(token) = token.as_ref() {
3097                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3098                }
3099
3100                let request = req_builder
3101                    .header(CONTENT_LENGTH, 0_u64)
3102                    .body(common::to_body::<String>(None));
3103
3104                client.request(request.unwrap()).await
3105            };
3106
3107            match req_result {
3108                Err(err) => {
3109                    if let common::Retry::After(d) = dlg.http_error(&err) {
3110                        sleep(d).await;
3111                        continue;
3112                    }
3113                    dlg.finished(false);
3114                    return Err(common::Error::HttpError(err));
3115                }
3116                Ok(res) => {
3117                    let (mut parts, body) = res.into_parts();
3118                    let mut body = common::Body::new(body);
3119                    if !parts.status.is_success() {
3120                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3121                        let error = serde_json::from_str(&common::to_string(&bytes));
3122                        let response = common::to_response(parts, bytes.into());
3123
3124                        if let common::Retry::After(d) =
3125                            dlg.http_failure(&response, error.as_ref().ok())
3126                        {
3127                            sleep(d).await;
3128                            continue;
3129                        }
3130
3131                        dlg.finished(false);
3132
3133                        return Err(match error {
3134                            Ok(value) => common::Error::BadRequest(value),
3135                            _ => common::Error::Failure(response),
3136                        });
3137                    }
3138                    let response = {
3139                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3140                        let encoded = common::to_string(&bytes);
3141                        match serde_json::from_str(&encoded) {
3142                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3143                            Err(error) => {
3144                                dlg.response_json_decode_error(&encoded, &error);
3145                                return Err(common::Error::JsonDecodeError(
3146                                    encoded.to_string(),
3147                                    error,
3148                                ));
3149                            }
3150                        }
3151                    };
3152
3153                    dlg.finished(true);
3154                    return Ok(response);
3155                }
3156            }
3157        }
3158    }
3159
3160    /// Required. The name of the resource context. It can be in following formats:
3161    ///
3162    /// * `projects/{project_id}`
3163    /// * `folders/{folder_id}`
3164    /// * `organizations/{organization_id}`
3165    ///
3166    /// Sets the *resource* path property to the given value.
3167    ///
3168    /// Even though the property as already been set when instantiating this call,
3169    /// we provide this method for API completeness.
3170    pub fn resource(mut self, new_value: &str) -> ProjectCatalogSearchCall<'a, C> {
3171        self._resource = new_value.to_string();
3172        self
3173    }
3174    /// The query to filter the catalogs. The supported queries are:
3175    ///
3176    /// * Get a single catalog: `name=catalogs/{catalog_id}`
3177    ///
3178    /// Sets the *query* query property to the given value.
3179    pub fn query(mut self, new_value: &str) -> ProjectCatalogSearchCall<'a, C> {
3180        self._query = Some(new_value.to_string());
3181        self
3182    }
3183    /// A pagination token returned from a previous call to SearchCatalogs that
3184    /// indicates where this listing should continue from.
3185    /// This field is optional.
3186    ///
3187    /// Sets the *page token* query property to the given value.
3188    pub fn page_token(mut self, new_value: &str) -> ProjectCatalogSearchCall<'a, C> {
3189        self._page_token = Some(new_value.to_string());
3190        self
3191    }
3192    /// The maximum number of entries that are requested.
3193    ///
3194    /// Sets the *page size* query property to the given value.
3195    pub fn page_size(mut self, new_value: i32) -> ProjectCatalogSearchCall<'a, C> {
3196        self._page_size = Some(new_value);
3197        self
3198    }
3199    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3200    /// while executing the actual API request.
3201    ///
3202    /// ````text
3203    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3204    /// ````
3205    ///
3206    /// Sets the *delegate* property to the given value.
3207    pub fn delegate(
3208        mut self,
3209        new_value: &'a mut dyn common::Delegate,
3210    ) -> ProjectCatalogSearchCall<'a, C> {
3211        self._delegate = Some(new_value);
3212        self
3213    }
3214
3215    /// Set any additional parameter of the query string used in the request.
3216    /// It should be used to set parameters which are not yet available through their own
3217    /// setters.
3218    ///
3219    /// Please note that this method must not be used to set any of the known parameters
3220    /// which have their own setter method. If done anyway, the request will fail.
3221    ///
3222    /// # Additional Parameters
3223    ///
3224    /// * *$.xgafv* (query-string) - V1 error format.
3225    /// * *access_token* (query-string) - OAuth access token.
3226    /// * *alt* (query-string) - Data format for response.
3227    /// * *callback* (query-string) - JSONP
3228    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3229    /// * *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.
3230    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3231    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3232    /// * *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.
3233    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3234    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3235    pub fn param<T>(mut self, name: T, value: T) -> ProjectCatalogSearchCall<'a, C>
3236    where
3237        T: AsRef<str>,
3238    {
3239        self._additional_params
3240            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3241        self
3242    }
3243
3244    /// Identifies the authorization scope for the method you are building.
3245    ///
3246    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3247    /// [`Scope::CloudPlatform`].
3248    ///
3249    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3250    /// tokens for more than one scope.
3251    ///
3252    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3253    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3254    /// sufficient, a read-write scope will do as well.
3255    pub fn add_scope<St>(mut self, scope: St) -> ProjectCatalogSearchCall<'a, C>
3256    where
3257        St: AsRef<str>,
3258    {
3259        self._scopes.insert(String::from(scope.as_ref()));
3260        self
3261    }
3262    /// Identifies the authorization scope(s) for the method you are building.
3263    ///
3264    /// See [`Self::add_scope()`] for details.
3265    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectCatalogSearchCall<'a, C>
3266    where
3267        I: IntoIterator<Item = St>,
3268        St: AsRef<str>,
3269    {
3270        self._scopes
3271            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3272        self
3273    }
3274
3275    /// Removes all scopes, and no default scope will be used either.
3276    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3277    /// for details).
3278    pub fn clear_scopes(mut self) -> ProjectCatalogSearchCall<'a, C> {
3279        self._scopes.clear();
3280        self
3281    }
3282}
3283
3284/// Search Product resources that consumers have access to, within the
3285/// scope of the consumer cloud resource hierarchy context.
3286///
3287/// A builder for the *products.search* method supported by a *project* resource.
3288/// It is not used directly, but through a [`ProjectMethods`] instance.
3289///
3290/// # Example
3291///
3292/// Instantiate a resource method builder
3293///
3294/// ```test_harness,no_run
3295/// # extern crate hyper;
3296/// # extern crate hyper_rustls;
3297/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
3298/// # async fn dox() {
3299/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3300///
3301/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3302/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3303/// #     .with_native_roots()
3304/// #     .unwrap()
3305/// #     .https_only()
3306/// #     .enable_http2()
3307/// #     .build();
3308///
3309/// # let executor = hyper_util::rt::TokioExecutor::new();
3310/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3311/// #     secret,
3312/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3313/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3314/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3315/// #     ),
3316/// # ).build().await.unwrap();
3317///
3318/// # let client = hyper_util::client::legacy::Client::builder(
3319/// #     hyper_util::rt::TokioExecutor::new()
3320/// # )
3321/// # .build(
3322/// #     hyper_rustls::HttpsConnectorBuilder::new()
3323/// #         .with_native_roots()
3324/// #         .unwrap()
3325/// #         .https_or_http()
3326/// #         .enable_http2()
3327/// #         .build()
3328/// # );
3329/// # let mut hub = CloudPrivateCatalog::new(client, auth);
3330/// // You can configure optional parameters by calling the respective setters at will, and
3331/// // execute the final call using `doit()`.
3332/// // Values shown here are possibly random and not representative !
3333/// let result = hub.projects().products_search("resource")
3334///              .query("no")
3335///              .page_token("Stet")
3336///              .page_size(-13)
3337///              .doit().await;
3338/// # }
3339/// ```
3340pub struct ProjectProductSearchCall<'a, C>
3341where
3342    C: 'a,
3343{
3344    hub: &'a CloudPrivateCatalog<C>,
3345    _resource: String,
3346    _query: Option<String>,
3347    _page_token: Option<String>,
3348    _page_size: Option<i32>,
3349    _delegate: Option<&'a mut dyn common::Delegate>,
3350    _additional_params: HashMap<String, String>,
3351    _scopes: BTreeSet<String>,
3352}
3353
3354impl<'a, C> common::CallBuilder for ProjectProductSearchCall<'a, C> {}
3355
3356impl<'a, C> ProjectProductSearchCall<'a, C>
3357where
3358    C: common::Connector,
3359{
3360    /// Perform the operation you have build so far.
3361    pub async fn doit(
3362        mut self,
3363    ) -> common::Result<(
3364        common::Response,
3365        GoogleCloudPrivatecatalogV1beta1SearchProductsResponse,
3366    )> {
3367        use std::borrow::Cow;
3368        use std::io::{Read, Seek};
3369
3370        use common::{url::Params, ToParts};
3371        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3372
3373        let mut dd = common::DefaultDelegate;
3374        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3375        dlg.begin(common::MethodInfo {
3376            id: "cloudprivatecatalog.projects.products.search",
3377            http_method: hyper::Method::GET,
3378        });
3379
3380        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
3381            if self._additional_params.contains_key(field) {
3382                dlg.finished(false);
3383                return Err(common::Error::FieldClash(field));
3384            }
3385        }
3386
3387        let mut params = Params::with_capacity(6 + self._additional_params.len());
3388        params.push("resource", self._resource);
3389        if let Some(value) = self._query.as_ref() {
3390            params.push("query", value);
3391        }
3392        if let Some(value) = self._page_token.as_ref() {
3393            params.push("pageToken", value);
3394        }
3395        if let Some(value) = self._page_size.as_ref() {
3396            params.push("pageSize", value.to_string());
3397        }
3398
3399        params.extend(self._additional_params.iter());
3400
3401        params.push("alt", "json");
3402        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/products:search";
3403        if self._scopes.is_empty() {
3404            self._scopes
3405                .insert(Scope::CloudPlatform.as_ref().to_string());
3406        }
3407
3408        #[allow(clippy::single_element_loop)]
3409        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3410            url = params.uri_replacement(url, param_name, find_this, true);
3411        }
3412        {
3413            let to_remove = ["resource"];
3414            params.remove_params(&to_remove);
3415        }
3416
3417        let url = params.parse_with_url(&url);
3418
3419        loop {
3420            let token = match self
3421                .hub
3422                .auth
3423                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3424                .await
3425            {
3426                Ok(token) => token,
3427                Err(e) => match dlg.token(e) {
3428                    Ok(token) => token,
3429                    Err(e) => {
3430                        dlg.finished(false);
3431                        return Err(common::Error::MissingToken(e));
3432                    }
3433                },
3434            };
3435            let mut req_result = {
3436                let client = &self.hub.client;
3437                dlg.pre_request();
3438                let mut req_builder = hyper::Request::builder()
3439                    .method(hyper::Method::GET)
3440                    .uri(url.as_str())
3441                    .header(USER_AGENT, self.hub._user_agent.clone());
3442
3443                if let Some(token) = token.as_ref() {
3444                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3445                }
3446
3447                let request = req_builder
3448                    .header(CONTENT_LENGTH, 0_u64)
3449                    .body(common::to_body::<String>(None));
3450
3451                client.request(request.unwrap()).await
3452            };
3453
3454            match req_result {
3455                Err(err) => {
3456                    if let common::Retry::After(d) = dlg.http_error(&err) {
3457                        sleep(d).await;
3458                        continue;
3459                    }
3460                    dlg.finished(false);
3461                    return Err(common::Error::HttpError(err));
3462                }
3463                Ok(res) => {
3464                    let (mut parts, body) = res.into_parts();
3465                    let mut body = common::Body::new(body);
3466                    if !parts.status.is_success() {
3467                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3468                        let error = serde_json::from_str(&common::to_string(&bytes));
3469                        let response = common::to_response(parts, bytes.into());
3470
3471                        if let common::Retry::After(d) =
3472                            dlg.http_failure(&response, error.as_ref().ok())
3473                        {
3474                            sleep(d).await;
3475                            continue;
3476                        }
3477
3478                        dlg.finished(false);
3479
3480                        return Err(match error {
3481                            Ok(value) => common::Error::BadRequest(value),
3482                            _ => common::Error::Failure(response),
3483                        });
3484                    }
3485                    let response = {
3486                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3487                        let encoded = common::to_string(&bytes);
3488                        match serde_json::from_str(&encoded) {
3489                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3490                            Err(error) => {
3491                                dlg.response_json_decode_error(&encoded, &error);
3492                                return Err(common::Error::JsonDecodeError(
3493                                    encoded.to_string(),
3494                                    error,
3495                                ));
3496                            }
3497                        }
3498                    };
3499
3500                    dlg.finished(true);
3501                    return Ok(response);
3502                }
3503            }
3504        }
3505    }
3506
3507    /// Required. The name of the resource context. See
3508    /// SearchCatalogsRequest.resource for details.
3509    ///
3510    /// Sets the *resource* path property to the given value.
3511    ///
3512    /// Even though the property as already been set when instantiating this call,
3513    /// we provide this method for API completeness.
3514    pub fn resource(mut self, new_value: &str) -> ProjectProductSearchCall<'a, C> {
3515        self._resource = new_value.to_string();
3516        self
3517    }
3518    /// The query to filter the products.
3519    ///
3520    /// The supported queries are:
3521    /// * List products of all catalogs: empty
3522    /// * List products under a catalog: `parent=catalogs/{catalog_id}`
3523    /// * Get a product by name:
3524    /// `name=catalogs/{catalog_id}/products/{product_id}`
3525    ///
3526    /// Sets the *query* query property to the given value.
3527    pub fn query(mut self, new_value: &str) -> ProjectProductSearchCall<'a, C> {
3528        self._query = Some(new_value.to_string());
3529        self
3530    }
3531    /// A pagination token returned from a previous call to SearchProducts that
3532    /// indicates where this listing should continue from.
3533    /// This field is optional.
3534    ///
3535    /// Sets the *page token* query property to the given value.
3536    pub fn page_token(mut self, new_value: &str) -> ProjectProductSearchCall<'a, C> {
3537        self._page_token = Some(new_value.to_string());
3538        self
3539    }
3540    /// The maximum number of entries that are requested.
3541    ///
3542    /// Sets the *page size* query property to the given value.
3543    pub fn page_size(mut self, new_value: i32) -> ProjectProductSearchCall<'a, C> {
3544        self._page_size = Some(new_value);
3545        self
3546    }
3547    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3548    /// while executing the actual API request.
3549    ///
3550    /// ````text
3551    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3552    /// ````
3553    ///
3554    /// Sets the *delegate* property to the given value.
3555    pub fn delegate(
3556        mut self,
3557        new_value: &'a mut dyn common::Delegate,
3558    ) -> ProjectProductSearchCall<'a, C> {
3559        self._delegate = Some(new_value);
3560        self
3561    }
3562
3563    /// Set any additional parameter of the query string used in the request.
3564    /// It should be used to set parameters which are not yet available through their own
3565    /// setters.
3566    ///
3567    /// Please note that this method must not be used to set any of the known parameters
3568    /// which have their own setter method. If done anyway, the request will fail.
3569    ///
3570    /// # Additional Parameters
3571    ///
3572    /// * *$.xgafv* (query-string) - V1 error format.
3573    /// * *access_token* (query-string) - OAuth access token.
3574    /// * *alt* (query-string) - Data format for response.
3575    /// * *callback* (query-string) - JSONP
3576    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3577    /// * *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.
3578    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3579    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3580    /// * *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.
3581    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3582    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3583    pub fn param<T>(mut self, name: T, value: T) -> ProjectProductSearchCall<'a, C>
3584    where
3585        T: AsRef<str>,
3586    {
3587        self._additional_params
3588            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3589        self
3590    }
3591
3592    /// Identifies the authorization scope for the method you are building.
3593    ///
3594    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3595    /// [`Scope::CloudPlatform`].
3596    ///
3597    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3598    /// tokens for more than one scope.
3599    ///
3600    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3601    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3602    /// sufficient, a read-write scope will do as well.
3603    pub fn add_scope<St>(mut self, scope: St) -> ProjectProductSearchCall<'a, C>
3604    where
3605        St: AsRef<str>,
3606    {
3607        self._scopes.insert(String::from(scope.as_ref()));
3608        self
3609    }
3610    /// Identifies the authorization scope(s) for the method you are building.
3611    ///
3612    /// See [`Self::add_scope()`] for details.
3613    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectProductSearchCall<'a, C>
3614    where
3615        I: IntoIterator<Item = St>,
3616        St: AsRef<str>,
3617    {
3618        self._scopes
3619            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3620        self
3621    }
3622
3623    /// Removes all scopes, and no default scope will be used either.
3624    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3625    /// for details).
3626    pub fn clear_scopes(mut self) -> ProjectProductSearchCall<'a, C> {
3627        self._scopes.clear();
3628        self
3629    }
3630}
3631
3632/// Search Version resources that consumers have access to, within the
3633/// scope of the consumer cloud resource hierarchy context.
3634///
3635/// A builder for the *versions.search* method supported by a *project* resource.
3636/// It is not used directly, but through a [`ProjectMethods`] instance.
3637///
3638/// # Example
3639///
3640/// Instantiate a resource method builder
3641///
3642/// ```test_harness,no_run
3643/// # extern crate hyper;
3644/// # extern crate hyper_rustls;
3645/// # extern crate google_cloudprivatecatalog1_beta1 as cloudprivatecatalog1_beta1;
3646/// # async fn dox() {
3647/// # use cloudprivatecatalog1_beta1::{CloudPrivateCatalog, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3648///
3649/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3650/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3651/// #     .with_native_roots()
3652/// #     .unwrap()
3653/// #     .https_only()
3654/// #     .enable_http2()
3655/// #     .build();
3656///
3657/// # let executor = hyper_util::rt::TokioExecutor::new();
3658/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3659/// #     secret,
3660/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3661/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3662/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3663/// #     ),
3664/// # ).build().await.unwrap();
3665///
3666/// # let client = hyper_util::client::legacy::Client::builder(
3667/// #     hyper_util::rt::TokioExecutor::new()
3668/// # )
3669/// # .build(
3670/// #     hyper_rustls::HttpsConnectorBuilder::new()
3671/// #         .with_native_roots()
3672/// #         .unwrap()
3673/// #         .https_or_http()
3674/// #         .enable_http2()
3675/// #         .build()
3676/// # );
3677/// # let mut hub = CloudPrivateCatalog::new(client, auth);
3678/// // You can configure optional parameters by calling the respective setters at will, and
3679/// // execute the final call using `doit()`.
3680/// // Values shown here are possibly random and not representative !
3681/// let result = hub.projects().versions_search("resource")
3682///              .query("sed")
3683///              .page_token("et")
3684///              .page_size(-68)
3685///              .doit().await;
3686/// # }
3687/// ```
3688pub struct ProjectVersionSearchCall<'a, C>
3689where
3690    C: 'a,
3691{
3692    hub: &'a CloudPrivateCatalog<C>,
3693    _resource: String,
3694    _query: Option<String>,
3695    _page_token: Option<String>,
3696    _page_size: Option<i32>,
3697    _delegate: Option<&'a mut dyn common::Delegate>,
3698    _additional_params: HashMap<String, String>,
3699    _scopes: BTreeSet<String>,
3700}
3701
3702impl<'a, C> common::CallBuilder for ProjectVersionSearchCall<'a, C> {}
3703
3704impl<'a, C> ProjectVersionSearchCall<'a, C>
3705where
3706    C: common::Connector,
3707{
3708    /// Perform the operation you have build so far.
3709    pub async fn doit(
3710        mut self,
3711    ) -> common::Result<(
3712        common::Response,
3713        GoogleCloudPrivatecatalogV1beta1SearchVersionsResponse,
3714    )> {
3715        use std::borrow::Cow;
3716        use std::io::{Read, Seek};
3717
3718        use common::{url::Params, ToParts};
3719        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3720
3721        let mut dd = common::DefaultDelegate;
3722        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3723        dlg.begin(common::MethodInfo {
3724            id: "cloudprivatecatalog.projects.versions.search",
3725            http_method: hyper::Method::GET,
3726        });
3727
3728        for &field in ["alt", "resource", "query", "pageToken", "pageSize"].iter() {
3729            if self._additional_params.contains_key(field) {
3730                dlg.finished(false);
3731                return Err(common::Error::FieldClash(field));
3732            }
3733        }
3734
3735        let mut params = Params::with_capacity(6 + self._additional_params.len());
3736        params.push("resource", self._resource);
3737        if let Some(value) = self._query.as_ref() {
3738            params.push("query", value);
3739        }
3740        if let Some(value) = self._page_token.as_ref() {
3741            params.push("pageToken", value);
3742        }
3743        if let Some(value) = self._page_size.as_ref() {
3744            params.push("pageSize", value.to_string());
3745        }
3746
3747        params.extend(self._additional_params.iter());
3748
3749        params.push("alt", "json");
3750        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}/versions:search";
3751        if self._scopes.is_empty() {
3752            self._scopes
3753                .insert(Scope::CloudPlatform.as_ref().to_string());
3754        }
3755
3756        #[allow(clippy::single_element_loop)]
3757        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3758            url = params.uri_replacement(url, param_name, find_this, true);
3759        }
3760        {
3761            let to_remove = ["resource"];
3762            params.remove_params(&to_remove);
3763        }
3764
3765        let url = params.parse_with_url(&url);
3766
3767        loop {
3768            let token = match self
3769                .hub
3770                .auth
3771                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3772                .await
3773            {
3774                Ok(token) => token,
3775                Err(e) => match dlg.token(e) {
3776                    Ok(token) => token,
3777                    Err(e) => {
3778                        dlg.finished(false);
3779                        return Err(common::Error::MissingToken(e));
3780                    }
3781                },
3782            };
3783            let mut req_result = {
3784                let client = &self.hub.client;
3785                dlg.pre_request();
3786                let mut req_builder = hyper::Request::builder()
3787                    .method(hyper::Method::GET)
3788                    .uri(url.as_str())
3789                    .header(USER_AGENT, self.hub._user_agent.clone());
3790
3791                if let Some(token) = token.as_ref() {
3792                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3793                }
3794
3795                let request = req_builder
3796                    .header(CONTENT_LENGTH, 0_u64)
3797                    .body(common::to_body::<String>(None));
3798
3799                client.request(request.unwrap()).await
3800            };
3801
3802            match req_result {
3803                Err(err) => {
3804                    if let common::Retry::After(d) = dlg.http_error(&err) {
3805                        sleep(d).await;
3806                        continue;
3807                    }
3808                    dlg.finished(false);
3809                    return Err(common::Error::HttpError(err));
3810                }
3811                Ok(res) => {
3812                    let (mut parts, body) = res.into_parts();
3813                    let mut body = common::Body::new(body);
3814                    if !parts.status.is_success() {
3815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3816                        let error = serde_json::from_str(&common::to_string(&bytes));
3817                        let response = common::to_response(parts, bytes.into());
3818
3819                        if let common::Retry::After(d) =
3820                            dlg.http_failure(&response, error.as_ref().ok())
3821                        {
3822                            sleep(d).await;
3823                            continue;
3824                        }
3825
3826                        dlg.finished(false);
3827
3828                        return Err(match error {
3829                            Ok(value) => common::Error::BadRequest(value),
3830                            _ => common::Error::Failure(response),
3831                        });
3832                    }
3833                    let response = {
3834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3835                        let encoded = common::to_string(&bytes);
3836                        match serde_json::from_str(&encoded) {
3837                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3838                            Err(error) => {
3839                                dlg.response_json_decode_error(&encoded, &error);
3840                                return Err(common::Error::JsonDecodeError(
3841                                    encoded.to_string(),
3842                                    error,
3843                                ));
3844                            }
3845                        }
3846                    };
3847
3848                    dlg.finished(true);
3849                    return Ok(response);
3850                }
3851            }
3852        }
3853    }
3854
3855    /// Required. The name of the resource context. See
3856    /// SearchCatalogsRequest.resource for details.
3857    ///
3858    /// Sets the *resource* path property to the given value.
3859    ///
3860    /// Even though the property as already been set when instantiating this call,
3861    /// we provide this method for API completeness.
3862    pub fn resource(mut self, new_value: &str) -> ProjectVersionSearchCall<'a, C> {
3863        self._resource = new_value.to_string();
3864        self
3865    }
3866    /// The query to filter the versions. Required.
3867    ///
3868    /// The supported queries are:
3869    /// * List versions under a product:
3870    /// `parent=catalogs/{catalog_id}/products/{product_id}`
3871    /// * Get a version by name:
3872    /// `name=catalogs/{catalog_id}/products/{product_id}/versions/{version_id}`
3873    ///
3874    /// Sets the *query* query property to the given value.
3875    pub fn query(mut self, new_value: &str) -> ProjectVersionSearchCall<'a, C> {
3876        self._query = Some(new_value.to_string());
3877        self
3878    }
3879    /// A pagination token returned from a previous call to SearchVersions
3880    /// that indicates where this listing should continue from.
3881    /// This field is optional.
3882    ///
3883    /// Sets the *page token* query property to the given value.
3884    pub fn page_token(mut self, new_value: &str) -> ProjectVersionSearchCall<'a, C> {
3885        self._page_token = Some(new_value.to_string());
3886        self
3887    }
3888    /// The maximum number of entries that are requested.
3889    ///
3890    /// Sets the *page size* query property to the given value.
3891    pub fn page_size(mut self, new_value: i32) -> ProjectVersionSearchCall<'a, C> {
3892        self._page_size = Some(new_value);
3893        self
3894    }
3895    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3896    /// while executing the actual API request.
3897    ///
3898    /// ````text
3899    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3900    /// ````
3901    ///
3902    /// Sets the *delegate* property to the given value.
3903    pub fn delegate(
3904        mut self,
3905        new_value: &'a mut dyn common::Delegate,
3906    ) -> ProjectVersionSearchCall<'a, C> {
3907        self._delegate = Some(new_value);
3908        self
3909    }
3910
3911    /// Set any additional parameter of the query string used in the request.
3912    /// It should be used to set parameters which are not yet available through their own
3913    /// setters.
3914    ///
3915    /// Please note that this method must not be used to set any of the known parameters
3916    /// which have their own setter method. If done anyway, the request will fail.
3917    ///
3918    /// # Additional Parameters
3919    ///
3920    /// * *$.xgafv* (query-string) - V1 error format.
3921    /// * *access_token* (query-string) - OAuth access token.
3922    /// * *alt* (query-string) - Data format for response.
3923    /// * *callback* (query-string) - JSONP
3924    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3925    /// * *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.
3926    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3927    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3928    /// * *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.
3929    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3930    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3931    pub fn param<T>(mut self, name: T, value: T) -> ProjectVersionSearchCall<'a, C>
3932    where
3933        T: AsRef<str>,
3934    {
3935        self._additional_params
3936            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3937        self
3938    }
3939
3940    /// Identifies the authorization scope for the method you are building.
3941    ///
3942    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3943    /// [`Scope::CloudPlatform`].
3944    ///
3945    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3946    /// tokens for more than one scope.
3947    ///
3948    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3949    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3950    /// sufficient, a read-write scope will do as well.
3951    pub fn add_scope<St>(mut self, scope: St) -> ProjectVersionSearchCall<'a, C>
3952    where
3953        St: AsRef<str>,
3954    {
3955        self._scopes.insert(String::from(scope.as_ref()));
3956        self
3957    }
3958    /// Identifies the authorization scope(s) for the method you are building.
3959    ///
3960    /// See [`Self::add_scope()`] for details.
3961    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectVersionSearchCall<'a, C>
3962    where
3963        I: IntoIterator<Item = St>,
3964        St: AsRef<str>,
3965    {
3966        self._scopes
3967            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3968        self
3969    }
3970
3971    /// Removes all scopes, and no default scope will be used either.
3972    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3973    /// for details).
3974    pub fn clear_scopes(mut self) -> ProjectVersionSearchCall<'a, C> {
3975        self._scopes.clear();
3976        self
3977    }
3978}