google_analytics3/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// View and manage your Google Analytics data
17    Full,
18
19    /// Edit Google Analytics management entities
20    Edit,
21
22    /// Manage Google Analytics Account users by email address
23    ManageUser,
24
25    /// View Google Analytics user permissions
26    ManageUserReadonly,
27
28    /// Create a new Google Analytics account along with its default property and view
29    Provision,
30
31    /// View your Google Analytics data
32    Readonly,
33
34    /// Manage Google Analytics user deletion requests
35    UserDeletion,
36}
37
38impl AsRef<str> for Scope {
39    fn as_ref(&self) -> &str {
40        match *self {
41            Scope::Full => "https://www.googleapis.com/auth/analytics",
42            Scope::Edit => "https://www.googleapis.com/auth/analytics.edit",
43            Scope::ManageUser => "https://www.googleapis.com/auth/analytics.manage.users",
44            Scope::ManageUserReadonly => {
45                "https://www.googleapis.com/auth/analytics.manage.users.readonly"
46            }
47            Scope::Provision => "https://www.googleapis.com/auth/analytics.provision",
48            Scope::Readonly => "https://www.googleapis.com/auth/analytics.readonly",
49            Scope::UserDeletion => "https://www.googleapis.com/auth/analytics.user.deletion",
50        }
51    }
52}
53
54#[allow(clippy::derivable_impls)]
55impl Default for Scope {
56    fn default() -> Scope {
57        Scope::ManageUserReadonly
58    }
59}
60
61// ########
62// HUB ###
63// ######
64
65/// Central instance to access all Analytics related resource activities
66///
67/// # Examples
68///
69/// Instantiate a new hub
70///
71/// ```test_harness,no_run
72/// extern crate hyper;
73/// extern crate hyper_rustls;
74/// extern crate google_analytics3 as analytics3;
75/// use analytics3::api::EntityUserLink;
76/// use analytics3::{Result, Error};
77/// # async fn dox() {
78/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
79///
80/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
81/// // `client_secret`, among other things.
82/// let secret: yup_oauth2::ApplicationSecret = Default::default();
83/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
84/// // unless you replace  `None` with the desired Flow.
85/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
86/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
87/// // retrieve them from storage.
88/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
89///     .with_native_roots()
90///     .unwrap()
91///     .https_only()
92///     .enable_http2()
93///     .build();
94///
95/// let executor = hyper_util::rt::TokioExecutor::new();
96/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
97///     secret,
98///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
99///     yup_oauth2::client::CustomHyperClientBuilder::from(
100///         hyper_util::client::legacy::Client::builder(executor).build(connector),
101///     ),
102/// ).build().await.unwrap();
103///
104/// let client = hyper_util::client::legacy::Client::builder(
105///     hyper_util::rt::TokioExecutor::new()
106/// )
107/// .build(
108///     hyper_rustls::HttpsConnectorBuilder::new()
109///         .with_native_roots()
110///         .unwrap()
111///         .https_or_http()
112///         .enable_http2()
113///         .build()
114/// );
115/// let mut hub = Analytics::new(client, auth);
116/// // As the method needs a request, you would usually fill it with the desired information
117/// // into the respective structure. Some of the parts shown here might not be applicable !
118/// // Values shown here are possibly random and not representative !
119/// let mut req = EntityUserLink::default();
120///
121/// // You can configure optional parameters by calling the respective setters at will, and
122/// // execute the final call using `doit()`.
123/// // Values shown here are possibly random and not representative !
124/// let result = hub.management().profile_user_links_update(req, "accountId", "webPropertyId", "profileId", "linkId")
125///              .doit().await;
126///
127/// match result {
128///     Err(e) => match e {
129///         // The Error enum provides details about what exactly happened.
130///         // You can also just use its `Debug`, `Display` or `Error` traits
131///          Error::HttpError(_)
132///         |Error::Io(_)
133///         |Error::MissingAPIKey
134///         |Error::MissingToken(_)
135///         |Error::Cancelled
136///         |Error::UploadSizeLimitExceeded(_, _)
137///         |Error::Failure(_)
138///         |Error::BadRequest(_)
139///         |Error::FieldClash(_)
140///         |Error::JsonDecodeError(_, _) => println!("{}", e),
141///     },
142///     Ok(res) => println!("Success: {:?}", res),
143/// }
144/// # }
145/// ```
146#[derive(Clone)]
147pub struct Analytics<C> {
148    pub client: common::Client<C>,
149    pub auth: Box<dyn common::GetToken>,
150    _user_agent: String,
151    _base_url: String,
152    _root_url: String,
153}
154
155impl<C> common::Hub for Analytics<C> {}
156
157impl<'a, C> Analytics<C> {
158    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Analytics<C> {
159        Analytics {
160            client,
161            auth: Box::new(auth),
162            _user_agent: "google-api-rust-client/7.0.0".to_string(),
163            _base_url: "https://www.googleapis.com/analytics/v3/".to_string(),
164            _root_url: "https://analytics.googleapis.com/".to_string(),
165        }
166    }
167
168    pub fn data(&'a self) -> DataMethods<'a, C> {
169        DataMethods { hub: self }
170    }
171    pub fn management(&'a self) -> ManagementMethods<'a, C> {
172        ManagementMethods { hub: self }
173    }
174    pub fn metadata(&'a self) -> MetadataMethods<'a, C> {
175        MetadataMethods { hub: self }
176    }
177    pub fn provisioning(&'a self) -> ProvisioningMethods<'a, C> {
178        ProvisioningMethods { hub: self }
179    }
180    pub fn user_deletion(&'a self) -> UserDeletionMethods<'a, C> {
181        UserDeletionMethods { hub: self }
182    }
183
184    /// Set the user-agent header field to use in all requests to the server.
185    /// It defaults to `google-api-rust-client/7.0.0`.
186    ///
187    /// Returns the previously set user-agent.
188    pub fn user_agent(&mut self, agent_name: String) -> String {
189        std::mem::replace(&mut self._user_agent, agent_name)
190    }
191
192    /// Set the base url to use in all requests to the server.
193    /// It defaults to `https://www.googleapis.com/analytics/v3/`.
194    ///
195    /// Returns the previously set base url.
196    pub fn base_url(&mut self, new_base_url: String) -> String {
197        std::mem::replace(&mut self._base_url, new_base_url)
198    }
199
200    /// Set the root url to use in all requests to the server.
201    /// It defaults to `https://analytics.googleapis.com/`.
202    ///
203    /// Returns the previously set root url.
204    pub fn root_url(&mut self, new_root_url: String) -> String {
205        std::mem::replace(&mut self._root_url, new_root_url)
206    }
207}
208
209// ############
210// SCHEMAS ###
211// ##########
212/// JSON template for Analytics account entry.
213///
214/// This type is not used in any activity, and only used as *part* of another schema.
215///
216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
217#[serde_with::serde_as]
218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
219pub struct Account {
220    /// Child link for an account entry. Points to the list of web properties for this account.
221    #[serde(rename = "childLink")]
222    pub child_link: Option<AccountChildLink>,
223    /// Time the account was created.
224    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
225    /// Account ID.
226    pub id: Option<String>,
227    /// Resource type for Analytics account.
228    pub kind: Option<String>,
229    /// Account name.
230    pub name: Option<String>,
231    /// Permissions the user has for this account.
232    pub permissions: Option<AccountPermissions>,
233    /// Link for this account.
234    #[serde(rename = "selfLink")]
235    pub self_link: Option<String>,
236    /// Indicates whether this account is starred or not.
237    pub starred: Option<bool>,
238    /// Time the account was last modified.
239    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
240}
241
242impl common::Part for Account {}
243
244/// JSON template for a linked account.
245///
246/// This type is not used in any activity, and only used as *part* of another schema.
247///
248#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
249#[serde_with::serde_as]
250#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
251pub struct AccountRef {
252    /// Link for this account.
253    pub href: Option<String>,
254    /// Account ID.
255    pub id: Option<String>,
256    /// Analytics account reference.
257    pub kind: Option<String>,
258    /// Account name.
259    pub name: Option<String>,
260}
261
262impl common::Part for AccountRef {}
263
264/// An AccountSummary collection lists a summary of accounts, properties and views (profiles) to which the user has access. Each resource in the collection corresponds to a single AccountSummary.
265///
266/// # Activities
267///
268/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
269/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
270///
271/// * [account summaries list management](ManagementAccountSummaryListCall) (response)
272#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
273#[serde_with::serde_as]
274#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
275pub struct AccountSummaries {
276    /// A list of AccountSummaries.
277    pub items: Option<Vec<AccountSummary>>,
278    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
279    #[serde(rename = "itemsPerPage")]
280    pub items_per_page: Option<i32>,
281    /// Collection type.
282    pub kind: Option<String>,
283    /// Link to next page for this AccountSummary collection.
284    #[serde(rename = "nextLink")]
285    pub next_link: Option<String>,
286    /// Link to previous page for this AccountSummary collection.
287    #[serde(rename = "previousLink")]
288    pub previous_link: Option<String>,
289    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
290    #[serde(rename = "startIndex")]
291    pub start_index: Option<i32>,
292    /// The total number of results for the query, regardless of the number of results in the response.
293    #[serde(rename = "totalResults")]
294    pub total_results: Option<i32>,
295    /// Email ID of the authenticated user
296    pub username: Option<String>,
297}
298
299impl common::ResponseResult for AccountSummaries {}
300
301/// JSON template for an Analytics AccountSummary. An AccountSummary is a lightweight tree comprised of properties/profiles.
302///
303/// This type is not used in any activity, and only used as *part* of another schema.
304///
305#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
306#[serde_with::serde_as]
307#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
308pub struct AccountSummary {
309    /// Account ID.
310    pub id: Option<String>,
311    /// Resource type for Analytics AccountSummary.
312    pub kind: Option<String>,
313    /// Account name.
314    pub name: Option<String>,
315    /// Indicates whether this account is starred or not.
316    pub starred: Option<bool>,
317    /// List of web properties under this account.
318    #[serde(rename = "webProperties")]
319    pub web_properties: Option<Vec<WebPropertySummary>>,
320}
321
322impl common::Part for AccountSummary {}
323
324/// JSON template for an Analytics account ticket. The account ticket consists of the ticket ID and the basic information for the account, property and profile.
325///
326/// # Activities
327///
328/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
329/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
330///
331/// * [create account ticket provisioning](ProvisioningCreateAccountTicketCall) (request|response)
332#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
333#[serde_with::serde_as]
334#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
335pub struct AccountTicket {
336    /// Account for this ticket.
337    pub account: Option<Account>,
338    /// Account ticket ID used to access the account ticket.
339    pub id: Option<String>,
340    /// Resource type for account ticket.
341    pub kind: Option<String>,
342    /// View (Profile) for the account.
343    pub profile: Option<Profile>,
344    /// Redirect URI where the user will be sent after accepting Terms of Service. Must be configured in APIs console as a callback URL.
345    #[serde(rename = "redirectUri")]
346    pub redirect_uri: Option<String>,
347    /// Web property for the account.
348    pub webproperty: Option<Webproperty>,
349}
350
351impl common::RequestValue for AccountTicket {}
352impl common::ResponseResult for AccountTicket {}
353
354/// JSON template for an Analytics account tree requests. The account tree request is used in the provisioning api to create an account, property, and view (profile). It contains the basic information required to make these fields.
355///
356/// # Activities
357///
358/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
359/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
360///
361/// * [create account tree provisioning](ProvisioningCreateAccountTreeCall) (request)
362#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
363#[serde_with::serde_as]
364#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
365pub struct AccountTreeRequest {
366    /// no description provided
367    #[serde(rename = "accountName")]
368    pub account_name: Option<String>,
369    /// Resource type for account ticket.
370    pub kind: Option<String>,
371    /// no description provided
372    #[serde(rename = "profileName")]
373    pub profile_name: Option<String>,
374    /// no description provided
375    pub timezone: Option<String>,
376    /// no description provided
377    #[serde(rename = "webpropertyName")]
378    pub webproperty_name: Option<String>,
379    /// no description provided
380    #[serde(rename = "websiteUrl")]
381    pub website_url: Option<String>,
382}
383
384impl common::RequestValue for AccountTreeRequest {}
385
386/// JSON template for an Analytics account tree response. The account tree response is used in the provisioning api to return the result of creating an account, property, and view (profile).
387///
388/// # Activities
389///
390/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
391/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
392///
393/// * [create account tree provisioning](ProvisioningCreateAccountTreeCall) (response)
394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
395#[serde_with::serde_as]
396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
397pub struct AccountTreeResponse {
398    /// The account created.
399    pub account: Option<Account>,
400    /// Resource type for account ticket.
401    pub kind: Option<String>,
402    /// View (Profile) for the account.
403    pub profile: Option<Profile>,
404    /// Web property for the account.
405    pub webproperty: Option<Webproperty>,
406}
407
408impl common::ResponseResult for AccountTreeResponse {}
409
410/// An account collection provides a list of Analytics accounts to which a user has access. The account collection is the entry point to all management information. Each resource in the collection corresponds to a single Analytics account.
411///
412/// # Activities
413///
414/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
415/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
416///
417/// * [accounts list management](ManagementAccountListCall) (response)
418#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
419#[serde_with::serde_as]
420#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
421pub struct Accounts {
422    /// A list of accounts.
423    pub items: Option<Vec<Account>>,
424    /// The maximum number of entries the response can contain, regardless of the actual number of entries returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
425    #[serde(rename = "itemsPerPage")]
426    pub items_per_page: Option<i32>,
427    /// Collection type.
428    pub kind: Option<String>,
429    /// Next link for this account collection.
430    #[serde(rename = "nextLink")]
431    pub next_link: Option<String>,
432    /// Previous link for this account collection.
433    #[serde(rename = "previousLink")]
434    pub previous_link: Option<String>,
435    /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter.
436    #[serde(rename = "startIndex")]
437    pub start_index: Option<i32>,
438    /// The total number of results for the query, regardless of the number of results in the response.
439    #[serde(rename = "totalResults")]
440    pub total_results: Option<i32>,
441    /// Email ID of the authenticated user
442    pub username: Option<String>,
443}
444
445impl common::ResponseResult for Accounts {}
446
447/// JSON template for an Google Ads account.
448///
449/// This type is not used in any activity, and only used as *part* of another schema.
450///
451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
452#[serde_with::serde_as]
453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
454pub struct AdWordsAccount {
455    /// True if auto-tagging is enabled on the Google Ads account. Read-only after the insert operation.
456    #[serde(rename = "autoTaggingEnabled")]
457    pub auto_tagging_enabled: Option<bool>,
458    /// Customer ID. This field is required when creating a Google Ads link.
459    #[serde(rename = "customerId")]
460    pub customer_id: Option<String>,
461    /// Resource type for Google Ads account.
462    pub kind: Option<String>,
463}
464
465impl common::Part for AdWordsAccount {}
466
467/// Request template for the delete upload data request.
468///
469/// # Activities
470///
471/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
472/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
473///
474/// * [uploads delete upload data management](ManagementUploadDeleteUploadDataCall) (request)
475#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
476#[serde_with::serde_as]
477#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
478pub struct AnalyticsDataimportDeleteUploadDataRequest {
479    /// A list of upload UIDs.
480    #[serde(rename = "customDataImportUids")]
481    pub custom_data_import_uids: Option<Vec<String>>,
482}
483
484impl common::RequestValue for AnalyticsDataimportDeleteUploadDataRequest {}
485
486/// JSON template for a metadata column.
487///
488/// This type is not used in any activity, and only used as *part* of another schema.
489///
490#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
491#[serde_with::serde_as]
492#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
493pub struct Column {
494    /// Map of attribute name and value for this column.
495    pub attributes: Option<HashMap<String, String>>,
496    /// Column id.
497    pub id: Option<String>,
498    /// Resource type for Analytics column.
499    pub kind: Option<String>,
500}
501
502impl common::Part for Column {}
503
504/// Lists columns (dimensions and metrics) for a particular report type.
505///
506/// # Activities
507///
508/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
509/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
510///
511/// * [columns list metadata](MetadataColumnListCall) (response)
512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
513#[serde_with::serde_as]
514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
515pub struct Columns {
516    /// List of attributes names returned by columns.
517    #[serde(rename = "attributeNames")]
518    pub attribute_names: Option<Vec<String>>,
519    /// Etag of collection. This etag can be compared with the last response etag to check if response has changed.
520    pub etag: Option<String>,
521    /// List of columns for a report type.
522    pub items: Option<Vec<Column>>,
523    /// Collection type.
524    pub kind: Option<String>,
525    /// Total number of columns returned in the response.
526    #[serde(rename = "totalResults")]
527    pub total_results: Option<i32>,
528}
529
530impl common::ResponseResult for Columns {}
531
532/// JSON template for an Analytics custom data source.
533///
534/// This type is not used in any activity, and only used as *part* of another schema.
535///
536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
537#[serde_with::serde_as]
538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
539pub struct CustomDataSource {
540    /// Account ID to which this custom data source belongs.
541    #[serde(rename = "accountId")]
542    pub account_id: Option<String>,
543    /// no description provided
544    #[serde(rename = "childLink")]
545    pub child_link: Option<CustomDataSourceChildLink>,
546    /// Time this custom data source was created.
547    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
548    /// Description of custom data source.
549    pub description: Option<String>,
550    /// Custom data source ID.
551    pub id: Option<String>,
552    /// no description provided
553    #[serde(rename = "importBehavior")]
554    pub import_behavior: Option<String>,
555    /// Resource type for Analytics custom data source.
556    pub kind: Option<String>,
557    /// Name of this custom data source.
558    pub name: Option<String>,
559    /// Parent link for this custom data source. Points to the web property to which this custom data source belongs.
560    #[serde(rename = "parentLink")]
561    pub parent_link: Option<CustomDataSourceParentLink>,
562    /// IDs of views (profiles) linked to the custom data source.
563    #[serde(rename = "profilesLinked")]
564    pub profiles_linked: Option<Vec<String>>,
565    /// Collection of schema headers of the custom data source.
566    pub schema: Option<Vec<String>>,
567    /// Link for this Analytics custom data source.
568    #[serde(rename = "selfLink")]
569    pub self_link: Option<String>,
570    /// Type of the custom data source.
571    #[serde(rename = "type")]
572    pub type_: Option<String>,
573    /// Time this custom data source was last modified.
574    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
575    /// Upload type of the custom data source.
576    #[serde(rename = "uploadType")]
577    pub upload_type: Option<String>,
578    /// Web property ID of the form UA-XXXXX-YY to which this custom data source belongs.
579    #[serde(rename = "webPropertyId")]
580    pub web_property_id: Option<String>,
581}
582
583impl common::Part for CustomDataSource {}
584
585/// Lists Analytics custom data sources to which the user has access. Each resource in the collection corresponds to a single Analytics custom data source.
586///
587/// # Activities
588///
589/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
590/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
591///
592/// * [custom data sources list management](ManagementCustomDataSourceListCall) (response)
593#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
594#[serde_with::serde_as]
595#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
596pub struct CustomDataSources {
597    /// Collection of custom data sources.
598    pub items: Option<Vec<CustomDataSource>>,
599    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
600    #[serde(rename = "itemsPerPage")]
601    pub items_per_page: Option<i32>,
602    /// Collection type.
603    pub kind: Option<String>,
604    /// Link to next page for this custom data source collection.
605    #[serde(rename = "nextLink")]
606    pub next_link: Option<String>,
607    /// Link to previous page for this custom data source collection.
608    #[serde(rename = "previousLink")]
609    pub previous_link: Option<String>,
610    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
611    #[serde(rename = "startIndex")]
612    pub start_index: Option<i32>,
613    /// The total number of results for the query, regardless of the number of results in the response.
614    #[serde(rename = "totalResults")]
615    pub total_results: Option<i32>,
616    /// Email ID of the authenticated user
617    pub username: Option<String>,
618}
619
620impl common::ResponseResult for CustomDataSources {}
621
622/// JSON template for Analytics Custom Dimension.
623///
624/// # Activities
625///
626/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
627/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
628///
629/// * [custom dimensions get management](ManagementCustomDimensionGetCall) (response)
630/// * [custom dimensions insert management](ManagementCustomDimensionInsertCall) (request|response)
631/// * [custom dimensions patch management](ManagementCustomDimensionPatchCall) (request|response)
632/// * [custom dimensions update management](ManagementCustomDimensionUpdateCall) (request|response)
633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
634#[serde_with::serde_as]
635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
636pub struct CustomDimension {
637    /// Account ID.
638    #[serde(rename = "accountId")]
639    pub account_id: Option<String>,
640    /// Boolean indicating whether the custom dimension is active.
641    pub active: Option<bool>,
642    /// Time the custom dimension was created.
643    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
644    /// Custom dimension ID.
645    pub id: Option<String>,
646    /// Index of the custom dimension.
647    pub index: Option<i32>,
648    /// Kind value for a custom dimension. Set to "analytics#customDimension". It is a read-only field.
649    pub kind: Option<String>,
650    /// Name of the custom dimension.
651    pub name: Option<String>,
652    /// Parent link for the custom dimension. Points to the property to which the custom dimension belongs.
653    #[serde(rename = "parentLink")]
654    pub parent_link: Option<CustomDimensionParentLink>,
655    /// Scope of the custom dimension: HIT, SESSION, USER or PRODUCT.
656    pub scope: Option<String>,
657    /// Link for the custom dimension
658    #[serde(rename = "selfLink")]
659    pub self_link: Option<String>,
660    /// Time the custom dimension was last modified.
661    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
662    /// Property ID.
663    #[serde(rename = "webPropertyId")]
664    pub web_property_id: Option<String>,
665}
666
667impl common::RequestValue for CustomDimension {}
668impl common::ResponseResult for CustomDimension {}
669
670/// A custom dimension collection lists Analytics custom dimensions to which the user has access. Each resource in the collection corresponds to a single Analytics custom dimension.
671///
672/// # Activities
673///
674/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
675/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
676///
677/// * [custom dimensions list management](ManagementCustomDimensionListCall) (response)
678#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
679#[serde_with::serde_as]
680#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
681pub struct CustomDimensions {
682    /// Collection of custom dimensions.
683    pub items: Option<Vec<CustomDimension>>,
684    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
685    #[serde(rename = "itemsPerPage")]
686    pub items_per_page: Option<i32>,
687    /// Collection type.
688    pub kind: Option<String>,
689    /// Link to next page for this custom dimension collection.
690    #[serde(rename = "nextLink")]
691    pub next_link: Option<String>,
692    /// Link to previous page for this custom dimension collection.
693    #[serde(rename = "previousLink")]
694    pub previous_link: Option<String>,
695    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
696    #[serde(rename = "startIndex")]
697    pub start_index: Option<i32>,
698    /// The total number of results for the query, regardless of the number of results in the response.
699    #[serde(rename = "totalResults")]
700    pub total_results: Option<i32>,
701    /// Email ID of the authenticated user
702    pub username: Option<String>,
703}
704
705impl common::ResponseResult for CustomDimensions {}
706
707/// JSON template for Analytics Custom Metric.
708///
709/// # Activities
710///
711/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
712/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
713///
714/// * [custom metrics get management](ManagementCustomMetricGetCall) (response)
715/// * [custom metrics insert management](ManagementCustomMetricInsertCall) (request|response)
716/// * [custom metrics patch management](ManagementCustomMetricPatchCall) (request|response)
717/// * [custom metrics update management](ManagementCustomMetricUpdateCall) (request|response)
718#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
719#[serde_with::serde_as]
720#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
721pub struct CustomMetric {
722    /// Account ID.
723    #[serde(rename = "accountId")]
724    pub account_id: Option<String>,
725    /// Boolean indicating whether the custom metric is active.
726    pub active: Option<bool>,
727    /// Time the custom metric was created.
728    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
729    /// Custom metric ID.
730    pub id: Option<String>,
731    /// Index of the custom metric.
732    pub index: Option<i32>,
733    /// Kind value for a custom metric. Set to "analytics#customMetric". It is a read-only field.
734    pub kind: Option<String>,
735    /// Max value of custom metric.
736    pub max_value: Option<String>,
737    /// Min value of custom metric.
738    pub min_value: Option<String>,
739    /// Name of the custom metric.
740    pub name: Option<String>,
741    /// Parent link for the custom metric. Points to the property to which the custom metric belongs.
742    #[serde(rename = "parentLink")]
743    pub parent_link: Option<CustomMetricParentLink>,
744    /// Scope of the custom metric: HIT or PRODUCT.
745    pub scope: Option<String>,
746    /// Link for the custom metric
747    #[serde(rename = "selfLink")]
748    pub self_link: Option<String>,
749    /// Data type of custom metric.
750    #[serde(rename = "type")]
751    pub type_: Option<String>,
752    /// Time the custom metric was last modified.
753    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
754    /// Property ID.
755    #[serde(rename = "webPropertyId")]
756    pub web_property_id: Option<String>,
757}
758
759impl common::RequestValue for CustomMetric {}
760impl common::ResponseResult for CustomMetric {}
761
762/// A custom metric collection lists Analytics custom metrics to which the user has access. Each resource in the collection corresponds to a single Analytics custom metric.
763///
764/// # Activities
765///
766/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
767/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
768///
769/// * [custom metrics list management](ManagementCustomMetricListCall) (response)
770#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
771#[serde_with::serde_as]
772#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
773pub struct CustomMetrics {
774    /// Collection of custom metrics.
775    pub items: Option<Vec<CustomMetric>>,
776    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
777    #[serde(rename = "itemsPerPage")]
778    pub items_per_page: Option<i32>,
779    /// Collection type.
780    pub kind: Option<String>,
781    /// Link to next page for this custom metric collection.
782    #[serde(rename = "nextLink")]
783    pub next_link: Option<String>,
784    /// Link to previous page for this custom metric collection.
785    #[serde(rename = "previousLink")]
786    pub previous_link: Option<String>,
787    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
788    #[serde(rename = "startIndex")]
789    pub start_index: Option<i32>,
790    /// The total number of results for the query, regardless of the number of results in the response.
791    #[serde(rename = "totalResults")]
792    pub total_results: Option<i32>,
793    /// Email ID of the authenticated user
794    pub username: Option<String>,
795}
796
797impl common::ResponseResult for CustomMetrics {}
798
799/// JSON template for Analytics Entity Google Ads Link.
800///
801/// # Activities
802///
803/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
804/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
805///
806/// * [web property ad words links get management](ManagementWebPropertyAdWordsLinkGetCall) (response)
807/// * [web property ad words links insert management](ManagementWebPropertyAdWordsLinkInsertCall) (request|response)
808/// * [web property ad words links patch management](ManagementWebPropertyAdWordsLinkPatchCall) (request|response)
809/// * [web property ad words links update management](ManagementWebPropertyAdWordsLinkUpdateCall) (request|response)
810#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
811#[serde_with::serde_as]
812#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
813pub struct EntityAdWordsLink {
814    /// A list of Google Ads client accounts. These cannot be MCC accounts. This field is required when creating a Google Ads link. It cannot be empty.
815    #[serde(rename = "adWordsAccounts")]
816    pub ad_words_accounts: Option<Vec<AdWordsAccount>>,
817    /// Web property being linked.
818    pub entity: Option<EntityAdWordsLinkEntity>,
819    /// Entity Google Ads link ID
820    pub id: Option<String>,
821    /// Resource type for entity Google Ads link.
822    pub kind: Option<String>,
823    /// Name of the link. This field is required when creating a Google Ads link.
824    pub name: Option<String>,
825    /// IDs of linked Views (Profiles) represented as strings.
826    #[serde(rename = "profileIds")]
827    pub profile_ids: Option<Vec<String>>,
828    /// URL link for this Google Analytics - Google Ads link.
829    #[serde(rename = "selfLink")]
830    pub self_link: Option<String>,
831}
832
833impl common::RequestValue for EntityAdWordsLink {}
834impl common::ResponseResult for EntityAdWordsLink {}
835
836/// An entity Google Ads link collection provides a list of GA-Google Ads links Each resource in this collection corresponds to a single link.
837///
838/// # Activities
839///
840/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
841/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
842///
843/// * [web property ad words links list management](ManagementWebPropertyAdWordsLinkListCall) (response)
844#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
845#[serde_with::serde_as]
846#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
847pub struct EntityAdWordsLinks {
848    /// A list of entity Google Ads links.
849    pub items: Option<Vec<EntityAdWordsLink>>,
850    /// The maximum number of entries the response can contain, regardless of the actual number of entries returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
851    #[serde(rename = "itemsPerPage")]
852    pub items_per_page: Option<i32>,
853    /// Collection type.
854    pub kind: Option<String>,
855    /// Next link for this Google Ads link collection.
856    #[serde(rename = "nextLink")]
857    pub next_link: Option<String>,
858    /// Previous link for this Google Ads link collection.
859    #[serde(rename = "previousLink")]
860    pub previous_link: Option<String>,
861    /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter.
862    #[serde(rename = "startIndex")]
863    pub start_index: Option<i32>,
864    /// The total number of results for the query, regardless of the number of results in the response.
865    #[serde(rename = "totalResults")]
866    pub total_results: Option<i32>,
867}
868
869impl common::ResponseResult for EntityAdWordsLinks {}
870
871/// JSON template for an Analytics Entity-User Link. Returns permissions that a user has for an entity.
872///
873/// # Activities
874///
875/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
876/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
877///
878/// * [account user links insert management](ManagementAccountUserLinkInsertCall) (request|response)
879/// * [account user links update management](ManagementAccountUserLinkUpdateCall) (request|response)
880/// * [profile user links insert management](ManagementProfileUserLinkInsertCall) (request|response)
881/// * [profile user links update management](ManagementProfileUserLinkUpdateCall) (request|response)
882/// * [webproperty user links insert management](ManagementWebpropertyUserLinkInsertCall) (request|response)
883/// * [webproperty user links update management](ManagementWebpropertyUserLinkUpdateCall) (request|response)
884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
885#[serde_with::serde_as]
886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
887pub struct EntityUserLink {
888    /// Entity for this link. It can be an account, a web property, or a view (profile).
889    pub entity: Option<EntityUserLinkEntity>,
890    /// Entity user link ID
891    pub id: Option<String>,
892    /// Resource type for entity user link.
893    pub kind: Option<String>,
894    /// Permissions the user has for this entity.
895    pub permissions: Option<EntityUserLinkPermissions>,
896    /// Self link for this resource.
897    #[serde(rename = "selfLink")]
898    pub self_link: Option<String>,
899    /// User reference.
900    #[serde(rename = "userRef")]
901    pub user_ref: Option<UserRef>,
902}
903
904impl common::RequestValue for EntityUserLink {}
905impl common::ResponseResult for EntityUserLink {}
906
907/// An entity user link collection provides a list of Analytics ACL links Each resource in this collection corresponds to a single link.
908///
909/// # Activities
910///
911/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
912/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
913///
914/// * [account user links list management](ManagementAccountUserLinkListCall) (response)
915/// * [profile user links list management](ManagementProfileUserLinkListCall) (response)
916/// * [webproperty user links list management](ManagementWebpropertyUserLinkListCall) (response)
917#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
918#[serde_with::serde_as]
919#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
920pub struct EntityUserLinks {
921    /// A list of entity user links.
922    pub items: Option<Vec<EntityUserLink>>,
923    /// The maximum number of entries the response can contain, regardless of the actual number of entries returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
924    #[serde(rename = "itemsPerPage")]
925    pub items_per_page: Option<i32>,
926    /// Collection type.
927    pub kind: Option<String>,
928    /// Next link for this account collection.
929    #[serde(rename = "nextLink")]
930    pub next_link: Option<String>,
931    /// Previous link for this account collection.
932    #[serde(rename = "previousLink")]
933    pub previous_link: Option<String>,
934    /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter.
935    #[serde(rename = "startIndex")]
936    pub start_index: Option<i32>,
937    /// The total number of results for the query, regardless of the number of results in the response.
938    #[serde(rename = "totalResults")]
939    pub total_results: Option<i32>,
940}
941
942impl common::ResponseResult for EntityUserLinks {}
943
944/// JSON template for Analytics experiment resource.
945///
946/// # Activities
947///
948/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
949/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
950///
951/// * [experiments get management](ManagementExperimentGetCall) (response)
952/// * [experiments insert management](ManagementExperimentInsertCall) (request|response)
953/// * [experiments patch management](ManagementExperimentPatchCall) (request|response)
954/// * [experiments update management](ManagementExperimentUpdateCall) (request|response)
955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
956#[serde_with::serde_as]
957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
958pub struct Experiment {
959    /// Account ID to which this experiment belongs. This field is read-only.
960    #[serde(rename = "accountId")]
961    pub account_id: Option<String>,
962    /// Time the experiment was created. This field is read-only.
963    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
964    /// Notes about this experiment.
965    pub description: Option<String>,
966    /// If true, the end user will be able to edit the experiment via the Google Analytics user interface.
967    #[serde(rename = "editableInGaUi")]
968    pub editable_in_ga_ui: Option<bool>,
969    /// The ending time of the experiment (the time the status changed from RUNNING to ENDED). This field is present only if the experiment has ended. This field is read-only.
970    #[serde(rename = "endTime")]
971    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
972    /// Boolean specifying whether to distribute traffic evenly across all variations. If the value is False, content experiments follows the default behavior of adjusting traffic dynamically based on variation performance. Optional -- defaults to False. This field may not be changed for an experiment whose status is ENDED.
973    #[serde(rename = "equalWeighting")]
974    pub equal_weighting: Option<bool>,
975    /// Experiment ID. Required for patch and update. Disallowed for create.
976    pub id: Option<String>,
977    /// Internal ID for the web property to which this experiment belongs. This field is read-only.
978    #[serde(rename = "internalWebPropertyId")]
979    pub internal_web_property_id: Option<String>,
980    /// Resource type for an Analytics experiment. This field is read-only.
981    pub kind: Option<String>,
982    /// An integer number in [3, 90]. Specifies the minimum length of the experiment. Can be changed for a running experiment. This field may not be changed for an experiments whose status is ENDED.
983    #[serde(rename = "minimumExperimentLengthInDays")]
984    pub minimum_experiment_length_in_days: Option<i32>,
985    /// Experiment name. This field may not be changed for an experiment whose status is ENDED. This field is required when creating an experiment.
986    pub name: Option<String>,
987    /// The metric that the experiment is optimizing. Valid values: "ga:goal(n)Completions", "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces", "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue". This field is required if status is "RUNNING" and servingFramework is one of "REDIRECT" or "API".
988    #[serde(rename = "objectiveMetric")]
989    pub objective_metric: Option<String>,
990    /// Whether the objectiveMetric should be minimized or maximized. Possible values: "MAXIMUM", "MINIMUM". Optional--defaults to "MAXIMUM". Cannot be specified without objectiveMetric. Cannot be modified when status is "RUNNING" or "ENDED".
991    #[serde(rename = "optimizationType")]
992    pub optimization_type: Option<String>,
993    /// Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
994    #[serde(rename = "parentLink")]
995    pub parent_link: Option<ExperimentParentLink>,
996    /// View (Profile) ID to which this experiment belongs. This field is read-only.
997    #[serde(rename = "profileId")]
998    pub profile_id: Option<String>,
999    /// Why the experiment ended. Possible values: "STOPPED_BY_USER", "WINNER_FOUND", "EXPERIMENT_EXPIRED", "ENDED_WITH_NO_WINNER", "GOAL_OBJECTIVE_CHANGED". "ENDED_WITH_NO_WINNER" means that the experiment didn't expire but no winner was projected to be found. If the experiment status is changed via the API to ENDED this field is set to STOPPED_BY_USER. This field is read-only.
1000    #[serde(rename = "reasonExperimentEnded")]
1001    pub reason_experiment_ended: Option<String>,
1002    /// Boolean specifying whether variations URLS are rewritten to match those of the original. This field may not be changed for an experiments whose status is ENDED.
1003    #[serde(rename = "rewriteVariationUrlsAsOriginal")]
1004    pub rewrite_variation_urls_as_original: Option<bool>,
1005    /// Link for this experiment. This field is read-only.
1006    #[serde(rename = "selfLink")]
1007    pub self_link: Option<String>,
1008    /// The framework used to serve the experiment variations and evaluate the results. One of:  
1009    /// - REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen variation and evaluates the results.
1010    /// - API: Google Analytics chooses and reports the variation to serve and evaluates the results; the caller is responsible for serving the selected variation.
1011    /// - EXTERNAL: The variations will be served externally and the chosen variation reported to Google Analytics. The caller is responsible for serving the selected variation and evaluating the results.
1012    #[serde(rename = "servingFramework")]
1013    pub serving_framework: Option<String>,
1014    /// The snippet of code to include on the control page(s). This field is read-only.
1015    pub snippet: Option<String>,
1016    /// The starting time of the experiment (the time the status changed from READY_TO_RUN to RUNNING). This field is present only if the experiment has started. This field is read-only.
1017    #[serde(rename = "startTime")]
1018    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1019    /// Experiment status. Possible values: "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED". Experiments can be created in the "DRAFT", "READY_TO_RUN" or "RUNNING" state. This field is required when creating an experiment.
1020    pub status: Option<String>,
1021    /// A floating-point number in (0, 1]. Specifies the fraction of the traffic that participates in the experiment. Can be changed for a running experiment. This field may not be changed for an experiments whose status is ENDED.
1022    #[serde(rename = "trafficCoverage")]
1023    pub traffic_coverage: Option<f64>,
1024    /// Time the experiment was last modified. This field is read-only.
1025    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1026    /// Array of variations. The first variation in the array is the original. The number of variations may not change once an experiment is in the RUNNING state. At least two variations are required before status can be set to RUNNING.
1027    pub variations: Option<Vec<ExperimentVariations>>,
1028    /// Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-YY. This field is read-only.
1029    #[serde(rename = "webPropertyId")]
1030    pub web_property_id: Option<String>,
1031    /// A floating-point number in (0, 1). Specifies the necessary confidence level to choose a winner. This field may not be changed for an experiments whose status is ENDED.
1032    #[serde(rename = "winnerConfidenceLevel")]
1033    pub winner_confidence_level: Option<f64>,
1034    /// Boolean specifying whether a winner has been found for this experiment. This field is read-only.
1035    #[serde(rename = "winnerFound")]
1036    pub winner_found: Option<bool>,
1037}
1038
1039impl common::RequestValue for Experiment {}
1040impl common::ResponseResult for Experiment {}
1041
1042/// An experiment collection lists Analytics experiments to which the user has access. Each view (profile) can have a set of experiments. Each resource in the Experiment collection corresponds to a single Analytics experiment.
1043///
1044/// # Activities
1045///
1046/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1047/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1048///
1049/// * [experiments list management](ManagementExperimentListCall) (response)
1050#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1051#[serde_with::serde_as]
1052#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1053pub struct Experiments {
1054    /// A list of experiments.
1055    pub items: Option<Vec<Experiment>>,
1056    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
1057    #[serde(rename = "itemsPerPage")]
1058    pub items_per_page: Option<i32>,
1059    /// Collection type.
1060    pub kind: Option<String>,
1061    /// Link to next page for this experiment collection.
1062    #[serde(rename = "nextLink")]
1063    pub next_link: Option<String>,
1064    /// Link to previous page for this experiment collection.
1065    #[serde(rename = "previousLink")]
1066    pub previous_link: Option<String>,
1067    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1068    #[serde(rename = "startIndex")]
1069    pub start_index: Option<i32>,
1070    /// The total number of results for the query, regardless of the number of resources in the result.
1071    #[serde(rename = "totalResults")]
1072    pub total_results: Option<i32>,
1073    /// Email ID of the authenticated user
1074    pub username: Option<String>,
1075}
1076
1077impl common::ResponseResult for Experiments {}
1078
1079/// JSON template for an Analytics account filter.
1080///
1081/// # Activities
1082///
1083/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1084/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1085///
1086/// * [filters delete management](ManagementFilterDeleteCall) (response)
1087/// * [filters get management](ManagementFilterGetCall) (response)
1088/// * [filters insert management](ManagementFilterInsertCall) (request|response)
1089/// * [filters patch management](ManagementFilterPatchCall) (request|response)
1090/// * [filters update management](ManagementFilterUpdateCall) (request|response)
1091#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1092#[serde_with::serde_as]
1093#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1094pub struct Filter {
1095    /// Account ID to which this filter belongs.
1096    #[serde(rename = "accountId")]
1097    pub account_id: Option<String>,
1098    /// Details for the filter of the type ADVANCED.
1099    #[serde(rename = "advancedDetails")]
1100    pub advanced_details: Option<FilterAdvancedDetails>,
1101    /// Time this filter was created.
1102    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
1103    /// Details for the filter of the type EXCLUDE.
1104    #[serde(rename = "excludeDetails")]
1105    pub exclude_details: Option<FilterExpression>,
1106    /// Filter ID.
1107    pub id: Option<String>,
1108    /// Details for the filter of the type INCLUDE.
1109    #[serde(rename = "includeDetails")]
1110    pub include_details: Option<FilterExpression>,
1111    /// Resource type for Analytics filter.
1112    pub kind: Option<String>,
1113    /// Details for the filter of the type LOWER.
1114    #[serde(rename = "lowercaseDetails")]
1115    pub lowercase_details: Option<FilterLowercaseDetails>,
1116    /// Name of this filter.
1117    pub name: Option<String>,
1118    /// Parent link for this filter. Points to the account to which this filter belongs.
1119    #[serde(rename = "parentLink")]
1120    pub parent_link: Option<FilterParentLink>,
1121    /// Details for the filter of the type SEARCH_AND_REPLACE.
1122    #[serde(rename = "searchAndReplaceDetails")]
1123    pub search_and_replace_details: Option<FilterSearchAndReplaceDetails>,
1124    /// Link for this filter.
1125    #[serde(rename = "selfLink")]
1126    pub self_link: Option<String>,
1127    /// Type of this filter. Possible values are INCLUDE, EXCLUDE, LOWERCASE, UPPERCASE, SEARCH_AND_REPLACE and ADVANCED.
1128    #[serde(rename = "type")]
1129    pub type_: Option<String>,
1130    /// Time this filter was last modified.
1131    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1132    /// Details for the filter of the type UPPER.
1133    #[serde(rename = "uppercaseDetails")]
1134    pub uppercase_details: Option<FilterUppercaseDetails>,
1135}
1136
1137impl common::RequestValue for Filter {}
1138impl common::ResponseResult for Filter {}
1139
1140/// JSON template for an Analytics filter expression.
1141///
1142/// This type is not used in any activity, and only used as *part* of another schema.
1143///
1144#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1145#[serde_with::serde_as]
1146#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1147pub struct FilterExpression {
1148    /// Determines if the filter is case sensitive.
1149    #[serde(rename = "caseSensitive")]
1150    pub case_sensitive: Option<bool>,
1151    /// Filter expression value
1152    #[serde(rename = "expressionValue")]
1153    pub expression_value: Option<String>,
1154    /// Field to filter. Possible values:  
1155    /// - Content and Traffic  
1156    /// - PAGE_REQUEST_URI,
1157    /// - PAGE_HOSTNAME,
1158    /// - PAGE_TITLE,
1159    /// - REFERRAL,
1160    /// - COST_DATA_URI (Campaign target URL),
1161    /// - HIT_TYPE,
1162    /// - INTERNAL_SEARCH_TERM,
1163    /// - INTERNAL_SEARCH_TYPE,
1164    /// - SOURCE_PROPERTY_TRACKING_ID,   
1165    /// - Campaign or AdGroup  
1166    /// - CAMPAIGN_SOURCE,
1167    /// - CAMPAIGN_MEDIUM,
1168    /// - CAMPAIGN_NAME,
1169    /// - CAMPAIGN_AD_GROUP,
1170    /// - CAMPAIGN_TERM,
1171    /// - CAMPAIGN_CONTENT,
1172    /// - CAMPAIGN_CODE,
1173    /// - CAMPAIGN_REFERRAL_PATH,   
1174    /// - E-Commerce  
1175    /// - TRANSACTION_COUNTRY,
1176    /// - TRANSACTION_REGION,
1177    /// - TRANSACTION_CITY,
1178    /// - TRANSACTION_AFFILIATION (Store or order location),
1179    /// - ITEM_NAME,
1180    /// - ITEM_CODE,
1181    /// - ITEM_VARIATION,
1182    /// - TRANSACTION_ID,
1183    /// - TRANSACTION_CURRENCY_CODE,
1184    /// - PRODUCT_ACTION_TYPE,   
1185    /// - Audience/Users  
1186    /// - BROWSER,
1187    /// - BROWSER_VERSION,
1188    /// - BROWSER_SIZE,
1189    /// - PLATFORM,
1190    /// - PLATFORM_VERSION,
1191    /// - LANGUAGE,
1192    /// - SCREEN_RESOLUTION,
1193    /// - SCREEN_COLORS,
1194    /// - JAVA_ENABLED (Boolean Field),
1195    /// - FLASH_VERSION,
1196    /// - GEO_SPEED (Connection speed),
1197    /// - VISITOR_TYPE,
1198    /// - GEO_ORGANIZATION (ISP organization),
1199    /// - GEO_DOMAIN,
1200    /// - GEO_IP_ADDRESS,
1201    /// - GEO_IP_VERSION,   
1202    /// - Location  
1203    /// - GEO_COUNTRY,
1204    /// - GEO_REGION,
1205    /// - GEO_CITY,   
1206    /// - Event  
1207    /// - EVENT_CATEGORY,
1208    /// - EVENT_ACTION,
1209    /// - EVENT_LABEL,   
1210    /// - Other  
1211    /// - CUSTOM_FIELD_1,
1212    /// - CUSTOM_FIELD_2,
1213    /// - USER_DEFINED_VALUE,   
1214    /// - Application  
1215    /// - APP_ID,
1216    /// - APP_INSTALLER_ID,
1217    /// - APP_NAME,
1218    /// - APP_VERSION,
1219    /// - SCREEN,
1220    /// - IS_APP (Boolean Field),
1221    /// - IS_FATAL_EXCEPTION (Boolean Field),
1222    /// - EXCEPTION_DESCRIPTION,   
1223    /// - Mobile device  
1224    /// - IS_MOBILE (Boolean Field, Deprecated. Use DEVICE_CATEGORY=mobile),
1225    /// - IS_TABLET (Boolean Field, Deprecated. Use DEVICE_CATEGORY=tablet),
1226    /// - DEVICE_CATEGORY,
1227    /// - MOBILE_HAS_QWERTY_KEYBOARD (Boolean Field),
1228    /// - MOBILE_HAS_NFC_SUPPORT (Boolean Field),
1229    /// - MOBILE_HAS_CELLULAR_RADIO (Boolean Field),
1230    /// - MOBILE_HAS_WIFI_SUPPORT (Boolean Field),
1231    /// - MOBILE_BRAND_NAME,
1232    /// - MOBILE_MODEL_NAME,
1233    /// - MOBILE_MARKETING_NAME,
1234    /// - MOBILE_POINTING_METHOD,   
1235    /// - Social  
1236    /// - SOCIAL_NETWORK,
1237    /// - SOCIAL_ACTION,
1238    /// - SOCIAL_ACTION_TARGET,   
1239    /// - Custom dimension  
1240    /// - CUSTOM_DIMENSION (See accompanying field index),
1241    pub field: Option<String>,
1242    /// The Index of the custom dimension. Set only if the field is a is CUSTOM_DIMENSION.
1243    #[serde(rename = "fieldIndex")]
1244    pub field_index: Option<i32>,
1245    /// Kind value for filter expression
1246    pub kind: Option<String>,
1247    /// Match type for this filter. Possible values are BEGINS_WITH, EQUAL, ENDS_WITH, CONTAINS, or MATCHES. GEO_DOMAIN, GEO_IP_ADDRESS, PAGE_REQUEST_URI, or PAGE_HOSTNAME filters can use any match type; all other filters must use MATCHES.
1248    #[serde(rename = "matchType")]
1249    pub match_type: Option<String>,
1250}
1251
1252impl common::Part for FilterExpression {}
1253
1254/// JSON template for a profile filter link.
1255///
1256/// This type is not used in any activity, and only used as *part* of another schema.
1257///
1258#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1259#[serde_with::serde_as]
1260#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1261pub struct FilterRef {
1262    /// Account ID to which this filter belongs.
1263    #[serde(rename = "accountId")]
1264    pub account_id: Option<String>,
1265    /// Link for this filter.
1266    pub href: Option<String>,
1267    /// Filter ID.
1268    pub id: Option<String>,
1269    /// Kind value for filter reference.
1270    pub kind: Option<String>,
1271    /// Name of this filter.
1272    pub name: Option<String>,
1273}
1274
1275impl common::Part for FilterRef {}
1276
1277/// A filter collection lists filters created by users in an Analytics account. Each resource in the collection corresponds to a filter.
1278///
1279/// # Activities
1280///
1281/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1282/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1283///
1284/// * [filters list management](ManagementFilterListCall) (response)
1285#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1286#[serde_with::serde_as]
1287#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1288pub struct Filters {
1289    /// A list of filters.
1290    pub items: Option<Vec<Filter>>,
1291    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
1292    #[serde(rename = "itemsPerPage")]
1293    pub items_per_page: Option<i32>,
1294    /// Collection type.
1295    pub kind: Option<String>,
1296    /// Link to next page for this filter collection.
1297    #[serde(rename = "nextLink")]
1298    pub next_link: Option<String>,
1299    /// Link to previous page for this filter collection.
1300    #[serde(rename = "previousLink")]
1301    pub previous_link: Option<String>,
1302    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1303    #[serde(rename = "startIndex")]
1304    pub start_index: Option<i32>,
1305    /// The total number of results for the query, regardless of the number of results in the response.
1306    #[serde(rename = "totalResults")]
1307    pub total_results: Option<i32>,
1308    /// Email ID of the authenticated user
1309    pub username: Option<String>,
1310}
1311
1312impl common::ResponseResult for Filters {}
1313
1314/// Analytics data for a given view (profile).
1315///
1316/// # Activities
1317///
1318/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1319/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1320///
1321/// * [ga get data](DataGaGetCall) (response)
1322#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1323#[serde_with::serde_as]
1324#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1325pub struct GaData {
1326    /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
1327    #[serde(rename = "columnHeaders")]
1328    pub column_headers: Option<Vec<GaDataColumnHeaders>>,
1329    /// Determines if Analytics data contains samples.
1330    #[serde(rename = "containsSampledData")]
1331    pub contains_sampled_data: Option<bool>,
1332    /// The last refreshed time in seconds for Analytics data.
1333    #[serde(rename = "dataLastRefreshed")]
1334    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1335    pub data_last_refreshed: Option<i64>,
1336    /// no description provided
1337    #[serde(rename = "dataTable")]
1338    pub data_table: Option<GaDataDataTable>,
1339    /// Unique ID for this data response.
1340    pub id: Option<String>,
1341    /// The maximum number of rows the response can contain, regardless of the actual number of rows returned. Its value ranges from 1 to 10,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
1342    #[serde(rename = "itemsPerPage")]
1343    pub items_per_page: Option<i32>,
1344    /// Resource type.
1345    pub kind: Option<String>,
1346    /// Link to next page for this Analytics data query.
1347    #[serde(rename = "nextLink")]
1348    pub next_link: Option<String>,
1349    /// Link to previous page for this Analytics data query.
1350    #[serde(rename = "previousLink")]
1351    pub previous_link: Option<String>,
1352    /// Information for the view (profile), for which the Analytics data was requested.
1353    #[serde(rename = "profileInfo")]
1354    pub profile_info: Option<GaDataProfileInfo>,
1355    /// Analytics data request query parameters.
1356    pub query: Option<GaDataQuery>,
1357    /// Analytics data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request.
1358    pub rows: Option<Vec<Vec<String>>>,
1359    /// The number of samples used to calculate the result.
1360    #[serde(rename = "sampleSize")]
1361    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1362    pub sample_size: Option<i64>,
1363    /// Total size of the sample space from which the samples were selected.
1364    #[serde(rename = "sampleSpace")]
1365    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1366    pub sample_space: Option<i64>,
1367    /// Link to this page.
1368    #[serde(rename = "selfLink")]
1369    pub self_link: Option<String>,
1370    /// The total number of rows for the query, regardless of the number of rows in the response.
1371    #[serde(rename = "totalResults")]
1372    pub total_results: Option<i32>,
1373    /// Total values for the requested metrics over all the results, not just the results returned in this response. The order of the metric totals is same as the metric order specified in the request.
1374    #[serde(rename = "totalsForAllResults")]
1375    pub totals_for_all_results: Option<HashMap<String, String>>,
1376}
1377
1378impl common::ResponseResult for GaData {}
1379
1380/// JSON template for Analytics goal resource.
1381///
1382/// # Activities
1383///
1384/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1385/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1386///
1387/// * [goals get management](ManagementGoalGetCall) (response)
1388/// * [goals insert management](ManagementGoalInsertCall) (request|response)
1389/// * [goals patch management](ManagementGoalPatchCall) (request|response)
1390/// * [goals update management](ManagementGoalUpdateCall) (request|response)
1391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1392#[serde_with::serde_as]
1393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1394pub struct Goal {
1395    /// Account ID to which this goal belongs.
1396    #[serde(rename = "accountId")]
1397    pub account_id: Option<String>,
1398    /// Determines whether this goal is active.
1399    pub active: Option<bool>,
1400    /// Time this goal was created.
1401    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
1402    /// Details for the goal of the type EVENT.
1403    #[serde(rename = "eventDetails")]
1404    pub event_details: Option<GoalEventDetails>,
1405    /// Goal ID.
1406    pub id: Option<String>,
1407    /// Internal ID for the web property to which this goal belongs.
1408    #[serde(rename = "internalWebPropertyId")]
1409    pub internal_web_property_id: Option<String>,
1410    /// Resource type for an Analytics goal.
1411    pub kind: Option<String>,
1412    /// Goal name.
1413    pub name: Option<String>,
1414    /// Parent link for a goal. Points to the view (profile) to which this goal belongs.
1415    #[serde(rename = "parentLink")]
1416    pub parent_link: Option<GoalParentLink>,
1417    /// View (Profile) ID to which this goal belongs.
1418    #[serde(rename = "profileId")]
1419    pub profile_id: Option<String>,
1420    /// Link for this goal.
1421    #[serde(rename = "selfLink")]
1422    pub self_link: Option<String>,
1423    /// Goal type. Possible values are URL_DESTINATION, VISIT_TIME_ON_SITE, VISIT_NUM_PAGES, AND EVENT.
1424    #[serde(rename = "type")]
1425    pub type_: Option<String>,
1426    /// Time this goal was last modified.
1427    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1428    /// Details for the goal of the type URL_DESTINATION.
1429    #[serde(rename = "urlDestinationDetails")]
1430    pub url_destination_details: Option<GoalUrlDestinationDetails>,
1431    /// Goal value.
1432    pub value: Option<f32>,
1433    /// Details for the goal of the type VISIT_NUM_PAGES.
1434    #[serde(rename = "visitNumPagesDetails")]
1435    pub visit_num_pages_details: Option<GoalVisitNumPagesDetails>,
1436    /// Details for the goal of the type VISIT_TIME_ON_SITE.
1437    #[serde(rename = "visitTimeOnSiteDetails")]
1438    pub visit_time_on_site_details: Option<GoalVisitTimeOnSiteDetails>,
1439    /// Web property ID to which this goal belongs. The web property ID is of the form UA-XXXXX-YY.
1440    #[serde(rename = "webPropertyId")]
1441    pub web_property_id: Option<String>,
1442}
1443
1444impl common::RequestValue for Goal {}
1445impl common::ResponseResult for Goal {}
1446
1447/// A goal collection lists Analytics goals to which the user has access. Each view (profile) can have a set of goals. Each resource in the Goal collection corresponds to a single Analytics goal.
1448///
1449/// # Activities
1450///
1451/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1452/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1453///
1454/// * [goals list management](ManagementGoalListCall) (response)
1455#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1456#[serde_with::serde_as]
1457#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1458pub struct Goals {
1459    /// A list of goals.
1460    pub items: Option<Vec<Goal>>,
1461    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
1462    #[serde(rename = "itemsPerPage")]
1463    pub items_per_page: Option<i32>,
1464    /// Collection type.
1465    pub kind: Option<String>,
1466    /// Link to next page for this goal collection.
1467    #[serde(rename = "nextLink")]
1468    pub next_link: Option<String>,
1469    /// Link to previous page for this goal collection.
1470    #[serde(rename = "previousLink")]
1471    pub previous_link: Option<String>,
1472    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1473    #[serde(rename = "startIndex")]
1474    pub start_index: Option<i32>,
1475    /// The total number of results for the query, regardless of the number of resources in the result.
1476    #[serde(rename = "totalResults")]
1477    pub total_results: Option<i32>,
1478    /// Email ID of the authenticated user
1479    pub username: Option<String>,
1480}
1481
1482impl common::ResponseResult for Goals {}
1483
1484/// JSON template for a hash Client Id request resource.
1485///
1486/// # Activities
1487///
1488/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1489/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1490///
1491/// * [client id hash client id management](ManagementClientIdHashClientIdCall) (request)
1492#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1493#[serde_with::serde_as]
1494#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1495pub struct HashClientIdRequest {
1496    /// no description provided
1497    #[serde(rename = "clientId")]
1498    pub client_id: Option<String>,
1499    /// no description provided
1500    pub kind: Option<String>,
1501    /// no description provided
1502    #[serde(rename = "webPropertyId")]
1503    pub web_property_id: Option<String>,
1504}
1505
1506impl common::RequestValue for HashClientIdRequest {}
1507
1508/// JSON template for a hash Client Id response resource.
1509///
1510/// # Activities
1511///
1512/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1513/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1514///
1515/// * [client id hash client id management](ManagementClientIdHashClientIdCall) (response)
1516#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1517#[serde_with::serde_as]
1518#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1519pub struct HashClientIdResponse {
1520    /// no description provided
1521    #[serde(rename = "clientId")]
1522    pub client_id: Option<String>,
1523    /// no description provided
1524    #[serde(rename = "hashedClientId")]
1525    pub hashed_client_id: Option<String>,
1526    /// no description provided
1527    pub kind: Option<String>,
1528    /// no description provided
1529    #[serde(rename = "webPropertyId")]
1530    pub web_property_id: Option<String>,
1531}
1532
1533impl common::ResponseResult for HashClientIdResponse {}
1534
1535/// JSON template for an Analytics Remarketing Include Conditions.
1536///
1537/// This type is not used in any activity, and only used as *part* of another schema.
1538///
1539#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1540#[serde_with::serde_as]
1541#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1542pub struct IncludeConditions {
1543    /// The look-back window lets you specify a time frame for evaluating the behavior that qualifies users for your audience. For example, if your filters include users from Central Asia, and Transactions Greater than 2, and you set the look-back window to 14 days, then any user from Central Asia whose cumulative transactions exceed 2 during the last 14 days is added to the audience.
1544    #[serde(rename = "daysToLookBack")]
1545    pub days_to_look_back: Option<i32>,
1546    /// Boolean indicating whether this segment is a smart list. https://support.google.com/analytics/answer/4628577
1547    #[serde(rename = "isSmartList")]
1548    pub is_smart_list: Option<bool>,
1549    /// Resource type for include conditions.
1550    pub kind: Option<String>,
1551    /// Number of days (in the range 1 to 540) a user remains in the audience.
1552    #[serde(rename = "membershipDurationDays")]
1553    pub membership_duration_days: Option<i32>,
1554    /// The segment condition that will cause a user to be added to an audience.
1555    pub segment: Option<String>,
1556}
1557
1558impl common::Part for IncludeConditions {}
1559
1560/// JSON template for an Analytics Remarketing Audience Foreign Link.
1561///
1562/// This type is not used in any activity, and only used as *part* of another schema.
1563///
1564#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1565#[serde_with::serde_as]
1566#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1567pub struct LinkedForeignAccount {
1568    /// Account ID to which this linked foreign account belongs.
1569    #[serde(rename = "accountId")]
1570    pub account_id: Option<String>,
1571    /// Boolean indicating whether this is eligible for search.
1572    #[serde(rename = "eligibleForSearch")]
1573    pub eligible_for_search: Option<bool>,
1574    /// Entity ad account link ID.
1575    pub id: Option<String>,
1576    /// Internal ID for the web property to which this linked foreign account belongs.
1577    #[serde(rename = "internalWebPropertyId")]
1578    pub internal_web_property_id: Option<String>,
1579    /// Resource type for linked foreign account.
1580    pub kind: Option<String>,
1581    /// The foreign account ID. For example the an Google Ads `linkedAccountId` has the following format XXX-XXX-XXXX.
1582    #[serde(rename = "linkedAccountId")]
1583    pub linked_account_id: Option<String>,
1584    /// Remarketing audience ID to which this linked foreign account belongs.
1585    #[serde(rename = "remarketingAudienceId")]
1586    pub remarketing_audience_id: Option<String>,
1587    /// The status of this foreign account link.
1588    pub status: Option<String>,
1589    /// The type of the foreign account. For example, `ADWORDS_LINKS`, `DBM_LINKS`, `MCC_LINKS` or `OPTIMIZE`.
1590    #[serde(rename = "type")]
1591    pub type_: Option<String>,
1592    /// Web property ID of the form UA-XXXXX-YY to which this linked foreign account belongs.
1593    #[serde(rename = "webPropertyId")]
1594    pub web_property_id: Option<String>,
1595}
1596
1597impl common::Part for LinkedForeignAccount {}
1598
1599/// Multi-Channel Funnels data for a given view (profile).
1600///
1601/// # Activities
1602///
1603/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1604/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1605///
1606/// * [mcf get data](DataMcfGetCall) (response)
1607#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1608#[serde_with::serde_as]
1609#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1610pub struct McfData {
1611    /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
1612    #[serde(rename = "columnHeaders")]
1613    pub column_headers: Option<Vec<McfDataColumnHeaders>>,
1614    /// Determines if the Analytics data contains sampled data.
1615    #[serde(rename = "containsSampledData")]
1616    pub contains_sampled_data: Option<bool>,
1617    /// Unique ID for this data response.
1618    pub id: Option<String>,
1619    /// The maximum number of rows the response can contain, regardless of the actual number of rows returned. Its value ranges from 1 to 10,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
1620    #[serde(rename = "itemsPerPage")]
1621    pub items_per_page: Option<i32>,
1622    /// Resource type.
1623    pub kind: Option<String>,
1624    /// Link to next page for this Analytics data query.
1625    #[serde(rename = "nextLink")]
1626    pub next_link: Option<String>,
1627    /// Link to previous page for this Analytics data query.
1628    #[serde(rename = "previousLink")]
1629    pub previous_link: Option<String>,
1630    /// Information for the view (profile), for which the Analytics data was requested.
1631    #[serde(rename = "profileInfo")]
1632    pub profile_info: Option<McfDataProfileInfo>,
1633    /// Analytics data request query parameters.
1634    pub query: Option<McfDataQuery>,
1635    /// Analytics data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request.
1636    pub rows: Option<Vec<Vec<McfDataRows>>>,
1637    /// The number of samples used to calculate the result.
1638    #[serde(rename = "sampleSize")]
1639    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1640    pub sample_size: Option<i64>,
1641    /// Total size of the sample space from which the samples were selected.
1642    #[serde(rename = "sampleSpace")]
1643    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1644    pub sample_space: Option<i64>,
1645    /// Link to this page.
1646    #[serde(rename = "selfLink")]
1647    pub self_link: Option<String>,
1648    /// The total number of rows for the query, regardless of the number of rows in the response.
1649    #[serde(rename = "totalResults")]
1650    pub total_results: Option<i32>,
1651    /// Total values for the requested metrics over all the results, not just the results returned in this response. The order of the metric totals is same as the metric order specified in the request.
1652    #[serde(rename = "totalsForAllResults")]
1653    pub totals_for_all_results: Option<HashMap<String, String>>,
1654}
1655
1656impl common::ResponseResult for McfData {}
1657
1658/// JSON template for an Analytics view (profile).
1659///
1660/// # Activities
1661///
1662/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1663/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1664///
1665/// * [profiles get management](ManagementProfileGetCall) (response)
1666/// * [profiles insert management](ManagementProfileInsertCall) (request|response)
1667/// * [profiles patch management](ManagementProfilePatchCall) (request|response)
1668/// * [profiles update management](ManagementProfileUpdateCall) (request|response)
1669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1670#[serde_with::serde_as]
1671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1672pub struct Profile {
1673    /// Account ID to which this view (profile) belongs.
1674    #[serde(rename = "accountId")]
1675    pub account_id: Option<String>,
1676    /// Indicates whether bot filtering is enabled for this view (profile).
1677    #[serde(rename = "botFilteringEnabled")]
1678    pub bot_filtering_enabled: Option<bool>,
1679    /// Child link for this view (profile). Points to the list of goals for this view (profile).
1680    #[serde(rename = "childLink")]
1681    pub child_link: Option<ProfileChildLink>,
1682    /// Time this view (profile) was created.
1683    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
1684    /// The currency type associated with this view (profile), defaults to USD. The supported values are:
1685    /// USD, JPY, EUR, GBP, AUD, KRW, BRL, CNY, DKK, RUB, SEK, NOK, PLN, TRY, TWD, HKD, THB, IDR, ARS, MXN, VND, PHP, INR, CHF, CAD, CZK, NZD, HUF, BGN, LTL, ZAR, UAH, AED, BOB, CLP, COP, EGP, HRK, ILS, MAD, MYR, PEN, PKR, RON, RSD, SAR, SGD, VEF, LVL
1686    pub currency: Option<String>,
1687    /// Default page for this view (profile).
1688    #[serde(rename = "defaultPage")]
1689    pub default_page: Option<String>,
1690    /// Indicates whether ecommerce tracking is enabled for this view (profile).
1691    #[serde(rename = "eCommerceTracking")]
1692    pub e_commerce_tracking: Option<bool>,
1693    /// Indicates whether enhanced ecommerce tracking is enabled for this view (profile). This property can only be enabled if ecommerce tracking is enabled.
1694    #[serde(rename = "enhancedECommerceTracking")]
1695    pub enhanced_e_commerce_tracking: Option<bool>,
1696    /// The query parameters that are excluded from this view (profile).
1697    #[serde(rename = "excludeQueryParameters")]
1698    pub exclude_query_parameters: Option<String>,
1699    /// View (Profile) ID.
1700    pub id: Option<String>,
1701    /// Internal ID for the web property to which this view (profile) belongs.
1702    #[serde(rename = "internalWebPropertyId")]
1703    pub internal_web_property_id: Option<String>,
1704    /// Resource type for Analytics view (profile).
1705    pub kind: Option<String>,
1706    /// Name of this view (profile).
1707    pub name: Option<String>,
1708    /// Parent link for this view (profile). Points to the web property to which this view (profile) belongs.
1709    #[serde(rename = "parentLink")]
1710    pub parent_link: Option<ProfileParentLink>,
1711    /// Permissions the user has for this view (profile).
1712    pub permissions: Option<ProfilePermissions>,
1713    /// Link for this view (profile).
1714    #[serde(rename = "selfLink")]
1715    pub self_link: Option<String>,
1716    /// Site search category parameters for this view (profile).
1717    #[serde(rename = "siteSearchCategoryParameters")]
1718    pub site_search_category_parameters: Option<String>,
1719    /// The site search query parameters for this view (profile).
1720    #[serde(rename = "siteSearchQueryParameters")]
1721    pub site_search_query_parameters: Option<String>,
1722    /// Indicates whether this view (profile) is starred or not.
1723    pub starred: Option<bool>,
1724    /// Whether or not Analytics will strip search category parameters from the URLs in your reports.
1725    #[serde(rename = "stripSiteSearchCategoryParameters")]
1726    pub strip_site_search_category_parameters: Option<bool>,
1727    /// Whether or not Analytics will strip search query parameters from the URLs in your reports.
1728    #[serde(rename = "stripSiteSearchQueryParameters")]
1729    pub strip_site_search_query_parameters: Option<bool>,
1730    /// Time zone for which this view (profile) has been configured. Time zones are identified by strings from the TZ database.
1731    pub timezone: Option<String>,
1732    /// View (Profile) type. Supported types: WEB or APP.
1733    #[serde(rename = "type")]
1734    pub type_: Option<String>,
1735    /// Time this view (profile) was last modified.
1736    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1737    /// Web property ID of the form UA-XXXXX-YY to which this view (profile) belongs.
1738    #[serde(rename = "webPropertyId")]
1739    pub web_property_id: Option<String>,
1740    /// Website URL for this view (profile).
1741    #[serde(rename = "websiteUrl")]
1742    pub website_url: Option<String>,
1743}
1744
1745impl common::RequestValue for Profile {}
1746impl common::ResponseResult for Profile {}
1747
1748/// JSON template for an Analytics profile filter link.
1749///
1750/// # Activities
1751///
1752/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1753/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1754///
1755/// * [profile filter links get management](ManagementProfileFilterLinkGetCall) (response)
1756/// * [profile filter links insert management](ManagementProfileFilterLinkInsertCall) (request|response)
1757/// * [profile filter links patch management](ManagementProfileFilterLinkPatchCall) (request|response)
1758/// * [profile filter links update management](ManagementProfileFilterLinkUpdateCall) (request|response)
1759#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1760#[serde_with::serde_as]
1761#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1762pub struct ProfileFilterLink {
1763    /// Filter for this link.
1764    #[serde(rename = "filterRef")]
1765    pub filter_ref: Option<FilterRef>,
1766    /// Profile filter link ID.
1767    pub id: Option<String>,
1768    /// Resource type for Analytics filter.
1769    pub kind: Option<String>,
1770    /// View (Profile) for this link.
1771    #[serde(rename = "profileRef")]
1772    pub profile_ref: Option<ProfileRef>,
1773    /// The rank of this profile filter link relative to the other filters linked to the same profile.
1774    /// For readonly (i.e., list and get) operations, the rank always starts at 1.
1775    /// For write (i.e., create, update, or delete) operations, you may specify a value between 0 and 255 inclusively, [0, 255]. In order to insert a link at the end of the list, either don't specify a rank or set a rank to a number greater than the largest rank in the list. In order to insert a link to the beginning of the list specify a rank that is less than or equal to 1. The new link will move all existing filters with the same or lower rank down the list. After the link is inserted/updated/deleted all profile filter links will be renumbered starting at 1.
1776    pub rank: Option<i32>,
1777    /// Link for this profile filter link.
1778    #[serde(rename = "selfLink")]
1779    pub self_link: Option<String>,
1780}
1781
1782impl common::RequestValue for ProfileFilterLink {}
1783impl common::ResponseResult for ProfileFilterLink {}
1784
1785/// A profile filter link collection lists profile filter links between profiles and filters. Each resource in the collection corresponds to a profile filter link.
1786///
1787/// # Activities
1788///
1789/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1790/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1791///
1792/// * [profile filter links list management](ManagementProfileFilterLinkListCall) (response)
1793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1794#[serde_with::serde_as]
1795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1796pub struct ProfileFilterLinks {
1797    /// A list of profile filter links.
1798    pub items: Option<Vec<ProfileFilterLink>>,
1799    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
1800    #[serde(rename = "itemsPerPage")]
1801    pub items_per_page: Option<i32>,
1802    /// Collection type.
1803    pub kind: Option<String>,
1804    /// Link to next page for this profile filter link collection.
1805    #[serde(rename = "nextLink")]
1806    pub next_link: Option<String>,
1807    /// Link to previous page for this profile filter link collection.
1808    #[serde(rename = "previousLink")]
1809    pub previous_link: Option<String>,
1810    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1811    #[serde(rename = "startIndex")]
1812    pub start_index: Option<i32>,
1813    /// The total number of results for the query, regardless of the number of results in the response.
1814    #[serde(rename = "totalResults")]
1815    pub total_results: Option<i32>,
1816    /// Email ID of the authenticated user
1817    pub username: Option<String>,
1818}
1819
1820impl common::ResponseResult for ProfileFilterLinks {}
1821
1822/// JSON template for a linked view (profile).
1823///
1824/// This type is not used in any activity, and only used as *part* of another schema.
1825///
1826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1827#[serde_with::serde_as]
1828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1829pub struct ProfileRef {
1830    /// Account ID to which this view (profile) belongs.
1831    #[serde(rename = "accountId")]
1832    pub account_id: Option<String>,
1833    /// Link for this view (profile).
1834    pub href: Option<String>,
1835    /// View (Profile) ID.
1836    pub id: Option<String>,
1837    /// Internal ID for the web property to which this view (profile) belongs.
1838    #[serde(rename = "internalWebPropertyId")]
1839    pub internal_web_property_id: Option<String>,
1840    /// Analytics view (profile) reference.
1841    pub kind: Option<String>,
1842    /// Name of this view (profile).
1843    pub name: Option<String>,
1844    /// Web property ID of the form UA-XXXXX-YY to which this view (profile) belongs.
1845    #[serde(rename = "webPropertyId")]
1846    pub web_property_id: Option<String>,
1847}
1848
1849impl common::Part for ProfileRef {}
1850
1851/// JSON template for an Analytics ProfileSummary. ProfileSummary returns basic information (i.e., summary) for a profile.
1852///
1853/// This type is not used in any activity, and only used as *part* of another schema.
1854///
1855#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1856#[serde_with::serde_as]
1857#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1858pub struct ProfileSummary {
1859    /// View (profile) ID.
1860    pub id: Option<String>,
1861    /// Resource type for Analytics ProfileSummary.
1862    pub kind: Option<String>,
1863    /// View (profile) name.
1864    pub name: Option<String>,
1865    /// Indicates whether this view (profile) is starred or not.
1866    pub starred: Option<bool>,
1867    /// View (Profile) type. Supported types: WEB or APP.
1868    #[serde(rename = "type")]
1869    pub type_: Option<String>,
1870}
1871
1872impl common::Part for ProfileSummary {}
1873
1874/// A view (profile) collection lists Analytics views (profiles) to which the user has access. Each resource in the collection corresponds to a single Analytics view (profile).
1875///
1876/// # Activities
1877///
1878/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1879/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1880///
1881/// * [profiles list management](ManagementProfileListCall) (response)
1882#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1883#[serde_with::serde_as]
1884#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1885pub struct Profiles {
1886    /// A list of views (profiles).
1887    pub items: Option<Vec<Profile>>,
1888    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
1889    #[serde(rename = "itemsPerPage")]
1890    pub items_per_page: Option<i32>,
1891    /// Collection type.
1892    pub kind: Option<String>,
1893    /// Link to next page for this view (profile) collection.
1894    #[serde(rename = "nextLink")]
1895    pub next_link: Option<String>,
1896    /// Link to previous page for this view (profile) collection.
1897    #[serde(rename = "previousLink")]
1898    pub previous_link: Option<String>,
1899    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1900    #[serde(rename = "startIndex")]
1901    pub start_index: Option<i32>,
1902    /// The total number of results for the query, regardless of the number of results in the response.
1903    #[serde(rename = "totalResults")]
1904    pub total_results: Option<i32>,
1905    /// Email ID of the authenticated user
1906    pub username: Option<String>,
1907}
1908
1909impl common::ResponseResult for Profiles {}
1910
1911/// Real time data for a given view (profile).
1912///
1913/// # Activities
1914///
1915/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1916/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1917///
1918/// * [realtime get data](DataRealtimeGetCall) (response)
1919#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1920#[serde_with::serde_as]
1921#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1922pub struct RealtimeData {
1923    /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
1924    #[serde(rename = "columnHeaders")]
1925    pub column_headers: Option<Vec<RealtimeDataColumnHeaders>>,
1926    /// Unique ID for this data response.
1927    pub id: Option<String>,
1928    /// Resource type.
1929    pub kind: Option<String>,
1930    /// Information for the view (profile), for which the real time data was requested.
1931    #[serde(rename = "profileInfo")]
1932    pub profile_info: Option<RealtimeDataProfileInfo>,
1933    /// Real time data request query parameters.
1934    pub query: Option<RealtimeDataQuery>,
1935    /// Real time data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request.
1936    pub rows: Option<Vec<Vec<String>>>,
1937    /// Link to this page.
1938    #[serde(rename = "selfLink")]
1939    pub self_link: Option<String>,
1940    /// The total number of rows for the query, regardless of the number of rows in the response.
1941    #[serde(rename = "totalResults")]
1942    pub total_results: Option<i32>,
1943    /// Total values for the requested metrics over all the results, not just the results returned in this response. The order of the metric totals is same as the metric order specified in the request.
1944    #[serde(rename = "totalsForAllResults")]
1945    pub totals_for_all_results: Option<HashMap<String, String>>,
1946}
1947
1948impl common::ResponseResult for RealtimeData {}
1949
1950/// JSON template for an Analytics remarketing audience.
1951///
1952/// # Activities
1953///
1954/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1955/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1956///
1957/// * [remarketing audience get management](ManagementRemarketingAudienceGetCall) (response)
1958/// * [remarketing audience insert management](ManagementRemarketingAudienceInsertCall) (request|response)
1959/// * [remarketing audience patch management](ManagementRemarketingAudiencePatchCall) (request|response)
1960/// * [remarketing audience update management](ManagementRemarketingAudienceUpdateCall) (request|response)
1961#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1962#[serde_with::serde_as]
1963#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1964pub struct RemarketingAudience {
1965    /// Account ID to which this remarketing audience belongs.
1966    #[serde(rename = "accountId")]
1967    pub account_id: Option<String>,
1968    /// The simple audience definition that will cause a user to be added to an audience.
1969    #[serde(rename = "audienceDefinition")]
1970    pub audience_definition: Option<RemarketingAudienceAudienceDefinition>,
1971    /// The type of audience, either SIMPLE or STATE_BASED.
1972    #[serde(rename = "audienceType")]
1973    pub audience_type: Option<String>,
1974    /// Time this remarketing audience was created.
1975    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
1976    /// The description of this remarketing audience.
1977    pub description: Option<String>,
1978    /// Remarketing Audience ID.
1979    pub id: Option<String>,
1980    /// Internal ID for the web property to which this remarketing audience belongs.
1981    #[serde(rename = "internalWebPropertyId")]
1982    pub internal_web_property_id: Option<String>,
1983    /// Collection type.
1984    pub kind: Option<String>,
1985    /// The linked ad accounts associated with this remarketing audience. A remarketing audience can have only one linkedAdAccount currently.
1986    #[serde(rename = "linkedAdAccounts")]
1987    pub linked_ad_accounts: Option<Vec<LinkedForeignAccount>>,
1988    /// The views (profiles) that this remarketing audience is linked to.
1989    #[serde(rename = "linkedViews")]
1990    pub linked_views: Option<Vec<String>>,
1991    /// The name of this remarketing audience.
1992    pub name: Option<String>,
1993    /// A state based audience definition that will cause a user to be added or removed from an audience.
1994    #[serde(rename = "stateBasedAudienceDefinition")]
1995    pub state_based_audience_definition: Option<RemarketingAudienceStateBasedAudienceDefinition>,
1996    /// Time this remarketing audience was last modified.
1997    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1998    /// Web property ID of the form UA-XXXXX-YY to which this remarketing audience belongs.
1999    #[serde(rename = "webPropertyId")]
2000    pub web_property_id: Option<String>,
2001}
2002
2003impl common::RequestValue for RemarketingAudience {}
2004impl common::ResponseResult for RemarketingAudience {}
2005
2006/// A remarketing audience collection lists Analytics remarketing audiences to which the user has access. Each resource in the collection corresponds to a single Analytics remarketing audience.
2007///
2008/// # Activities
2009///
2010/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2011/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2012///
2013/// * [remarketing audience list management](ManagementRemarketingAudienceListCall) (response)
2014#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2015#[serde_with::serde_as]
2016#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2017pub struct RemarketingAudiences {
2018    /// A list of remarketing audiences.
2019    pub items: Option<Vec<RemarketingAudience>>,
2020    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
2021    #[serde(rename = "itemsPerPage")]
2022    pub items_per_page: Option<i32>,
2023    /// Collection type.
2024    pub kind: Option<String>,
2025    /// Link to next page for this remarketing audience collection.
2026    #[serde(rename = "nextLink")]
2027    pub next_link: Option<String>,
2028    /// Link to previous page for this view (profile) collection.
2029    #[serde(rename = "previousLink")]
2030    pub previous_link: Option<String>,
2031    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2032    #[serde(rename = "startIndex")]
2033    pub start_index: Option<i32>,
2034    /// The total number of results for the query, regardless of the number of results in the response.
2035    #[serde(rename = "totalResults")]
2036    pub total_results: Option<i32>,
2037    /// Email ID of the authenticated user
2038    pub username: Option<String>,
2039}
2040
2041impl common::ResponseResult for RemarketingAudiences {}
2042
2043/// JSON template for an Analytics segment.
2044///
2045/// This type is not used in any activity, and only used as *part* of another schema.
2046///
2047#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2048#[serde_with::serde_as]
2049#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2050pub struct Segment {
2051    /// Time the segment was created.
2052    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
2053    /// Segment definition.
2054    pub definition: Option<String>,
2055    /// Segment ID.
2056    pub id: Option<String>,
2057    /// Resource type for Analytics segment.
2058    pub kind: Option<String>,
2059    /// Segment name.
2060    pub name: Option<String>,
2061    /// Segment ID. Can be used with the 'segment' parameter in Core Reporting API.
2062    #[serde(rename = "segmentId")]
2063    pub segment_id: Option<String>,
2064    /// Link for this segment.
2065    #[serde(rename = "selfLink")]
2066    pub self_link: Option<String>,
2067    /// Type for a segment. Possible values are "BUILT_IN" or "CUSTOM".
2068    #[serde(rename = "type")]
2069    pub type_: Option<String>,
2070    /// Time the segment was last modified.
2071    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
2072}
2073
2074impl common::Part for Segment {}
2075
2076/// An segment collection lists Analytics segments that the user has access to. Each resource in the collection corresponds to a single Analytics segment.
2077///
2078/// # Activities
2079///
2080/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2081/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2082///
2083/// * [segments list management](ManagementSegmentListCall) (response)
2084#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2085#[serde_with::serde_as]
2086#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2087pub struct Segments {
2088    /// A list of segments.
2089    pub items: Option<Vec<Segment>>,
2090    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
2091    #[serde(rename = "itemsPerPage")]
2092    pub items_per_page: Option<i32>,
2093    /// Collection type for segments.
2094    pub kind: Option<String>,
2095    /// Link to next page for this segment collection.
2096    #[serde(rename = "nextLink")]
2097    pub next_link: Option<String>,
2098    /// Link to previous page for this segment collection.
2099    #[serde(rename = "previousLink")]
2100    pub previous_link: Option<String>,
2101    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2102    #[serde(rename = "startIndex")]
2103    pub start_index: Option<i32>,
2104    /// The total number of results for the query, regardless of the number of results in the response.
2105    #[serde(rename = "totalResults")]
2106    pub total_results: Option<i32>,
2107    /// Email ID of the authenticated user
2108    pub username: Option<String>,
2109}
2110
2111impl common::ResponseResult for Segments {}
2112
2113/// JSON template for Analytics unsampled report resource.
2114///
2115/// # Activities
2116///
2117/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2118/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2119///
2120/// * [unsampled reports get management](ManagementUnsampledReportGetCall) (response)
2121/// * [unsampled reports insert management](ManagementUnsampledReportInsertCall) (request|response)
2122#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2123#[serde_with::serde_as]
2124#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2125pub struct UnsampledReport {
2126    /// Account ID to which this unsampled report belongs.
2127    #[serde(rename = "accountId")]
2128    pub account_id: Option<String>,
2129    /// Download details for a file stored in Google Cloud Storage.
2130    #[serde(rename = "cloudStorageDownloadDetails")]
2131    pub cloud_storage_download_details: Option<UnsampledReportCloudStorageDownloadDetails>,
2132    /// Time this unsampled report was created.
2133    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
2134    /// The dimensions for the unsampled report.
2135    pub dimensions: Option<String>,
2136    /// The type of download you need to use for the report data file. Possible values include `GOOGLE_DRIVE` and `GOOGLE_CLOUD_STORAGE`. If the value is `GOOGLE_DRIVE`, see the `driveDownloadDetails` field. If the value is `GOOGLE_CLOUD_STORAGE`, see the `cloudStorageDownloadDetails` field.
2137    #[serde(rename = "downloadType")]
2138    pub download_type: Option<String>,
2139    /// Download details for a file stored in Google Drive.
2140    #[serde(rename = "driveDownloadDetails")]
2141    pub drive_download_details: Option<UnsampledReportDriveDownloadDetails>,
2142    /// The end date for the unsampled report.
2143    #[serde(rename = "end-date")]
2144    pub end_date: Option<String>,
2145    /// The filters for the unsampled report.
2146    pub filters: Option<String>,
2147    /// Unsampled report ID.
2148    pub id: Option<String>,
2149    /// Resource type for an Analytics unsampled report.
2150    pub kind: Option<String>,
2151    /// The metrics for the unsampled report.
2152    pub metrics: Option<String>,
2153    /// View (Profile) ID to which this unsampled report belongs.
2154    #[serde(rename = "profileId")]
2155    pub profile_id: Option<String>,
2156    /// The segment for the unsampled report.
2157    pub segment: Option<String>,
2158    /// Link for this unsampled report.
2159    #[serde(rename = "selfLink")]
2160    pub self_link: Option<String>,
2161    /// The start date for the unsampled report.
2162    #[serde(rename = "start-date")]
2163    pub start_date: Option<String>,
2164    /// Status of this unsampled report. Possible values are PENDING, COMPLETED, or FAILED.
2165    pub status: Option<String>,
2166    /// Title of the unsampled report.
2167    pub title: Option<String>,
2168    /// Time this unsampled report was last modified.
2169    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
2170    /// Web property ID to which this unsampled report belongs. The web property ID is of the form UA-XXXXX-YY.
2171    #[serde(rename = "webPropertyId")]
2172    pub web_property_id: Option<String>,
2173}
2174
2175impl common::RequestValue for UnsampledReport {}
2176impl common::ResponseResult for UnsampledReport {}
2177
2178/// An unsampled report collection lists Analytics unsampled reports to which the user has access. Each view (profile) can have a set of unsampled reports. Each resource in the unsampled report collection corresponds to a single Analytics unsampled report.
2179///
2180/// # Activities
2181///
2182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2184///
2185/// * [unsampled reports list management](ManagementUnsampledReportListCall) (response)
2186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2187#[serde_with::serde_as]
2188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2189pub struct UnsampledReports {
2190    /// A list of unsampled reports.
2191    pub items: Option<Vec<UnsampledReport>>,
2192    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
2193    #[serde(rename = "itemsPerPage")]
2194    pub items_per_page: Option<i32>,
2195    /// Collection type.
2196    pub kind: Option<String>,
2197    /// Link to next page for this unsampled report collection.
2198    #[serde(rename = "nextLink")]
2199    pub next_link: Option<String>,
2200    /// Link to previous page for this unsampled report collection.
2201    #[serde(rename = "previousLink")]
2202    pub previous_link: Option<String>,
2203    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2204    #[serde(rename = "startIndex")]
2205    pub start_index: Option<i32>,
2206    /// The total number of results for the query, regardless of the number of resources in the result.
2207    #[serde(rename = "totalResults")]
2208    pub total_results: Option<i32>,
2209    /// Email ID of the authenticated user
2210    pub username: Option<String>,
2211}
2212
2213impl common::ResponseResult for UnsampledReports {}
2214
2215/// Metadata returned for an upload operation.
2216///
2217/// # Activities
2218///
2219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2221///
2222/// * [uploads get management](ManagementUploadGetCall) (response)
2223/// * [uploads upload data management](ManagementUploadUploadDataCall) (response)
2224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2225#[serde_with::serde_as]
2226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2227pub struct Upload {
2228    /// Account Id to which this upload belongs.
2229    #[serde(rename = "accountId")]
2230    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2231    pub account_id: Option<i64>,
2232    /// Custom data source Id to which this data import belongs.
2233    #[serde(rename = "customDataSourceId")]
2234    pub custom_data_source_id: Option<String>,
2235    /// Data import errors collection.
2236    pub errors: Option<Vec<String>>,
2237    /// A unique ID for this upload.
2238    pub id: Option<String>,
2239    /// Resource type for Analytics upload.
2240    pub kind: Option<String>,
2241    /// Upload status. Possible values: PENDING, COMPLETED, FAILED, DELETING, DELETED.
2242    pub status: Option<String>,
2243    /// Time this file is uploaded.
2244    #[serde(rename = "uploadTime")]
2245    pub upload_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2246}
2247
2248impl common::ResponseResult for Upload {}
2249
2250/// Upload collection lists Analytics uploads to which the user has access. Each custom data source can have a set of uploads. Each resource in the upload collection corresponds to a single Analytics data upload.
2251///
2252/// # Activities
2253///
2254/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2255/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2256///
2257/// * [uploads list management](ManagementUploadListCall) (response)
2258#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2259#[serde_with::serde_as]
2260#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2261pub struct Uploads {
2262    /// A list of uploads.
2263    pub items: Option<Vec<Upload>>,
2264    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
2265    #[serde(rename = "itemsPerPage")]
2266    pub items_per_page: Option<i32>,
2267    /// Collection type.
2268    pub kind: Option<String>,
2269    /// Link to next page for this upload collection.
2270    #[serde(rename = "nextLink")]
2271    pub next_link: Option<String>,
2272    /// Link to previous page for this upload collection.
2273    #[serde(rename = "previousLink")]
2274    pub previous_link: Option<String>,
2275    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2276    #[serde(rename = "startIndex")]
2277    pub start_index: Option<i32>,
2278    /// The total number of results for the query, regardless of the number of resources in the result.
2279    #[serde(rename = "totalResults")]
2280    pub total_results: Option<i32>,
2281}
2282
2283impl common::ResponseResult for Uploads {}
2284
2285/// JSON template for a user deletion request resource.
2286///
2287/// # Activities
2288///
2289/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2290/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2291///
2292/// * [user deletion request upsert user deletion](UserDeletionUserDeletionRequestUpsertCall) (request|response)
2293#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2294#[serde_with::serde_as]
2295#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2296pub struct UserDeletionRequest {
2297    /// This marks the point in time for which all user data before should be deleted
2298    #[serde(rename = "deletionRequestTime")]
2299    pub deletion_request_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2300    /// Firebase Project Id
2301    #[serde(rename = "firebaseProjectId")]
2302    pub firebase_project_id: Option<String>,
2303    /// User ID.
2304    pub id: Option<UserDeletionRequestId>,
2305    /// Value is "analytics#userDeletionRequest".
2306    pub kind: Option<String>,
2307    /// Property ID
2308    #[serde(rename = "propertyId")]
2309    pub property_id: Option<String>,
2310    /// Web property ID of the form UA-XXXXX-YY.
2311    #[serde(rename = "webPropertyId")]
2312    pub web_property_id: Option<String>,
2313}
2314
2315impl common::RequestValue for UserDeletionRequest {}
2316impl common::ResponseResult for UserDeletionRequest {}
2317
2318/// JSON template for a user reference.
2319///
2320/// This type is not used in any activity, and only used as *part* of another schema.
2321///
2322#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2323#[serde_with::serde_as]
2324#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2325pub struct UserRef {
2326    /// Email ID of this user.
2327    pub email: Option<String>,
2328    /// User ID.
2329    pub id: Option<String>,
2330    /// no description provided
2331    pub kind: Option<String>,
2332}
2333
2334impl common::Part for UserRef {}
2335
2336/// JSON template for a web property reference.
2337///
2338/// This type is not used in any activity, and only used as *part* of another schema.
2339///
2340#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2341#[serde_with::serde_as]
2342#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2343pub struct WebPropertyRef {
2344    /// Account ID to which this web property belongs.
2345    #[serde(rename = "accountId")]
2346    pub account_id: Option<String>,
2347    /// Link for this web property.
2348    pub href: Option<String>,
2349    /// Web property ID of the form UA-XXXXX-YY.
2350    pub id: Option<String>,
2351    /// Internal ID for this web property.
2352    #[serde(rename = "internalWebPropertyId")]
2353    pub internal_web_property_id: Option<String>,
2354    /// Analytics web property reference.
2355    pub kind: Option<String>,
2356    /// Name of this web property.
2357    pub name: Option<String>,
2358}
2359
2360impl common::Part for WebPropertyRef {}
2361
2362/// JSON template for an Analytics WebPropertySummary. WebPropertySummary returns basic information (i.e., summary) for a web property.
2363///
2364/// This type is not used in any activity, and only used as *part* of another schema.
2365///
2366#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2367#[serde_with::serde_as]
2368#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2369pub struct WebPropertySummary {
2370    /// Web property ID of the form UA-XXXXX-YY.
2371    pub id: Option<String>,
2372    /// Internal ID for this web property.
2373    #[serde(rename = "internalWebPropertyId")]
2374    pub internal_web_property_id: Option<String>,
2375    /// Resource type for Analytics WebPropertySummary.
2376    pub kind: Option<String>,
2377    /// Level for this web property. Possible values are STANDARD or PREMIUM.
2378    pub level: Option<String>,
2379    /// Web property name.
2380    pub name: Option<String>,
2381    /// List of profiles under this web property.
2382    pub profiles: Option<Vec<ProfileSummary>>,
2383    /// Indicates whether this web property is starred or not.
2384    pub starred: Option<bool>,
2385    /// Website url for this web property.
2386    #[serde(rename = "websiteUrl")]
2387    pub website_url: Option<String>,
2388}
2389
2390impl common::Part for WebPropertySummary {}
2391
2392/// A web property collection lists Analytics web properties to which the user has access. Each resource in the collection corresponds to a single Analytics web property.
2393///
2394/// # Activities
2395///
2396/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2397/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2398///
2399/// * [webproperties list management](ManagementWebpropertyListCall) (response)
2400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2401#[serde_with::serde_as]
2402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2403pub struct Webproperties {
2404    /// A list of web properties.
2405    pub items: Option<Vec<Webproperty>>,
2406    /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
2407    #[serde(rename = "itemsPerPage")]
2408    pub items_per_page: Option<i32>,
2409    /// Collection type.
2410    pub kind: Option<String>,
2411    /// Link to next page for this web property collection.
2412    #[serde(rename = "nextLink")]
2413    pub next_link: Option<String>,
2414    /// Link to previous page for this web property collection.
2415    #[serde(rename = "previousLink")]
2416    pub previous_link: Option<String>,
2417    /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2418    #[serde(rename = "startIndex")]
2419    pub start_index: Option<i32>,
2420    /// The total number of results for the query, regardless of the number of results in the response.
2421    #[serde(rename = "totalResults")]
2422    pub total_results: Option<i32>,
2423    /// Email ID of the authenticated user
2424    pub username: Option<String>,
2425}
2426
2427impl common::ResponseResult for Webproperties {}
2428
2429/// JSON template for an Analytics web property.
2430///
2431/// # Activities
2432///
2433/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2434/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2435///
2436/// * [webproperties get management](ManagementWebpropertyGetCall) (response)
2437/// * [webproperties insert management](ManagementWebpropertyInsertCall) (request|response)
2438/// * [webproperties patch management](ManagementWebpropertyPatchCall) (request|response)
2439/// * [webproperties update management](ManagementWebpropertyUpdateCall) (request|response)
2440#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2441#[serde_with::serde_as]
2442#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2443pub struct Webproperty {
2444    /// Account ID to which this web property belongs.
2445    #[serde(rename = "accountId")]
2446    pub account_id: Option<String>,
2447    /// Child link for this web property. Points to the list of views (profiles) for this web property.
2448    #[serde(rename = "childLink")]
2449    pub child_link: Option<WebpropertyChildLink>,
2450    /// Time this web property was created.
2451    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
2452    /// Set to true to reset the retention period of the user identifier with each new event from that user (thus setting the expiration date to current time plus retention period).
2453    /// Set to false to delete data associated with the user identifier automatically after the rentention period.
2454    /// This property cannot be set on insert.
2455    #[serde(rename = "dataRetentionResetOnNewActivity")]
2456    pub data_retention_reset_on_new_activity: Option<bool>,
2457    /// The length of time for which user and event data is retained.
2458    /// This property cannot be set on insert.
2459    #[serde(rename = "dataRetentionTtl")]
2460    pub data_retention_ttl: Option<String>,
2461    /// Default view (profile) ID.
2462    #[serde(rename = "defaultProfileId")]
2463    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2464    pub default_profile_id: Option<i64>,
2465    /// Web property ID of the form UA-XXXXX-YY.
2466    pub id: Option<String>,
2467    /// The industry vertical/category selected for this web property.
2468    #[serde(rename = "industryVertical")]
2469    pub industry_vertical: Option<String>,
2470    /// Internal ID for this web property.
2471    #[serde(rename = "internalWebPropertyId")]
2472    pub internal_web_property_id: Option<String>,
2473    /// Resource type for Analytics WebProperty.
2474    pub kind: Option<String>,
2475    /// Level for this web property. Possible values are STANDARD or PREMIUM.
2476    pub level: Option<String>,
2477    /// Name of this web property.
2478    pub name: Option<String>,
2479    /// Parent link for this web property. Points to the account to which this web property belongs.
2480    #[serde(rename = "parentLink")]
2481    pub parent_link: Option<WebpropertyParentLink>,
2482    /// Permissions the user has for this web property.
2483    pub permissions: Option<WebpropertyPermissions>,
2484    /// View (Profile) count for this web property.
2485    #[serde(rename = "profileCount")]
2486    pub profile_count: Option<i32>,
2487    /// Link for this web property.
2488    #[serde(rename = "selfLink")]
2489    pub self_link: Option<String>,
2490    /// Indicates whether this web property is starred or not.
2491    pub starred: Option<bool>,
2492    /// Time this web property was last modified.
2493    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
2494    /// Website url for this web property.
2495    #[serde(rename = "websiteUrl")]
2496    pub website_url: Option<String>,
2497}
2498
2499impl common::RequestValue for Webproperty {}
2500impl common::ResponseResult for Webproperty {}
2501
2502/// Child link for an account entry. Points to the list of web properties for this account.
2503///
2504/// This type is not used in any activity, and only used as *part* of another schema.
2505///
2506#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2507#[serde_with::serde_as]
2508#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2509pub struct AccountChildLink {
2510    /// Link to the list of web properties for this account.
2511    pub href: Option<String>,
2512    /// Type of the child link. Its value is "analytics#webproperties".
2513    #[serde(rename = "type")]
2514    pub type_: Option<String>,
2515}
2516
2517impl common::NestedType for AccountChildLink {}
2518impl common::Part for AccountChildLink {}
2519
2520/// Permissions the user has for this account.
2521///
2522/// This type is not used in any activity, and only used as *part* of another schema.
2523///
2524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2525#[serde_with::serde_as]
2526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2527pub struct AccountPermissions {
2528    /// All the permissions that the user has for this account. These include any implied permissions (e.g., EDIT implies VIEW).
2529    pub effective: Option<Vec<String>>,
2530}
2531
2532impl common::NestedType for AccountPermissions {}
2533impl common::Part for AccountPermissions {}
2534
2535/// There is no detailed description.
2536///
2537/// This type is not used in any activity, and only used as *part* of another schema.
2538///
2539#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2540#[serde_with::serde_as]
2541#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2542pub struct CustomDataSourceChildLink {
2543    /// Link to the list of daily uploads for this custom data source. Link to the list of uploads for this custom data source.
2544    pub href: Option<String>,
2545    /// Value is "analytics#dailyUploads". Value is "analytics#uploads".
2546    #[serde(rename = "type")]
2547    pub type_: Option<String>,
2548}
2549
2550impl common::NestedType for CustomDataSourceChildLink {}
2551impl common::Part for CustomDataSourceChildLink {}
2552
2553/// Parent link for this custom data source. Points to the web property to which this custom data source belongs.
2554///
2555/// This type is not used in any activity, and only used as *part* of another schema.
2556///
2557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2558#[serde_with::serde_as]
2559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2560pub struct CustomDataSourceParentLink {
2561    /// Link to the web property to which this custom data source belongs.
2562    pub href: Option<String>,
2563    /// Value is "analytics#webproperty".
2564    #[serde(rename = "type")]
2565    pub type_: Option<String>,
2566}
2567
2568impl common::NestedType for CustomDataSourceParentLink {}
2569impl common::Part for CustomDataSourceParentLink {}
2570
2571/// Parent link for the custom dimension. Points to the property to which the custom dimension belongs.
2572///
2573/// This type is not used in any activity, and only used as *part* of another schema.
2574///
2575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2576#[serde_with::serde_as]
2577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2578pub struct CustomDimensionParentLink {
2579    /// Link to the property to which the custom dimension belongs.
2580    pub href: Option<String>,
2581    /// Type of the parent link. Set to "analytics#webproperty".
2582    #[serde(rename = "type")]
2583    pub type_: Option<String>,
2584}
2585
2586impl common::NestedType for CustomDimensionParentLink {}
2587impl common::Part for CustomDimensionParentLink {}
2588
2589/// Parent link for the custom metric. Points to the property to which the custom metric belongs.
2590///
2591/// This type is not used in any activity, and only used as *part* of another schema.
2592///
2593#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2594#[serde_with::serde_as]
2595#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2596pub struct CustomMetricParentLink {
2597    /// Link to the property to which the custom metric belongs.
2598    pub href: Option<String>,
2599    /// Type of the parent link. Set to "analytics#webproperty".
2600    #[serde(rename = "type")]
2601    pub type_: Option<String>,
2602}
2603
2604impl common::NestedType for CustomMetricParentLink {}
2605impl common::Part for CustomMetricParentLink {}
2606
2607/// Web property being linked.
2608///
2609/// This type is not used in any activity, and only used as *part* of another schema.
2610///
2611#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2612#[serde_with::serde_as]
2613#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2614pub struct EntityAdWordsLinkEntity {
2615    /// no description provided
2616    #[serde(rename = "webPropertyRef")]
2617    pub web_property_ref: Option<WebPropertyRef>,
2618}
2619
2620impl common::NestedType for EntityAdWordsLinkEntity {}
2621impl common::Part for EntityAdWordsLinkEntity {}
2622
2623/// Entity for this link. It can be an account, a web property, or a view (profile).
2624///
2625/// This type is not used in any activity, and only used as *part* of another schema.
2626///
2627#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2628#[serde_with::serde_as]
2629#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2630pub struct EntityUserLinkEntity {
2631    /// Account for this link.
2632    #[serde(rename = "accountRef")]
2633    pub account_ref: Option<AccountRef>,
2634    /// View (Profile) for this link.
2635    #[serde(rename = "profileRef")]
2636    pub profile_ref: Option<ProfileRef>,
2637    /// Web property for this link.
2638    #[serde(rename = "webPropertyRef")]
2639    pub web_property_ref: Option<WebPropertyRef>,
2640}
2641
2642impl common::NestedType for EntityUserLinkEntity {}
2643impl common::Part for EntityUserLinkEntity {}
2644
2645/// Permissions the user has for this entity.
2646///
2647/// This type is not used in any activity, and only used as *part* of another schema.
2648///
2649#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2650#[serde_with::serde_as]
2651#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2652pub struct EntityUserLinkPermissions {
2653    /// Effective permissions represent all the permissions that a user has for this entity. These include any implied permissions (e.g., EDIT implies VIEW) or inherited permissions from the parent entity. Effective permissions are read-only.
2654    pub effective: Option<Vec<String>>,
2655    /// Permissions that a user has been assigned at this very level. Does not include any implied or inherited permissions. Local permissions are modifiable.
2656    pub local: Option<Vec<String>>,
2657}
2658
2659impl common::NestedType for EntityUserLinkPermissions {}
2660impl common::Part for EntityUserLinkPermissions {}
2661
2662/// Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
2663///
2664/// This type is not used in any activity, and only used as *part* of another schema.
2665///
2666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2667#[serde_with::serde_as]
2668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2669pub struct ExperimentParentLink {
2670    /// Link to the view (profile) to which this experiment belongs. This field is read-only.
2671    pub href: Option<String>,
2672    /// Value is "analytics#profile". This field is read-only.
2673    #[serde(rename = "type")]
2674    pub type_: Option<String>,
2675}
2676
2677impl common::NestedType for ExperimentParentLink {}
2678impl common::Part for ExperimentParentLink {}
2679
2680/// Array of variations. The first variation in the array is the original. The number of variations may not change once an experiment is in the RUNNING state. At least two variations are required before status can be set to RUNNING.
2681///
2682/// This type is not used in any activity, and only used as *part* of another schema.
2683///
2684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2685#[serde_with::serde_as]
2686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2687pub struct ExperimentVariations {
2688    /// The name of the variation. This field is required when creating an experiment. This field may not be changed for an experiment whose status is ENDED.
2689    pub name: Option<String>,
2690    /// Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not served. This field may not be changed for an experiment whose status is ENDED.
2691    pub status: Option<String>,
2692    /// The URL of the variation. This field may not be changed for an experiment whose status is RUNNING or ENDED.
2693    pub url: Option<String>,
2694    /// Weight that this variation should receive. Only present if the experiment is running. This field is read-only.
2695    pub weight: Option<f64>,
2696    /// True if the experiment has ended and this variation performed (statistically) significantly better than the original. This field is read-only.
2697    pub won: Option<bool>,
2698}
2699
2700impl common::NestedType for ExperimentVariations {}
2701impl common::Part for ExperimentVariations {}
2702
2703/// Details for the filter of the type ADVANCED.
2704///
2705/// This type is not used in any activity, and only used as *part* of another schema.
2706///
2707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2708#[serde_with::serde_as]
2709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2710pub struct FilterAdvancedDetails {
2711    /// Indicates if the filter expressions are case sensitive.
2712    #[serde(rename = "caseSensitive")]
2713    pub case_sensitive: Option<bool>,
2714    /// Expression to extract from field A.
2715    #[serde(rename = "extractA")]
2716    pub extract_a: Option<String>,
2717    /// Expression to extract from field B.
2718    #[serde(rename = "extractB")]
2719    pub extract_b: Option<String>,
2720    /// Field A.
2721    #[serde(rename = "fieldA")]
2722    pub field_a: Option<String>,
2723    /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2724    #[serde(rename = "fieldAIndex")]
2725    pub field_a_index: Option<i32>,
2726    /// Indicates if field A is required to match.
2727    #[serde(rename = "fieldARequired")]
2728    pub field_a_required: Option<bool>,
2729    /// Field B.
2730    #[serde(rename = "fieldB")]
2731    pub field_b: Option<String>,
2732    /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2733    #[serde(rename = "fieldBIndex")]
2734    pub field_b_index: Option<i32>,
2735    /// Indicates if field B is required to match.
2736    #[serde(rename = "fieldBRequired")]
2737    pub field_b_required: Option<bool>,
2738    /// Expression used to construct the output value.
2739    #[serde(rename = "outputConstructor")]
2740    pub output_constructor: Option<String>,
2741    /// Output field.
2742    #[serde(rename = "outputToField")]
2743    pub output_to_field: Option<String>,
2744    /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2745    #[serde(rename = "outputToFieldIndex")]
2746    pub output_to_field_index: Option<i32>,
2747    /// Indicates if the existing value of the output field, if any, should be overridden by the output expression.
2748    #[serde(rename = "overrideOutputField")]
2749    pub override_output_field: Option<bool>,
2750}
2751
2752impl common::NestedType for FilterAdvancedDetails {}
2753impl common::Part for FilterAdvancedDetails {}
2754
2755/// Details for the filter of the type LOWER.
2756///
2757/// This type is not used in any activity, and only used as *part* of another schema.
2758///
2759#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2760#[serde_with::serde_as]
2761#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2762pub struct FilterLowercaseDetails {
2763    /// Field to use in the filter.
2764    pub field: Option<String>,
2765    /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2766    #[serde(rename = "fieldIndex")]
2767    pub field_index: Option<i32>,
2768}
2769
2770impl common::NestedType for FilterLowercaseDetails {}
2771impl common::Part for FilterLowercaseDetails {}
2772
2773/// Parent link for this filter. Points to the account to which this filter belongs.
2774///
2775/// This type is not used in any activity, and only used as *part* of another schema.
2776///
2777#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2778#[serde_with::serde_as]
2779#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2780pub struct FilterParentLink {
2781    /// Link to the account to which this filter belongs.
2782    pub href: Option<String>,
2783    /// Value is "analytics#account".
2784    #[serde(rename = "type")]
2785    pub type_: Option<String>,
2786}
2787
2788impl common::NestedType for FilterParentLink {}
2789impl common::Part for FilterParentLink {}
2790
2791/// Details for the filter of the type SEARCH_AND_REPLACE.
2792///
2793/// This type is not used in any activity, and only used as *part* of another schema.
2794///
2795#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2796#[serde_with::serde_as]
2797#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2798pub struct FilterSearchAndReplaceDetails {
2799    /// Determines if the filter is case sensitive.
2800    #[serde(rename = "caseSensitive")]
2801    pub case_sensitive: Option<bool>,
2802    /// Field to use in the filter.
2803    pub field: Option<String>,
2804    /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2805    #[serde(rename = "fieldIndex")]
2806    pub field_index: Option<i32>,
2807    /// Term to replace the search term with.
2808    #[serde(rename = "replaceString")]
2809    pub replace_string: Option<String>,
2810    /// Term to search.
2811    #[serde(rename = "searchString")]
2812    pub search_string: Option<String>,
2813}
2814
2815impl common::NestedType for FilterSearchAndReplaceDetails {}
2816impl common::Part for FilterSearchAndReplaceDetails {}
2817
2818/// Details for the filter of the type UPPER.
2819///
2820/// This type is not used in any activity, and only used as *part* of another schema.
2821///
2822#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2823#[serde_with::serde_as]
2824#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2825pub struct FilterUppercaseDetails {
2826    /// Field to use in the filter.
2827    pub field: Option<String>,
2828    /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2829    #[serde(rename = "fieldIndex")]
2830    pub field_index: Option<i32>,
2831}
2832
2833impl common::NestedType for FilterUppercaseDetails {}
2834impl common::Part for FilterUppercaseDetails {}
2835
2836/// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
2837///
2838/// This type is not used in any activity, and only used as *part* of another schema.
2839///
2840#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2841#[serde_with::serde_as]
2842#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2843pub struct GaDataColumnHeaders {
2844    /// Column Type. Either DIMENSION or METRIC.
2845    #[serde(rename = "columnType")]
2846    pub column_type: Option<String>,
2847    /// Data type. Dimension column headers have only STRING as the data type. Metric column headers have data types for metric values such as INTEGER, DOUBLE, CURRENCY etc.
2848    #[serde(rename = "dataType")]
2849    pub data_type: Option<String>,
2850    /// Column name.
2851    pub name: Option<String>,
2852}
2853
2854impl common::NestedType for GaDataColumnHeaders {}
2855impl common::Part for GaDataColumnHeaders {}
2856
2857/// There is no detailed description.
2858///
2859/// This type is not used in any activity, and only used as *part* of another schema.
2860///
2861#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2862#[serde_with::serde_as]
2863#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2864pub struct GaDataDataTable {
2865    /// no description provided
2866    pub cols: Option<Vec<GaDataDataTableCols>>,
2867    /// no description provided
2868    pub rows: Option<Vec<GaDataDataTableRows>>,
2869}
2870
2871impl common::NestedType for GaDataDataTable {}
2872impl common::Part for GaDataDataTable {}
2873
2874/// There is no detailed description.
2875///
2876/// This type is not used in any activity, and only used as *part* of another schema.
2877///
2878#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2879#[serde_with::serde_as]
2880#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2881pub struct GaDataDataTableCols {
2882    /// no description provided
2883    pub id: Option<String>,
2884    /// no description provided
2885    pub label: Option<String>,
2886    /// no description provided
2887    #[serde(rename = "type")]
2888    pub type_: Option<String>,
2889}
2890
2891impl common::NestedType for GaDataDataTableCols {}
2892impl common::Part for GaDataDataTableCols {}
2893
2894/// There is no detailed description.
2895///
2896/// This type is not used in any activity, and only used as *part* of another schema.
2897///
2898#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2899#[serde_with::serde_as]
2900#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2901pub struct GaDataDataTableRows {
2902    /// no description provided
2903    pub c: Option<Vec<GaDataDataTableRowsC>>,
2904}
2905
2906impl common::NestedType for GaDataDataTableRows {}
2907impl common::Part for GaDataDataTableRows {}
2908
2909/// There is no detailed description.
2910///
2911/// This type is not used in any activity, and only used as *part* of another schema.
2912///
2913#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2914#[serde_with::serde_as]
2915#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2916pub struct GaDataDataTableRowsC {
2917    /// no description provided
2918    pub v: Option<String>,
2919}
2920
2921impl common::NestedType for GaDataDataTableRowsC {}
2922impl common::Part for GaDataDataTableRowsC {}
2923
2924/// Information for the view (profile), for which the Analytics data was requested.
2925///
2926/// This type is not used in any activity, and only used as *part* of another schema.
2927///
2928#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2929#[serde_with::serde_as]
2930#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2931pub struct GaDataProfileInfo {
2932    /// Account ID to which this view (profile) belongs.
2933    #[serde(rename = "accountId")]
2934    pub account_id: Option<String>,
2935    /// Internal ID for the web property to which this view (profile) belongs.
2936    #[serde(rename = "internalWebPropertyId")]
2937    pub internal_web_property_id: Option<String>,
2938    /// View (Profile) ID.
2939    #[serde(rename = "profileId")]
2940    pub profile_id: Option<String>,
2941    /// View (Profile) name.
2942    #[serde(rename = "profileName")]
2943    pub profile_name: Option<String>,
2944    /// Table ID for view (profile).
2945    #[serde(rename = "tableId")]
2946    pub table_id: Option<String>,
2947    /// Web Property ID to which this view (profile) belongs.
2948    #[serde(rename = "webPropertyId")]
2949    pub web_property_id: Option<String>,
2950}
2951
2952impl common::NestedType for GaDataProfileInfo {}
2953impl common::Part for GaDataProfileInfo {}
2954
2955/// Analytics data request query parameters.
2956///
2957/// This type is not used in any activity, and only used as *part* of another schema.
2958///
2959#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2960#[serde_with::serde_as]
2961#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2962pub struct GaDataQuery {
2963    /// List of analytics dimensions.
2964    pub dimensions: Option<String>,
2965    /// End date.
2966    #[serde(rename = "end-date")]
2967    pub end_date: Option<String>,
2968    /// Comma-separated list of dimension or metric filters.
2969    pub filters: Option<String>,
2970    /// Unique table ID.
2971    pub ids: Option<String>,
2972    /// Maximum results per page.
2973    #[serde(rename = "max-results")]
2974    pub max_results: Option<i32>,
2975    /// List of analytics metrics.
2976    pub metrics: Option<Vec<String>>,
2977    /// Desired sampling level
2978    #[serde(rename = "samplingLevel")]
2979    pub sampling_level: Option<String>,
2980    /// Analytics advanced segment.
2981    pub segment: Option<String>,
2982    /// List of dimensions or metrics based on which Analytics data is sorted.
2983    pub sort: Option<Vec<String>>,
2984    /// Start date.
2985    #[serde(rename = "start-date")]
2986    pub start_date: Option<String>,
2987    /// Start index.
2988    #[serde(rename = "start-index")]
2989    pub start_index: Option<i32>,
2990}
2991
2992impl common::NestedType for GaDataQuery {}
2993impl common::Part for GaDataQuery {}
2994
2995/// Details for the goal of the type EVENT.
2996///
2997/// This type is not used in any activity, and only used as *part* of another schema.
2998///
2999#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3000#[serde_with::serde_as]
3001#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3002pub struct GoalEventDetails {
3003    /// List of event conditions.
3004    #[serde(rename = "eventConditions")]
3005    pub event_conditions: Option<Vec<GoalEventDetailsEventConditions>>,
3006    /// Determines if the event value should be used as the value for this goal.
3007    #[serde(rename = "useEventValue")]
3008    pub use_event_value: Option<bool>,
3009}
3010
3011impl common::NestedType for GoalEventDetails {}
3012impl common::Part for GoalEventDetails {}
3013
3014/// List of event conditions.
3015///
3016/// This type is not used in any activity, and only used as *part* of another schema.
3017///
3018#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3019#[serde_with::serde_as]
3020#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3021pub struct GoalEventDetailsEventConditions {
3022    /// Type of comparison. Possible values are LESS_THAN, GREATER_THAN or EQUAL.
3023    #[serde(rename = "comparisonType")]
3024    pub comparison_type: Option<String>,
3025    /// Value used for this comparison.
3026    #[serde(rename = "comparisonValue")]
3027    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3028    pub comparison_value: Option<i64>,
3029    /// Expression used for this match.
3030    pub expression: Option<String>,
3031    /// Type of the match to be performed. Possible values are REGEXP, BEGINS_WITH, or EXACT.
3032    #[serde(rename = "matchType")]
3033    pub match_type: Option<String>,
3034    /// Type of this event condition. Possible values are CATEGORY, ACTION, LABEL, or VALUE.
3035    #[serde(rename = "type")]
3036    pub type_: Option<String>,
3037}
3038
3039impl common::NestedType for GoalEventDetailsEventConditions {}
3040impl common::Part for GoalEventDetailsEventConditions {}
3041
3042/// Parent link for a goal. Points to the view (profile) to which this goal belongs.
3043///
3044/// This type is not used in any activity, and only used as *part* of another schema.
3045///
3046#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3047#[serde_with::serde_as]
3048#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3049pub struct GoalParentLink {
3050    /// Link to the view (profile) to which this goal belongs.
3051    pub href: Option<String>,
3052    /// Value is "analytics#profile".
3053    #[serde(rename = "type")]
3054    pub type_: Option<String>,
3055}
3056
3057impl common::NestedType for GoalParentLink {}
3058impl common::Part for GoalParentLink {}
3059
3060/// Details for the goal of the type URL_DESTINATION.
3061///
3062/// This type is not used in any activity, and only used as *part* of another schema.
3063///
3064#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3065#[serde_with::serde_as]
3066#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3067pub struct GoalUrlDestinationDetails {
3068    /// Determines if the goal URL must exactly match the capitalization of visited URLs.
3069    #[serde(rename = "caseSensitive")]
3070    pub case_sensitive: Option<bool>,
3071    /// Determines if the first step in this goal is required.
3072    #[serde(rename = "firstStepRequired")]
3073    pub first_step_required: Option<bool>,
3074    /// Match type for the goal URL. Possible values are HEAD, EXACT, or REGEX.
3075    #[serde(rename = "matchType")]
3076    pub match_type: Option<String>,
3077    /// List of steps configured for this goal funnel.
3078    pub steps: Option<Vec<GoalUrlDestinationDetailsSteps>>,
3079    /// URL for this goal.
3080    pub url: Option<String>,
3081}
3082
3083impl common::NestedType for GoalUrlDestinationDetails {}
3084impl common::Part for GoalUrlDestinationDetails {}
3085
3086/// List of steps configured for this goal funnel.
3087///
3088/// This type is not used in any activity, and only used as *part* of another schema.
3089///
3090#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3091#[serde_with::serde_as]
3092#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3093pub struct GoalUrlDestinationDetailsSteps {
3094    /// Step name.
3095    pub name: Option<String>,
3096    /// Step number.
3097    pub number: Option<i32>,
3098    /// URL for this step.
3099    pub url: Option<String>,
3100}
3101
3102impl common::NestedType for GoalUrlDestinationDetailsSteps {}
3103impl common::Part for GoalUrlDestinationDetailsSteps {}
3104
3105/// Details for the goal of the type VISIT_NUM_PAGES.
3106///
3107/// This type is not used in any activity, and only used as *part* of another schema.
3108///
3109#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3110#[serde_with::serde_as]
3111#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3112pub struct GoalVisitNumPagesDetails {
3113    /// Type of comparison. Possible values are LESS_THAN, GREATER_THAN, or EQUAL.
3114    #[serde(rename = "comparisonType")]
3115    pub comparison_type: Option<String>,
3116    /// Value used for this comparison.
3117    #[serde(rename = "comparisonValue")]
3118    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3119    pub comparison_value: Option<i64>,
3120}
3121
3122impl common::NestedType for GoalVisitNumPagesDetails {}
3123impl common::Part for GoalVisitNumPagesDetails {}
3124
3125/// Details for the goal of the type VISIT_TIME_ON_SITE.
3126///
3127/// This type is not used in any activity, and only used as *part* of another schema.
3128///
3129#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3130#[serde_with::serde_as]
3131#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3132pub struct GoalVisitTimeOnSiteDetails {
3133    /// Type of comparison. Possible values are LESS_THAN or GREATER_THAN.
3134    #[serde(rename = "comparisonType")]
3135    pub comparison_type: Option<String>,
3136    /// Value used for this comparison.
3137    #[serde(rename = "comparisonValue")]
3138    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3139    pub comparison_value: Option<i64>,
3140}
3141
3142impl common::NestedType for GoalVisitTimeOnSiteDetails {}
3143impl common::Part for GoalVisitTimeOnSiteDetails {}
3144
3145/// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
3146///
3147/// This type is not used in any activity, and only used as *part* of another schema.
3148///
3149#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3150#[serde_with::serde_as]
3151#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3152pub struct McfDataColumnHeaders {
3153    /// Column Type. Either DIMENSION or METRIC.
3154    #[serde(rename = "columnType")]
3155    pub column_type: Option<String>,
3156    /// Data type. Dimension and metric values data types such as INTEGER, DOUBLE, CURRENCY, MCF_SEQUENCE etc.
3157    #[serde(rename = "dataType")]
3158    pub data_type: Option<String>,
3159    /// Column name.
3160    pub name: Option<String>,
3161}
3162
3163impl common::NestedType for McfDataColumnHeaders {}
3164impl common::Part for McfDataColumnHeaders {}
3165
3166/// Information for the view (profile), for which the Analytics data was requested.
3167///
3168/// This type is not used in any activity, and only used as *part* of another schema.
3169///
3170#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3171#[serde_with::serde_as]
3172#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3173pub struct McfDataProfileInfo {
3174    /// Account ID to which this view (profile) belongs.
3175    #[serde(rename = "accountId")]
3176    pub account_id: Option<String>,
3177    /// Internal ID for the web property to which this view (profile) belongs.
3178    #[serde(rename = "internalWebPropertyId")]
3179    pub internal_web_property_id: Option<String>,
3180    /// View (Profile) ID.
3181    #[serde(rename = "profileId")]
3182    pub profile_id: Option<String>,
3183    /// View (Profile) name.
3184    #[serde(rename = "profileName")]
3185    pub profile_name: Option<String>,
3186    /// Table ID for view (profile).
3187    #[serde(rename = "tableId")]
3188    pub table_id: Option<String>,
3189    /// Web Property ID to which this view (profile) belongs.
3190    #[serde(rename = "webPropertyId")]
3191    pub web_property_id: Option<String>,
3192}
3193
3194impl common::NestedType for McfDataProfileInfo {}
3195impl common::Part for McfDataProfileInfo {}
3196
3197/// Analytics data request query parameters.
3198///
3199/// This type is not used in any activity, and only used as *part* of another schema.
3200///
3201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3202#[serde_with::serde_as]
3203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3204pub struct McfDataQuery {
3205    /// List of analytics dimensions.
3206    pub dimensions: Option<String>,
3207    /// End date.
3208    #[serde(rename = "end-date")]
3209    pub end_date: Option<String>,
3210    /// Comma-separated list of dimension or metric filters.
3211    pub filters: Option<String>,
3212    /// Unique table ID.
3213    pub ids: Option<String>,
3214    /// Maximum results per page.
3215    #[serde(rename = "max-results")]
3216    pub max_results: Option<i32>,
3217    /// List of analytics metrics.
3218    pub metrics: Option<Vec<String>>,
3219    /// Desired sampling level
3220    #[serde(rename = "samplingLevel")]
3221    pub sampling_level: Option<String>,
3222    /// Analytics advanced segment.
3223    pub segment: Option<String>,
3224    /// List of dimensions or metrics based on which Analytics data is sorted.
3225    pub sort: Option<Vec<String>>,
3226    /// Start date.
3227    #[serde(rename = "start-date")]
3228    pub start_date: Option<String>,
3229    /// Start index.
3230    #[serde(rename = "start-index")]
3231    pub start_index: Option<i32>,
3232}
3233
3234impl common::NestedType for McfDataQuery {}
3235impl common::Part for McfDataQuery {}
3236
3237/// A union object representing a dimension or metric value. Only one of "primitiveValue" or "conversionPathValue" attribute will be populated.
3238///
3239/// This type is not used in any activity, and only used as *part* of another schema.
3240///
3241#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3242#[serde_with::serde_as]
3243#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3244pub struct McfDataRows {
3245    /// A conversion path dimension value, containing a list of interactions with their attributes.
3246    #[serde(rename = "conversionPathValue")]
3247    pub conversion_path_value: Option<Vec<McfDataRowsConversionPathValue>>,
3248    /// A primitive dimension value. A primitive metric value.
3249    #[serde(rename = "primitiveValue")]
3250    pub primitive_value: Option<String>,
3251}
3252
3253impl common::NestedType for McfDataRows {}
3254impl common::Part for McfDataRows {}
3255
3256/// A conversion path dimension value, containing a list of interactions with their attributes.
3257///
3258/// This type is not used in any activity, and only used as *part* of another schema.
3259///
3260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3261#[serde_with::serde_as]
3262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3263pub struct McfDataRowsConversionPathValue {
3264    /// Type of an interaction on conversion path. Such as CLICK, IMPRESSION etc.
3265    #[serde(rename = "interactionType")]
3266    pub interaction_type: Option<String>,
3267    /// Node value of an interaction on conversion path. Such as source, medium etc.
3268    #[serde(rename = "nodeValue")]
3269    pub node_value: Option<String>,
3270}
3271
3272impl common::NestedType for McfDataRowsConversionPathValue {}
3273impl common::Part for McfDataRowsConversionPathValue {}
3274
3275/// Child link for this view (profile). Points to the list of goals for this view (profile).
3276///
3277/// This type is not used in any activity, and only used as *part* of another schema.
3278///
3279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3280#[serde_with::serde_as]
3281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3282pub struct ProfileChildLink {
3283    /// Link to the list of goals for this view (profile).
3284    pub href: Option<String>,
3285    /// Value is "analytics#goals".
3286    #[serde(rename = "type")]
3287    pub type_: Option<String>,
3288}
3289
3290impl common::NestedType for ProfileChildLink {}
3291impl common::Part for ProfileChildLink {}
3292
3293/// Parent link for this view (profile). Points to the web property to which this view (profile) belongs.
3294///
3295/// This type is not used in any activity, and only used as *part* of another schema.
3296///
3297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3298#[serde_with::serde_as]
3299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3300pub struct ProfileParentLink {
3301    /// Link to the web property to which this view (profile) belongs.
3302    pub href: Option<String>,
3303    /// Value is "analytics#webproperty".
3304    #[serde(rename = "type")]
3305    pub type_: Option<String>,
3306}
3307
3308impl common::NestedType for ProfileParentLink {}
3309impl common::Part for ProfileParentLink {}
3310
3311/// Permissions the user has for this view (profile).
3312///
3313/// This type is not used in any activity, and only used as *part* of another schema.
3314///
3315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3316#[serde_with::serde_as]
3317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3318pub struct ProfilePermissions {
3319    /// All the permissions that the user has for this view (profile). These include any implied permissions (e.g., EDIT implies VIEW) or inherited permissions from the parent web property.
3320    pub effective: Option<Vec<String>>,
3321}
3322
3323impl common::NestedType for ProfilePermissions {}
3324impl common::Part for ProfilePermissions {}
3325
3326/// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
3327///
3328/// This type is not used in any activity, and only used as *part* of another schema.
3329///
3330#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3331#[serde_with::serde_as]
3332#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3333pub struct RealtimeDataColumnHeaders {
3334    /// Column Type. Either DIMENSION or METRIC.
3335    #[serde(rename = "columnType")]
3336    pub column_type: Option<String>,
3337    /// Data type. Dimension column headers have only STRING as the data type. Metric column headers have data types for metric values such as INTEGER, DOUBLE, CURRENCY etc.
3338    #[serde(rename = "dataType")]
3339    pub data_type: Option<String>,
3340    /// Column name.
3341    pub name: Option<String>,
3342}
3343
3344impl common::NestedType for RealtimeDataColumnHeaders {}
3345impl common::Part for RealtimeDataColumnHeaders {}
3346
3347/// Information for the view (profile), for which the real time data was requested.
3348///
3349/// This type is not used in any activity, and only used as *part* of another schema.
3350///
3351#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3352#[serde_with::serde_as]
3353#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3354pub struct RealtimeDataProfileInfo {
3355    /// Account ID to which this view (profile) belongs.
3356    #[serde(rename = "accountId")]
3357    pub account_id: Option<String>,
3358    /// Internal ID for the web property to which this view (profile) belongs.
3359    #[serde(rename = "internalWebPropertyId")]
3360    pub internal_web_property_id: Option<String>,
3361    /// View (Profile) ID.
3362    #[serde(rename = "profileId")]
3363    pub profile_id: Option<String>,
3364    /// View (Profile) name.
3365    #[serde(rename = "profileName")]
3366    pub profile_name: Option<String>,
3367    /// Table ID for view (profile).
3368    #[serde(rename = "tableId")]
3369    pub table_id: Option<String>,
3370    /// Web Property ID to which this view (profile) belongs.
3371    #[serde(rename = "webPropertyId")]
3372    pub web_property_id: Option<String>,
3373}
3374
3375impl common::NestedType for RealtimeDataProfileInfo {}
3376impl common::Part for RealtimeDataProfileInfo {}
3377
3378/// Real time data request query parameters.
3379///
3380/// This type is not used in any activity, and only used as *part* of another schema.
3381///
3382#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3383#[serde_with::serde_as]
3384#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3385pub struct RealtimeDataQuery {
3386    /// List of real time dimensions.
3387    pub dimensions: Option<String>,
3388    /// Comma-separated list of dimension or metric filters.
3389    pub filters: Option<String>,
3390    /// Unique table ID.
3391    pub ids: Option<String>,
3392    /// Maximum results per page.
3393    #[serde(rename = "max-results")]
3394    pub max_results: Option<i32>,
3395    /// List of real time metrics.
3396    pub metrics: Option<Vec<String>>,
3397    /// List of dimensions or metrics based on which real time data is sorted.
3398    pub sort: Option<Vec<String>>,
3399}
3400
3401impl common::NestedType for RealtimeDataQuery {}
3402impl common::Part for RealtimeDataQuery {}
3403
3404/// The simple audience definition that will cause a user to be added to an audience.
3405///
3406/// This type is not used in any activity, and only used as *part* of another schema.
3407///
3408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3409#[serde_with::serde_as]
3410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3411pub struct RemarketingAudienceAudienceDefinition {
3412    /// Defines the conditions to include users to the audience.
3413    #[serde(rename = "includeConditions")]
3414    pub include_conditions: Option<IncludeConditions>,
3415}
3416
3417impl common::NestedType for RemarketingAudienceAudienceDefinition {}
3418impl common::Part for RemarketingAudienceAudienceDefinition {}
3419
3420/// A state based audience definition that will cause a user to be added or removed from an audience.
3421///
3422/// This type is not used in any activity, and only used as *part* of another schema.
3423///
3424#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3425#[serde_with::serde_as]
3426#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3427pub struct RemarketingAudienceStateBasedAudienceDefinition {
3428    /// Defines the conditions to exclude users from the audience.
3429    #[serde(rename = "excludeConditions")]
3430    pub exclude_conditions:
3431        Option<RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions>,
3432    /// Defines the conditions to include users to the audience.
3433    #[serde(rename = "includeConditions")]
3434    pub include_conditions: Option<IncludeConditions>,
3435}
3436
3437impl common::NestedType for RemarketingAudienceStateBasedAudienceDefinition {}
3438impl common::Part for RemarketingAudienceStateBasedAudienceDefinition {}
3439
3440/// Defines the conditions to exclude users from the audience.
3441///
3442/// This type is not used in any activity, and only used as *part* of another schema.
3443///
3444#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3445#[serde_with::serde_as]
3446#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3447pub struct RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions {
3448    /// Whether to make the exclusion TEMPORARY or PERMANENT.
3449    #[serde(rename = "exclusionDuration")]
3450    pub exclusion_duration: Option<String>,
3451    /// The segment condition that will cause a user to be removed from an audience.
3452    pub segment: Option<String>,
3453}
3454
3455impl common::NestedType for RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions {}
3456impl common::Part for RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions {}
3457
3458/// Download details for a file stored in Google Cloud Storage.
3459///
3460/// This type is not used in any activity, and only used as *part* of another schema.
3461///
3462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3463#[serde_with::serde_as]
3464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3465pub struct UnsampledReportCloudStorageDownloadDetails {
3466    /// Id of the bucket the file object is stored in.
3467    #[serde(rename = "bucketId")]
3468    pub bucket_id: Option<String>,
3469    /// Id of the file object containing the report data.
3470    #[serde(rename = "objectId")]
3471    pub object_id: Option<String>,
3472}
3473
3474impl common::NestedType for UnsampledReportCloudStorageDownloadDetails {}
3475impl common::Part for UnsampledReportCloudStorageDownloadDetails {}
3476
3477/// Download details for a file stored in Google Drive.
3478///
3479/// This type is not used in any activity, and only used as *part* of another schema.
3480///
3481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3482#[serde_with::serde_as]
3483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3484pub struct UnsampledReportDriveDownloadDetails {
3485    /// Id of the document/file containing the report data.
3486    #[serde(rename = "documentId")]
3487    pub document_id: Option<String>,
3488}
3489
3490impl common::NestedType for UnsampledReportDriveDownloadDetails {}
3491impl common::Part for UnsampledReportDriveDownloadDetails {}
3492
3493/// User ID.
3494///
3495/// This type is not used in any activity, and only used as *part* of another schema.
3496///
3497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3498#[serde_with::serde_as]
3499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3500pub struct UserDeletionRequestId {
3501    /// Type of user
3502    #[serde(rename = "type")]
3503    pub type_: Option<String>,
3504    /// The User's id
3505    #[serde(rename = "userId")]
3506    pub user_id: Option<String>,
3507}
3508
3509impl common::NestedType for UserDeletionRequestId {}
3510impl common::Part for UserDeletionRequestId {}
3511
3512/// Child link for this web property. Points to the list of views (profiles) for this web property.
3513///
3514/// This type is not used in any activity, and only used as *part* of another schema.
3515///
3516#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3517#[serde_with::serde_as]
3518#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3519pub struct WebpropertyChildLink {
3520    /// Link to the list of views (profiles) for this web property.
3521    pub href: Option<String>,
3522    /// Type of the parent link. Its value is "analytics#profiles".
3523    #[serde(rename = "type")]
3524    pub type_: Option<String>,
3525}
3526
3527impl common::NestedType for WebpropertyChildLink {}
3528impl common::Part for WebpropertyChildLink {}
3529
3530/// Parent link for this web property. Points to the account to which this web property belongs.
3531///
3532/// This type is not used in any activity, and only used as *part* of another schema.
3533///
3534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3535#[serde_with::serde_as]
3536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3537pub struct WebpropertyParentLink {
3538    /// Link to the account for this web property.
3539    pub href: Option<String>,
3540    /// Type of the parent link. Its value is "analytics#account".
3541    #[serde(rename = "type")]
3542    pub type_: Option<String>,
3543}
3544
3545impl common::NestedType for WebpropertyParentLink {}
3546impl common::Part for WebpropertyParentLink {}
3547
3548/// Permissions the user has for this web property.
3549///
3550/// This type is not used in any activity, and only used as *part* of another schema.
3551///
3552#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3553#[serde_with::serde_as]
3554#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3555pub struct WebpropertyPermissions {
3556    /// All the permissions that the user has for this web property. These include any implied permissions (e.g., EDIT implies VIEW) or inherited permissions from the parent account.
3557    pub effective: Option<Vec<String>>,
3558}
3559
3560impl common::NestedType for WebpropertyPermissions {}
3561impl common::Part for WebpropertyPermissions {}
3562
3563// ###################
3564// MethodBuilders ###
3565// #################
3566
3567/// A builder providing access to all methods supported on *data* resources.
3568/// It is not used directly, but through the [`Analytics`] hub.
3569///
3570/// # Example
3571///
3572/// Instantiate a resource builder
3573///
3574/// ```test_harness,no_run
3575/// extern crate hyper;
3576/// extern crate hyper_rustls;
3577/// extern crate google_analytics3 as analytics3;
3578///
3579/// # async fn dox() {
3580/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3581///
3582/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3583/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3584///     .with_native_roots()
3585///     .unwrap()
3586///     .https_only()
3587///     .enable_http2()
3588///     .build();
3589///
3590/// let executor = hyper_util::rt::TokioExecutor::new();
3591/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3592///     secret,
3593///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3594///     yup_oauth2::client::CustomHyperClientBuilder::from(
3595///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3596///     ),
3597/// ).build().await.unwrap();
3598///
3599/// let client = hyper_util::client::legacy::Client::builder(
3600///     hyper_util::rt::TokioExecutor::new()
3601/// )
3602/// .build(
3603///     hyper_rustls::HttpsConnectorBuilder::new()
3604///         .with_native_roots()
3605///         .unwrap()
3606///         .https_or_http()
3607///         .enable_http2()
3608///         .build()
3609/// );
3610/// let mut hub = Analytics::new(client, auth);
3611/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3612/// // like `ga_get(...)`, `mcf_get(...)` and `realtime_get(...)`
3613/// // to build up your call.
3614/// let rb = hub.data();
3615/// # }
3616/// ```
3617pub struct DataMethods<'a, C>
3618where
3619    C: 'a,
3620{
3621    hub: &'a Analytics<C>,
3622}
3623
3624impl<'a, C> common::MethodsBuilder for DataMethods<'a, C> {}
3625
3626impl<'a, C> DataMethods<'a, C> {
3627    /// Create a builder to help you perform the following task:
3628    ///
3629    /// Returns Analytics data for a view (profile).
3630    ///
3631    /// # Arguments
3632    ///
3633    /// * `ids` - Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
3634    /// * `start-date` - Start date for fetching Analytics data. Requests can specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is 7daysAgo.
3635    /// * `end-date` - End date for fetching Analytics data. Request can should specify an end date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is yesterday.
3636    /// * `metrics` - A comma-separated list of Analytics metrics. E.g., 'ga:sessions,ga:pageviews'. At least one metric must be specified.
3637    pub fn ga_get(
3638        &self,
3639        ids: &str,
3640        start_date: &str,
3641        end_date: &str,
3642        metrics: &str,
3643    ) -> DataGaGetCall<'a, C> {
3644        DataGaGetCall {
3645            hub: self.hub,
3646            _ids: ids.to_string(),
3647            _start_date: start_date.to_string(),
3648            _end_date: end_date.to_string(),
3649            _metrics: metrics.to_string(),
3650            _start_index: Default::default(),
3651            _sort: Default::default(),
3652            _segment: Default::default(),
3653            _sampling_level: Default::default(),
3654            _output: Default::default(),
3655            _max_results: Default::default(),
3656            _include_empty_rows: Default::default(),
3657            _filters: Default::default(),
3658            _dimensions: Default::default(),
3659            _delegate: Default::default(),
3660            _additional_params: Default::default(),
3661            _scopes: Default::default(),
3662        }
3663    }
3664
3665    /// Create a builder to help you perform the following task:
3666    ///
3667    /// Returns Analytics Multi-Channel Funnels data for a view (profile).
3668    ///
3669    /// # Arguments
3670    ///
3671    /// * `ids` - Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
3672    /// * `start-date` - Start date for fetching Analytics data. Requests can specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is 7daysAgo.
3673    /// * `end-date` - End date for fetching Analytics data. Requests can specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is 7daysAgo.
3674    /// * `metrics` - A comma-separated list of Multi-Channel Funnels metrics. E.g., 'mcf:totalConversions,mcf:totalConversionValue'. At least one metric must be specified.
3675    pub fn mcf_get(
3676        &self,
3677        ids: &str,
3678        start_date: &str,
3679        end_date: &str,
3680        metrics: &str,
3681    ) -> DataMcfGetCall<'a, C> {
3682        DataMcfGetCall {
3683            hub: self.hub,
3684            _ids: ids.to_string(),
3685            _start_date: start_date.to_string(),
3686            _end_date: end_date.to_string(),
3687            _metrics: metrics.to_string(),
3688            _start_index: Default::default(),
3689            _sort: Default::default(),
3690            _sampling_level: Default::default(),
3691            _max_results: Default::default(),
3692            _filters: Default::default(),
3693            _dimensions: Default::default(),
3694            _delegate: Default::default(),
3695            _additional_params: Default::default(),
3696            _scopes: Default::default(),
3697        }
3698    }
3699
3700    /// Create a builder to help you perform the following task:
3701    ///
3702    /// Returns real time data for a view (profile).
3703    ///
3704    /// # Arguments
3705    ///
3706    /// * `ids` - Unique table ID for retrieving real time data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
3707    /// * `metrics` - A comma-separated list of real time metrics. E.g., 'rt:activeUsers'. At least one metric must be specified.
3708    pub fn realtime_get(&self, ids: &str, metrics: &str) -> DataRealtimeGetCall<'a, C> {
3709        DataRealtimeGetCall {
3710            hub: self.hub,
3711            _ids: ids.to_string(),
3712            _metrics: metrics.to_string(),
3713            _sort: Default::default(),
3714            _max_results: Default::default(),
3715            _filters: Default::default(),
3716            _dimensions: Default::default(),
3717            _delegate: Default::default(),
3718            _additional_params: Default::default(),
3719            _scopes: Default::default(),
3720        }
3721    }
3722}
3723
3724/// A builder providing access to all methods supported on *management* resources.
3725/// It is not used directly, but through the [`Analytics`] hub.
3726///
3727/// # Example
3728///
3729/// Instantiate a resource builder
3730///
3731/// ```test_harness,no_run
3732/// extern crate hyper;
3733/// extern crate hyper_rustls;
3734/// extern crate google_analytics3 as analytics3;
3735///
3736/// # async fn dox() {
3737/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3738///
3739/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3740/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3741///     .with_native_roots()
3742///     .unwrap()
3743///     .https_only()
3744///     .enable_http2()
3745///     .build();
3746///
3747/// let executor = hyper_util::rt::TokioExecutor::new();
3748/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3749///     secret,
3750///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3751///     yup_oauth2::client::CustomHyperClientBuilder::from(
3752///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3753///     ),
3754/// ).build().await.unwrap();
3755///
3756/// let client = hyper_util::client::legacy::Client::builder(
3757///     hyper_util::rt::TokioExecutor::new()
3758/// )
3759/// .build(
3760///     hyper_rustls::HttpsConnectorBuilder::new()
3761///         .with_native_roots()
3762///         .unwrap()
3763///         .https_or_http()
3764///         .enable_http2()
3765///         .build()
3766/// );
3767/// let mut hub = Analytics::new(client, auth);
3768/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3769/// // like `account_summaries_list(...)`, `account_user_links_delete(...)`, `account_user_links_insert(...)`, `account_user_links_list(...)`, `account_user_links_update(...)`, `accounts_list(...)`, `client_id_hash_client_id(...)`, `custom_data_sources_list(...)`, `custom_dimensions_get(...)`, `custom_dimensions_insert(...)`, `custom_dimensions_list(...)`, `custom_dimensions_patch(...)`, `custom_dimensions_update(...)`, `custom_metrics_get(...)`, `custom_metrics_insert(...)`, `custom_metrics_list(...)`, `custom_metrics_patch(...)`, `custom_metrics_update(...)`, `experiments_delete(...)`, `experiments_get(...)`, `experiments_insert(...)`, `experiments_list(...)`, `experiments_patch(...)`, `experiments_update(...)`, `filters_delete(...)`, `filters_get(...)`, `filters_insert(...)`, `filters_list(...)`, `filters_patch(...)`, `filters_update(...)`, `goals_get(...)`, `goals_insert(...)`, `goals_list(...)`, `goals_patch(...)`, `goals_update(...)`, `profile_filter_links_delete(...)`, `profile_filter_links_get(...)`, `profile_filter_links_insert(...)`, `profile_filter_links_list(...)`, `profile_filter_links_patch(...)`, `profile_filter_links_update(...)`, `profile_user_links_delete(...)`, `profile_user_links_insert(...)`, `profile_user_links_list(...)`, `profile_user_links_update(...)`, `profiles_delete(...)`, `profiles_get(...)`, `profiles_insert(...)`, `profiles_list(...)`, `profiles_patch(...)`, `profiles_update(...)`, `remarketing_audience_delete(...)`, `remarketing_audience_get(...)`, `remarketing_audience_insert(...)`, `remarketing_audience_list(...)`, `remarketing_audience_patch(...)`, `remarketing_audience_update(...)`, `segments_list(...)`, `unsampled_reports_delete(...)`, `unsampled_reports_get(...)`, `unsampled_reports_insert(...)`, `unsampled_reports_list(...)`, `uploads_delete_upload_data(...)`, `uploads_get(...)`, `uploads_list(...)`, `uploads_upload_data(...)`, `web_property_ad_words_links_delete(...)`, `web_property_ad_words_links_get(...)`, `web_property_ad_words_links_insert(...)`, `web_property_ad_words_links_list(...)`, `web_property_ad_words_links_patch(...)`, `web_property_ad_words_links_update(...)`, `webproperties_get(...)`, `webproperties_insert(...)`, `webproperties_list(...)`, `webproperties_patch(...)`, `webproperties_update(...)`, `webproperty_user_links_delete(...)`, `webproperty_user_links_insert(...)`, `webproperty_user_links_list(...)` and `webproperty_user_links_update(...)`
3770/// // to build up your call.
3771/// let rb = hub.management();
3772/// # }
3773/// ```
3774pub struct ManagementMethods<'a, C>
3775where
3776    C: 'a,
3777{
3778    hub: &'a Analytics<C>,
3779}
3780
3781impl<'a, C> common::MethodsBuilder for ManagementMethods<'a, C> {}
3782
3783impl<'a, C> ManagementMethods<'a, C> {
3784    /// Create a builder to help you perform the following task:
3785    ///
3786    /// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
3787    pub fn account_summaries_list(&self) -> ManagementAccountSummaryListCall<'a, C> {
3788        ManagementAccountSummaryListCall {
3789            hub: self.hub,
3790            _start_index: Default::default(),
3791            _max_results: Default::default(),
3792            _delegate: Default::default(),
3793            _additional_params: Default::default(),
3794            _scopes: Default::default(),
3795        }
3796    }
3797
3798    /// Create a builder to help you perform the following task:
3799    ///
3800    /// Removes a user from the given account.
3801    ///
3802    /// # Arguments
3803    ///
3804    /// * `accountId` - Account ID to delete the user link for.
3805    /// * `linkId` - Link ID to delete the user link for.
3806    pub fn account_user_links_delete(
3807        &self,
3808        account_id: &str,
3809        link_id: &str,
3810    ) -> ManagementAccountUserLinkDeleteCall<'a, C> {
3811        ManagementAccountUserLinkDeleteCall {
3812            hub: self.hub,
3813            _account_id: account_id.to_string(),
3814            _link_id: link_id.to_string(),
3815            _delegate: Default::default(),
3816            _additional_params: Default::default(),
3817            _scopes: Default::default(),
3818        }
3819    }
3820
3821    /// Create a builder to help you perform the following task:
3822    ///
3823    /// Adds a new user to the given account.
3824    ///
3825    /// # Arguments
3826    ///
3827    /// * `request` - No description provided.
3828    /// * `accountId` - Account ID to create the user link for.
3829    pub fn account_user_links_insert(
3830        &self,
3831        request: EntityUserLink,
3832        account_id: &str,
3833    ) -> ManagementAccountUserLinkInsertCall<'a, C> {
3834        ManagementAccountUserLinkInsertCall {
3835            hub: self.hub,
3836            _request: request,
3837            _account_id: account_id.to_string(),
3838            _delegate: Default::default(),
3839            _additional_params: Default::default(),
3840            _scopes: Default::default(),
3841        }
3842    }
3843
3844    /// Create a builder to help you perform the following task:
3845    ///
3846    /// Lists account-user links for a given account.
3847    ///
3848    /// # Arguments
3849    ///
3850    /// * `accountId` - Account ID to retrieve the user links for.
3851    pub fn account_user_links_list(
3852        &self,
3853        account_id: &str,
3854    ) -> ManagementAccountUserLinkListCall<'a, C> {
3855        ManagementAccountUserLinkListCall {
3856            hub: self.hub,
3857            _account_id: account_id.to_string(),
3858            _start_index: Default::default(),
3859            _max_results: Default::default(),
3860            _delegate: Default::default(),
3861            _additional_params: Default::default(),
3862            _scopes: Default::default(),
3863        }
3864    }
3865
3866    /// Create a builder to help you perform the following task:
3867    ///
3868    /// Updates permissions for an existing user on the given account.
3869    ///
3870    /// # Arguments
3871    ///
3872    /// * `request` - No description provided.
3873    /// * `accountId` - Account ID to update the account-user link for.
3874    /// * `linkId` - Link ID to update the account-user link for.
3875    pub fn account_user_links_update(
3876        &self,
3877        request: EntityUserLink,
3878        account_id: &str,
3879        link_id: &str,
3880    ) -> ManagementAccountUserLinkUpdateCall<'a, C> {
3881        ManagementAccountUserLinkUpdateCall {
3882            hub: self.hub,
3883            _request: request,
3884            _account_id: account_id.to_string(),
3885            _link_id: link_id.to_string(),
3886            _delegate: Default::default(),
3887            _additional_params: Default::default(),
3888            _scopes: Default::default(),
3889        }
3890    }
3891
3892    /// Create a builder to help you perform the following task:
3893    ///
3894    /// Lists all accounts to which the user has access.
3895    pub fn accounts_list(&self) -> ManagementAccountListCall<'a, C> {
3896        ManagementAccountListCall {
3897            hub: self.hub,
3898            _start_index: Default::default(),
3899            _max_results: Default::default(),
3900            _delegate: Default::default(),
3901            _additional_params: Default::default(),
3902            _scopes: Default::default(),
3903        }
3904    }
3905
3906    /// Create a builder to help you perform the following task:
3907    ///
3908    /// Hashes the given Client ID.
3909    ///
3910    /// # Arguments
3911    ///
3912    /// * `request` - No description provided.
3913    pub fn client_id_hash_client_id(
3914        &self,
3915        request: HashClientIdRequest,
3916    ) -> ManagementClientIdHashClientIdCall<'a, C> {
3917        ManagementClientIdHashClientIdCall {
3918            hub: self.hub,
3919            _request: request,
3920            _delegate: Default::default(),
3921            _additional_params: Default::default(),
3922            _scopes: Default::default(),
3923        }
3924    }
3925
3926    /// Create a builder to help you perform the following task:
3927    ///
3928    /// List custom data sources to which the user has access.
3929    ///
3930    /// # Arguments
3931    ///
3932    /// * `accountId` - Account Id for the custom data sources to retrieve.
3933    /// * `webPropertyId` - Web property Id for the custom data sources to retrieve.
3934    pub fn custom_data_sources_list(
3935        &self,
3936        account_id: &str,
3937        web_property_id: &str,
3938    ) -> ManagementCustomDataSourceListCall<'a, C> {
3939        ManagementCustomDataSourceListCall {
3940            hub: self.hub,
3941            _account_id: account_id.to_string(),
3942            _web_property_id: web_property_id.to_string(),
3943            _start_index: Default::default(),
3944            _max_results: Default::default(),
3945            _delegate: Default::default(),
3946            _additional_params: Default::default(),
3947            _scopes: Default::default(),
3948        }
3949    }
3950
3951    /// Create a builder to help you perform the following task:
3952    ///
3953    /// Get a custom dimension to which the user has access.
3954    ///
3955    /// # Arguments
3956    ///
3957    /// * `accountId` - Account ID for the custom dimension to retrieve.
3958    /// * `webPropertyId` - Web property ID for the custom dimension to retrieve.
3959    /// * `customDimensionId` - The ID of the custom dimension to retrieve.
3960    pub fn custom_dimensions_get(
3961        &self,
3962        account_id: &str,
3963        web_property_id: &str,
3964        custom_dimension_id: &str,
3965    ) -> ManagementCustomDimensionGetCall<'a, C> {
3966        ManagementCustomDimensionGetCall {
3967            hub: self.hub,
3968            _account_id: account_id.to_string(),
3969            _web_property_id: web_property_id.to_string(),
3970            _custom_dimension_id: custom_dimension_id.to_string(),
3971            _delegate: Default::default(),
3972            _additional_params: Default::default(),
3973            _scopes: Default::default(),
3974        }
3975    }
3976
3977    /// Create a builder to help you perform the following task:
3978    ///
3979    /// Create a new custom dimension.
3980    ///
3981    /// # Arguments
3982    ///
3983    /// * `request` - No description provided.
3984    /// * `accountId` - Account ID for the custom dimension to create.
3985    /// * `webPropertyId` - Web property ID for the custom dimension to create.
3986    pub fn custom_dimensions_insert(
3987        &self,
3988        request: CustomDimension,
3989        account_id: &str,
3990        web_property_id: &str,
3991    ) -> ManagementCustomDimensionInsertCall<'a, C> {
3992        ManagementCustomDimensionInsertCall {
3993            hub: self.hub,
3994            _request: request,
3995            _account_id: account_id.to_string(),
3996            _web_property_id: web_property_id.to_string(),
3997            _delegate: Default::default(),
3998            _additional_params: Default::default(),
3999            _scopes: Default::default(),
4000        }
4001    }
4002
4003    /// Create a builder to help you perform the following task:
4004    ///
4005    /// Lists custom dimensions to which the user has access.
4006    ///
4007    /// # Arguments
4008    ///
4009    /// * `accountId` - Account ID for the custom dimensions to retrieve.
4010    /// * `webPropertyId` - Web property ID for the custom dimensions to retrieve.
4011    pub fn custom_dimensions_list(
4012        &self,
4013        account_id: &str,
4014        web_property_id: &str,
4015    ) -> ManagementCustomDimensionListCall<'a, C> {
4016        ManagementCustomDimensionListCall {
4017            hub: self.hub,
4018            _account_id: account_id.to_string(),
4019            _web_property_id: web_property_id.to_string(),
4020            _start_index: Default::default(),
4021            _max_results: Default::default(),
4022            _delegate: Default::default(),
4023            _additional_params: Default::default(),
4024            _scopes: Default::default(),
4025        }
4026    }
4027
4028    /// Create a builder to help you perform the following task:
4029    ///
4030    /// Updates an existing custom dimension. This method supports patch semantics.
4031    ///
4032    /// # Arguments
4033    ///
4034    /// * `request` - No description provided.
4035    /// * `accountId` - Account ID for the custom dimension to update.
4036    /// * `webPropertyId` - Web property ID for the custom dimension to update.
4037    /// * `customDimensionId` - Custom dimension ID for the custom dimension to update.
4038    pub fn custom_dimensions_patch(
4039        &self,
4040        request: CustomDimension,
4041        account_id: &str,
4042        web_property_id: &str,
4043        custom_dimension_id: &str,
4044    ) -> ManagementCustomDimensionPatchCall<'a, C> {
4045        ManagementCustomDimensionPatchCall {
4046            hub: self.hub,
4047            _request: request,
4048            _account_id: account_id.to_string(),
4049            _web_property_id: web_property_id.to_string(),
4050            _custom_dimension_id: custom_dimension_id.to_string(),
4051            _ignore_custom_data_source_links: Default::default(),
4052            _delegate: Default::default(),
4053            _additional_params: Default::default(),
4054            _scopes: Default::default(),
4055        }
4056    }
4057
4058    /// Create a builder to help you perform the following task:
4059    ///
4060    /// Updates an existing custom dimension.
4061    ///
4062    /// # Arguments
4063    ///
4064    /// * `request` - No description provided.
4065    /// * `accountId` - Account ID for the custom dimension to update.
4066    /// * `webPropertyId` - Web property ID for the custom dimension to update.
4067    /// * `customDimensionId` - Custom dimension ID for the custom dimension to update.
4068    pub fn custom_dimensions_update(
4069        &self,
4070        request: CustomDimension,
4071        account_id: &str,
4072        web_property_id: &str,
4073        custom_dimension_id: &str,
4074    ) -> ManagementCustomDimensionUpdateCall<'a, C> {
4075        ManagementCustomDimensionUpdateCall {
4076            hub: self.hub,
4077            _request: request,
4078            _account_id: account_id.to_string(),
4079            _web_property_id: web_property_id.to_string(),
4080            _custom_dimension_id: custom_dimension_id.to_string(),
4081            _ignore_custom_data_source_links: Default::default(),
4082            _delegate: Default::default(),
4083            _additional_params: Default::default(),
4084            _scopes: Default::default(),
4085        }
4086    }
4087
4088    /// Create a builder to help you perform the following task:
4089    ///
4090    /// Get a custom metric to which the user has access.
4091    ///
4092    /// # Arguments
4093    ///
4094    /// * `accountId` - Account ID for the custom metric to retrieve.
4095    /// * `webPropertyId` - Web property ID for the custom metric to retrieve.
4096    /// * `customMetricId` - The ID of the custom metric to retrieve.
4097    pub fn custom_metrics_get(
4098        &self,
4099        account_id: &str,
4100        web_property_id: &str,
4101        custom_metric_id: &str,
4102    ) -> ManagementCustomMetricGetCall<'a, C> {
4103        ManagementCustomMetricGetCall {
4104            hub: self.hub,
4105            _account_id: account_id.to_string(),
4106            _web_property_id: web_property_id.to_string(),
4107            _custom_metric_id: custom_metric_id.to_string(),
4108            _delegate: Default::default(),
4109            _additional_params: Default::default(),
4110            _scopes: Default::default(),
4111        }
4112    }
4113
4114    /// Create a builder to help you perform the following task:
4115    ///
4116    /// Create a new custom metric.
4117    ///
4118    /// # Arguments
4119    ///
4120    /// * `request` - No description provided.
4121    /// * `accountId` - Account ID for the custom metric to create.
4122    /// * `webPropertyId` - Web property ID for the custom dimension to create.
4123    pub fn custom_metrics_insert(
4124        &self,
4125        request: CustomMetric,
4126        account_id: &str,
4127        web_property_id: &str,
4128    ) -> ManagementCustomMetricInsertCall<'a, C> {
4129        ManagementCustomMetricInsertCall {
4130            hub: self.hub,
4131            _request: request,
4132            _account_id: account_id.to_string(),
4133            _web_property_id: web_property_id.to_string(),
4134            _delegate: Default::default(),
4135            _additional_params: Default::default(),
4136            _scopes: Default::default(),
4137        }
4138    }
4139
4140    /// Create a builder to help you perform the following task:
4141    ///
4142    /// Lists custom metrics to which the user has access.
4143    ///
4144    /// # Arguments
4145    ///
4146    /// * `accountId` - Account ID for the custom metrics to retrieve.
4147    /// * `webPropertyId` - Web property ID for the custom metrics to retrieve.
4148    pub fn custom_metrics_list(
4149        &self,
4150        account_id: &str,
4151        web_property_id: &str,
4152    ) -> ManagementCustomMetricListCall<'a, C> {
4153        ManagementCustomMetricListCall {
4154            hub: self.hub,
4155            _account_id: account_id.to_string(),
4156            _web_property_id: web_property_id.to_string(),
4157            _start_index: Default::default(),
4158            _max_results: Default::default(),
4159            _delegate: Default::default(),
4160            _additional_params: Default::default(),
4161            _scopes: Default::default(),
4162        }
4163    }
4164
4165    /// Create a builder to help you perform the following task:
4166    ///
4167    /// Updates an existing custom metric. This method supports patch semantics.
4168    ///
4169    /// # Arguments
4170    ///
4171    /// * `request` - No description provided.
4172    /// * `accountId` - Account ID for the custom metric to update.
4173    /// * `webPropertyId` - Web property ID for the custom metric to update.
4174    /// * `customMetricId` - Custom metric ID for the custom metric to update.
4175    pub fn custom_metrics_patch(
4176        &self,
4177        request: CustomMetric,
4178        account_id: &str,
4179        web_property_id: &str,
4180        custom_metric_id: &str,
4181    ) -> ManagementCustomMetricPatchCall<'a, C> {
4182        ManagementCustomMetricPatchCall {
4183            hub: self.hub,
4184            _request: request,
4185            _account_id: account_id.to_string(),
4186            _web_property_id: web_property_id.to_string(),
4187            _custom_metric_id: custom_metric_id.to_string(),
4188            _ignore_custom_data_source_links: Default::default(),
4189            _delegate: Default::default(),
4190            _additional_params: Default::default(),
4191            _scopes: Default::default(),
4192        }
4193    }
4194
4195    /// Create a builder to help you perform the following task:
4196    ///
4197    /// Updates an existing custom metric.
4198    ///
4199    /// # Arguments
4200    ///
4201    /// * `request` - No description provided.
4202    /// * `accountId` - Account ID for the custom metric to update.
4203    /// * `webPropertyId` - Web property ID for the custom metric to update.
4204    /// * `customMetricId` - Custom metric ID for the custom metric to update.
4205    pub fn custom_metrics_update(
4206        &self,
4207        request: CustomMetric,
4208        account_id: &str,
4209        web_property_id: &str,
4210        custom_metric_id: &str,
4211    ) -> ManagementCustomMetricUpdateCall<'a, C> {
4212        ManagementCustomMetricUpdateCall {
4213            hub: self.hub,
4214            _request: request,
4215            _account_id: account_id.to_string(),
4216            _web_property_id: web_property_id.to_string(),
4217            _custom_metric_id: custom_metric_id.to_string(),
4218            _ignore_custom_data_source_links: Default::default(),
4219            _delegate: Default::default(),
4220            _additional_params: Default::default(),
4221            _scopes: Default::default(),
4222        }
4223    }
4224
4225    /// Create a builder to help you perform the following task:
4226    ///
4227    /// Delete an experiment.
4228    ///
4229    /// # Arguments
4230    ///
4231    /// * `accountId` - Account ID to which the experiment belongs
4232    /// * `webPropertyId` - Web property ID to which the experiment belongs
4233    /// * `profileId` - View (Profile) ID to which the experiment belongs
4234    /// * `experimentId` - ID of the experiment to delete
4235    pub fn experiments_delete(
4236        &self,
4237        account_id: &str,
4238        web_property_id: &str,
4239        profile_id: &str,
4240        experiment_id: &str,
4241    ) -> ManagementExperimentDeleteCall<'a, C> {
4242        ManagementExperimentDeleteCall {
4243            hub: self.hub,
4244            _account_id: account_id.to_string(),
4245            _web_property_id: web_property_id.to_string(),
4246            _profile_id: profile_id.to_string(),
4247            _experiment_id: experiment_id.to_string(),
4248            _delegate: Default::default(),
4249            _additional_params: Default::default(),
4250            _scopes: Default::default(),
4251        }
4252    }
4253
4254    /// Create a builder to help you perform the following task:
4255    ///
4256    /// Returns an experiment to which the user has access.
4257    ///
4258    /// # Arguments
4259    ///
4260    /// * `accountId` - Account ID to retrieve the experiment for.
4261    /// * `webPropertyId` - Web property ID to retrieve the experiment for.
4262    /// * `profileId` - View (Profile) ID to retrieve the experiment for.
4263    /// * `experimentId` - Experiment ID to retrieve the experiment for.
4264    pub fn experiments_get(
4265        &self,
4266        account_id: &str,
4267        web_property_id: &str,
4268        profile_id: &str,
4269        experiment_id: &str,
4270    ) -> ManagementExperimentGetCall<'a, C> {
4271        ManagementExperimentGetCall {
4272            hub: self.hub,
4273            _account_id: account_id.to_string(),
4274            _web_property_id: web_property_id.to_string(),
4275            _profile_id: profile_id.to_string(),
4276            _experiment_id: experiment_id.to_string(),
4277            _delegate: Default::default(),
4278            _additional_params: Default::default(),
4279            _scopes: Default::default(),
4280        }
4281    }
4282
4283    /// Create a builder to help you perform the following task:
4284    ///
4285    /// Create a new experiment.
4286    ///
4287    /// # Arguments
4288    ///
4289    /// * `request` - No description provided.
4290    /// * `accountId` - Account ID to create the experiment for.
4291    /// * `webPropertyId` - Web property ID to create the experiment for.
4292    /// * `profileId` - View (Profile) ID to create the experiment for.
4293    pub fn experiments_insert(
4294        &self,
4295        request: Experiment,
4296        account_id: &str,
4297        web_property_id: &str,
4298        profile_id: &str,
4299    ) -> ManagementExperimentInsertCall<'a, C> {
4300        ManagementExperimentInsertCall {
4301            hub: self.hub,
4302            _request: request,
4303            _account_id: account_id.to_string(),
4304            _web_property_id: web_property_id.to_string(),
4305            _profile_id: profile_id.to_string(),
4306            _delegate: Default::default(),
4307            _additional_params: Default::default(),
4308            _scopes: Default::default(),
4309        }
4310    }
4311
4312    /// Create a builder to help you perform the following task:
4313    ///
4314    /// Lists experiments to which the user has access.
4315    ///
4316    /// # Arguments
4317    ///
4318    /// * `accountId` - Account ID to retrieve experiments for.
4319    /// * `webPropertyId` - Web property ID to retrieve experiments for.
4320    /// * `profileId` - View (Profile) ID to retrieve experiments for.
4321    pub fn experiments_list(
4322        &self,
4323        account_id: &str,
4324        web_property_id: &str,
4325        profile_id: &str,
4326    ) -> ManagementExperimentListCall<'a, C> {
4327        ManagementExperimentListCall {
4328            hub: self.hub,
4329            _account_id: account_id.to_string(),
4330            _web_property_id: web_property_id.to_string(),
4331            _profile_id: profile_id.to_string(),
4332            _start_index: Default::default(),
4333            _max_results: Default::default(),
4334            _delegate: Default::default(),
4335            _additional_params: Default::default(),
4336            _scopes: Default::default(),
4337        }
4338    }
4339
4340    /// Create a builder to help you perform the following task:
4341    ///
4342    /// Update an existing experiment. This method supports patch semantics.
4343    ///
4344    /// # Arguments
4345    ///
4346    /// * `request` - No description provided.
4347    /// * `accountId` - Account ID of the experiment to update.
4348    /// * `webPropertyId` - Web property ID of the experiment to update.
4349    /// * `profileId` - View (Profile) ID of the experiment to update.
4350    /// * `experimentId` - Experiment ID of the experiment to update.
4351    pub fn experiments_patch(
4352        &self,
4353        request: Experiment,
4354        account_id: &str,
4355        web_property_id: &str,
4356        profile_id: &str,
4357        experiment_id: &str,
4358    ) -> ManagementExperimentPatchCall<'a, C> {
4359        ManagementExperimentPatchCall {
4360            hub: self.hub,
4361            _request: request,
4362            _account_id: account_id.to_string(),
4363            _web_property_id: web_property_id.to_string(),
4364            _profile_id: profile_id.to_string(),
4365            _experiment_id: experiment_id.to_string(),
4366            _delegate: Default::default(),
4367            _additional_params: Default::default(),
4368            _scopes: Default::default(),
4369        }
4370    }
4371
4372    /// Create a builder to help you perform the following task:
4373    ///
4374    /// Update an existing experiment.
4375    ///
4376    /// # Arguments
4377    ///
4378    /// * `request` - No description provided.
4379    /// * `accountId` - Account ID of the experiment to update.
4380    /// * `webPropertyId` - Web property ID of the experiment to update.
4381    /// * `profileId` - View (Profile) ID of the experiment to update.
4382    /// * `experimentId` - Experiment ID of the experiment to update.
4383    pub fn experiments_update(
4384        &self,
4385        request: Experiment,
4386        account_id: &str,
4387        web_property_id: &str,
4388        profile_id: &str,
4389        experiment_id: &str,
4390    ) -> ManagementExperimentUpdateCall<'a, C> {
4391        ManagementExperimentUpdateCall {
4392            hub: self.hub,
4393            _request: request,
4394            _account_id: account_id.to_string(),
4395            _web_property_id: web_property_id.to_string(),
4396            _profile_id: profile_id.to_string(),
4397            _experiment_id: experiment_id.to_string(),
4398            _delegate: Default::default(),
4399            _additional_params: Default::default(),
4400            _scopes: Default::default(),
4401        }
4402    }
4403
4404    /// Create a builder to help you perform the following task:
4405    ///
4406    /// Delete a filter.
4407    ///
4408    /// # Arguments
4409    ///
4410    /// * `accountId` - Account ID to delete the filter for.
4411    /// * `filterId` - ID of the filter to be deleted.
4412    pub fn filters_delete(
4413        &self,
4414        account_id: &str,
4415        filter_id: &str,
4416    ) -> ManagementFilterDeleteCall<'a, C> {
4417        ManagementFilterDeleteCall {
4418            hub: self.hub,
4419            _account_id: account_id.to_string(),
4420            _filter_id: filter_id.to_string(),
4421            _delegate: Default::default(),
4422            _additional_params: Default::default(),
4423            _scopes: Default::default(),
4424        }
4425    }
4426
4427    /// Create a builder to help you perform the following task:
4428    ///
4429    /// Returns filters to which the user has access.
4430    ///
4431    /// # Arguments
4432    ///
4433    /// * `accountId` - Account ID to retrieve filters for.
4434    /// * `filterId` - Filter ID to retrieve filters for.
4435    pub fn filters_get(&self, account_id: &str, filter_id: &str) -> ManagementFilterGetCall<'a, C> {
4436        ManagementFilterGetCall {
4437            hub: self.hub,
4438            _account_id: account_id.to_string(),
4439            _filter_id: filter_id.to_string(),
4440            _delegate: Default::default(),
4441            _additional_params: Default::default(),
4442            _scopes: Default::default(),
4443        }
4444    }
4445
4446    /// Create a builder to help you perform the following task:
4447    ///
4448    /// Create a new filter.
4449    ///
4450    /// # Arguments
4451    ///
4452    /// * `request` - No description provided.
4453    /// * `accountId` - Account ID to create filter for.
4454    pub fn filters_insert(
4455        &self,
4456        request: Filter,
4457        account_id: &str,
4458    ) -> ManagementFilterInsertCall<'a, C> {
4459        ManagementFilterInsertCall {
4460            hub: self.hub,
4461            _request: request,
4462            _account_id: account_id.to_string(),
4463            _delegate: Default::default(),
4464            _additional_params: Default::default(),
4465            _scopes: Default::default(),
4466        }
4467    }
4468
4469    /// Create a builder to help you perform the following task:
4470    ///
4471    /// Lists all filters for an account
4472    ///
4473    /// # Arguments
4474    ///
4475    /// * `accountId` - Account ID to retrieve filters for.
4476    pub fn filters_list(&self, account_id: &str) -> ManagementFilterListCall<'a, C> {
4477        ManagementFilterListCall {
4478            hub: self.hub,
4479            _account_id: account_id.to_string(),
4480            _start_index: Default::default(),
4481            _max_results: Default::default(),
4482            _delegate: Default::default(),
4483            _additional_params: Default::default(),
4484            _scopes: Default::default(),
4485        }
4486    }
4487
4488    /// Create a builder to help you perform the following task:
4489    ///
4490    /// Updates an existing filter. This method supports patch semantics.
4491    ///
4492    /// # Arguments
4493    ///
4494    /// * `request` - No description provided.
4495    /// * `accountId` - Account ID to which the filter belongs.
4496    /// * `filterId` - ID of the filter to be updated.
4497    pub fn filters_patch(
4498        &self,
4499        request: Filter,
4500        account_id: &str,
4501        filter_id: &str,
4502    ) -> ManagementFilterPatchCall<'a, C> {
4503        ManagementFilterPatchCall {
4504            hub: self.hub,
4505            _request: request,
4506            _account_id: account_id.to_string(),
4507            _filter_id: filter_id.to_string(),
4508            _delegate: Default::default(),
4509            _additional_params: Default::default(),
4510            _scopes: Default::default(),
4511        }
4512    }
4513
4514    /// Create a builder to help you perform the following task:
4515    ///
4516    /// Updates an existing filter.
4517    ///
4518    /// # Arguments
4519    ///
4520    /// * `request` - No description provided.
4521    /// * `accountId` - Account ID to which the filter belongs.
4522    /// * `filterId` - ID of the filter to be updated.
4523    pub fn filters_update(
4524        &self,
4525        request: Filter,
4526        account_id: &str,
4527        filter_id: &str,
4528    ) -> ManagementFilterUpdateCall<'a, C> {
4529        ManagementFilterUpdateCall {
4530            hub: self.hub,
4531            _request: request,
4532            _account_id: account_id.to_string(),
4533            _filter_id: filter_id.to_string(),
4534            _delegate: Default::default(),
4535            _additional_params: Default::default(),
4536            _scopes: Default::default(),
4537        }
4538    }
4539
4540    /// Create a builder to help you perform the following task:
4541    ///
4542    /// Gets a goal to which the user has access.
4543    ///
4544    /// # Arguments
4545    ///
4546    /// * `accountId` - Account ID to retrieve the goal for.
4547    /// * `webPropertyId` - Web property ID to retrieve the goal for.
4548    /// * `profileId` - View (Profile) ID to retrieve the goal for.
4549    /// * `goalId` - Goal ID to retrieve the goal for.
4550    pub fn goals_get(
4551        &self,
4552        account_id: &str,
4553        web_property_id: &str,
4554        profile_id: &str,
4555        goal_id: &str,
4556    ) -> ManagementGoalGetCall<'a, C> {
4557        ManagementGoalGetCall {
4558            hub: self.hub,
4559            _account_id: account_id.to_string(),
4560            _web_property_id: web_property_id.to_string(),
4561            _profile_id: profile_id.to_string(),
4562            _goal_id: goal_id.to_string(),
4563            _delegate: Default::default(),
4564            _additional_params: Default::default(),
4565            _scopes: Default::default(),
4566        }
4567    }
4568
4569    /// Create a builder to help you perform the following task:
4570    ///
4571    /// Create a new goal.
4572    ///
4573    /// # Arguments
4574    ///
4575    /// * `request` - No description provided.
4576    /// * `accountId` - Account ID to create the goal for.
4577    /// * `webPropertyId` - Web property ID to create the goal for.
4578    /// * `profileId` - View (Profile) ID to create the goal for.
4579    pub fn goals_insert(
4580        &self,
4581        request: Goal,
4582        account_id: &str,
4583        web_property_id: &str,
4584        profile_id: &str,
4585    ) -> ManagementGoalInsertCall<'a, C> {
4586        ManagementGoalInsertCall {
4587            hub: self.hub,
4588            _request: request,
4589            _account_id: account_id.to_string(),
4590            _web_property_id: web_property_id.to_string(),
4591            _profile_id: profile_id.to_string(),
4592            _delegate: Default::default(),
4593            _additional_params: Default::default(),
4594            _scopes: Default::default(),
4595        }
4596    }
4597
4598    /// Create a builder to help you perform the following task:
4599    ///
4600    /// Lists goals to which the user has access.
4601    ///
4602    /// # Arguments
4603    ///
4604    /// * `accountId` - Account ID to retrieve goals for. Can either be a specific account ID or '~all', which refers to all the accounts that user has access to.
4605    /// * `webPropertyId` - Web property ID to retrieve goals for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
4606    /// * `profileId` - View (Profile) ID to retrieve goals for. Can either be a specific view (profile) ID or '~all', which refers to all the views (profiles) that user has access to.
4607    pub fn goals_list(
4608        &self,
4609        account_id: &str,
4610        web_property_id: &str,
4611        profile_id: &str,
4612    ) -> ManagementGoalListCall<'a, C> {
4613        ManagementGoalListCall {
4614            hub: self.hub,
4615            _account_id: account_id.to_string(),
4616            _web_property_id: web_property_id.to_string(),
4617            _profile_id: profile_id.to_string(),
4618            _start_index: Default::default(),
4619            _max_results: Default::default(),
4620            _delegate: Default::default(),
4621            _additional_params: Default::default(),
4622            _scopes: Default::default(),
4623        }
4624    }
4625
4626    /// Create a builder to help you perform the following task:
4627    ///
4628    /// Updates an existing goal. This method supports patch semantics.
4629    ///
4630    /// # Arguments
4631    ///
4632    /// * `request` - No description provided.
4633    /// * `accountId` - Account ID to update the goal.
4634    /// * `webPropertyId` - Web property ID to update the goal.
4635    /// * `profileId` - View (Profile) ID to update the goal.
4636    /// * `goalId` - Index of the goal to be updated.
4637    pub fn goals_patch(
4638        &self,
4639        request: Goal,
4640        account_id: &str,
4641        web_property_id: &str,
4642        profile_id: &str,
4643        goal_id: &str,
4644    ) -> ManagementGoalPatchCall<'a, C> {
4645        ManagementGoalPatchCall {
4646            hub: self.hub,
4647            _request: request,
4648            _account_id: account_id.to_string(),
4649            _web_property_id: web_property_id.to_string(),
4650            _profile_id: profile_id.to_string(),
4651            _goal_id: goal_id.to_string(),
4652            _delegate: Default::default(),
4653            _additional_params: Default::default(),
4654            _scopes: Default::default(),
4655        }
4656    }
4657
4658    /// Create a builder to help you perform the following task:
4659    ///
4660    /// Updates an existing goal.
4661    ///
4662    /// # Arguments
4663    ///
4664    /// * `request` - No description provided.
4665    /// * `accountId` - Account ID to update the goal.
4666    /// * `webPropertyId` - Web property ID to update the goal.
4667    /// * `profileId` - View (Profile) ID to update the goal.
4668    /// * `goalId` - Index of the goal to be updated.
4669    pub fn goals_update(
4670        &self,
4671        request: Goal,
4672        account_id: &str,
4673        web_property_id: &str,
4674        profile_id: &str,
4675        goal_id: &str,
4676    ) -> ManagementGoalUpdateCall<'a, C> {
4677        ManagementGoalUpdateCall {
4678            hub: self.hub,
4679            _request: request,
4680            _account_id: account_id.to_string(),
4681            _web_property_id: web_property_id.to_string(),
4682            _profile_id: profile_id.to_string(),
4683            _goal_id: goal_id.to_string(),
4684            _delegate: Default::default(),
4685            _additional_params: Default::default(),
4686            _scopes: Default::default(),
4687        }
4688    }
4689
4690    /// Create a builder to help you perform the following task:
4691    ///
4692    /// Delete a profile filter link.
4693    ///
4694    /// # Arguments
4695    ///
4696    /// * `accountId` - Account ID to which the profile filter link belongs.
4697    /// * `webPropertyId` - Web property Id to which the profile filter link belongs.
4698    /// * `profileId` - Profile ID to which the filter link belongs.
4699    /// * `linkId` - ID of the profile filter link to delete.
4700    pub fn profile_filter_links_delete(
4701        &self,
4702        account_id: &str,
4703        web_property_id: &str,
4704        profile_id: &str,
4705        link_id: &str,
4706    ) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
4707        ManagementProfileFilterLinkDeleteCall {
4708            hub: self.hub,
4709            _account_id: account_id.to_string(),
4710            _web_property_id: web_property_id.to_string(),
4711            _profile_id: profile_id.to_string(),
4712            _link_id: link_id.to_string(),
4713            _delegate: Default::default(),
4714            _additional_params: Default::default(),
4715            _scopes: Default::default(),
4716        }
4717    }
4718
4719    /// Create a builder to help you perform the following task:
4720    ///
4721    /// Returns a single profile filter link.
4722    ///
4723    /// # Arguments
4724    ///
4725    /// * `accountId` - Account ID to retrieve profile filter link for.
4726    /// * `webPropertyId` - Web property Id to retrieve profile filter link for.
4727    /// * `profileId` - Profile ID to retrieve filter link for.
4728    /// * `linkId` - ID of the profile filter link.
4729    pub fn profile_filter_links_get(
4730        &self,
4731        account_id: &str,
4732        web_property_id: &str,
4733        profile_id: &str,
4734        link_id: &str,
4735    ) -> ManagementProfileFilterLinkGetCall<'a, C> {
4736        ManagementProfileFilterLinkGetCall {
4737            hub: self.hub,
4738            _account_id: account_id.to_string(),
4739            _web_property_id: web_property_id.to_string(),
4740            _profile_id: profile_id.to_string(),
4741            _link_id: link_id.to_string(),
4742            _delegate: Default::default(),
4743            _additional_params: Default::default(),
4744            _scopes: Default::default(),
4745        }
4746    }
4747
4748    /// Create a builder to help you perform the following task:
4749    ///
4750    /// Create a new profile filter link.
4751    ///
4752    /// # Arguments
4753    ///
4754    /// * `request` - No description provided.
4755    /// * `accountId` - Account ID to create profile filter link for.
4756    /// * `webPropertyId` - Web property Id to create profile filter link for.
4757    /// * `profileId` - Profile ID to create filter link for.
4758    pub fn profile_filter_links_insert(
4759        &self,
4760        request: ProfileFilterLink,
4761        account_id: &str,
4762        web_property_id: &str,
4763        profile_id: &str,
4764    ) -> ManagementProfileFilterLinkInsertCall<'a, C> {
4765        ManagementProfileFilterLinkInsertCall {
4766            hub: self.hub,
4767            _request: request,
4768            _account_id: account_id.to_string(),
4769            _web_property_id: web_property_id.to_string(),
4770            _profile_id: profile_id.to_string(),
4771            _delegate: Default::default(),
4772            _additional_params: Default::default(),
4773            _scopes: Default::default(),
4774        }
4775    }
4776
4777    /// Create a builder to help you perform the following task:
4778    ///
4779    /// Lists all profile filter links for a profile.
4780    ///
4781    /// # Arguments
4782    ///
4783    /// * `accountId` - Account ID to retrieve profile filter links for.
4784    /// * `webPropertyId` - Web property Id for profile filter links for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
4785    /// * `profileId` - Profile ID to retrieve filter links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to.
4786    pub fn profile_filter_links_list(
4787        &self,
4788        account_id: &str,
4789        web_property_id: &str,
4790        profile_id: &str,
4791    ) -> ManagementProfileFilterLinkListCall<'a, C> {
4792        ManagementProfileFilterLinkListCall {
4793            hub: self.hub,
4794            _account_id: account_id.to_string(),
4795            _web_property_id: web_property_id.to_string(),
4796            _profile_id: profile_id.to_string(),
4797            _start_index: Default::default(),
4798            _max_results: Default::default(),
4799            _delegate: Default::default(),
4800            _additional_params: Default::default(),
4801            _scopes: Default::default(),
4802        }
4803    }
4804
4805    /// Create a builder to help you perform the following task:
4806    ///
4807    /// Update an existing profile filter link. This method supports patch semantics.
4808    ///
4809    /// # Arguments
4810    ///
4811    /// * `request` - No description provided.
4812    /// * `accountId` - Account ID to which profile filter link belongs.
4813    /// * `webPropertyId` - Web property Id to which profile filter link belongs
4814    /// * `profileId` - Profile ID to which filter link belongs
4815    /// * `linkId` - ID of the profile filter link to be updated.
4816    pub fn profile_filter_links_patch(
4817        &self,
4818        request: ProfileFilterLink,
4819        account_id: &str,
4820        web_property_id: &str,
4821        profile_id: &str,
4822        link_id: &str,
4823    ) -> ManagementProfileFilterLinkPatchCall<'a, C> {
4824        ManagementProfileFilterLinkPatchCall {
4825            hub: self.hub,
4826            _request: request,
4827            _account_id: account_id.to_string(),
4828            _web_property_id: web_property_id.to_string(),
4829            _profile_id: profile_id.to_string(),
4830            _link_id: link_id.to_string(),
4831            _delegate: Default::default(),
4832            _additional_params: Default::default(),
4833            _scopes: Default::default(),
4834        }
4835    }
4836
4837    /// Create a builder to help you perform the following task:
4838    ///
4839    /// Update an existing profile filter link.
4840    ///
4841    /// # Arguments
4842    ///
4843    /// * `request` - No description provided.
4844    /// * `accountId` - Account ID to which profile filter link belongs.
4845    /// * `webPropertyId` - Web property Id to which profile filter link belongs
4846    /// * `profileId` - Profile ID to which filter link belongs
4847    /// * `linkId` - ID of the profile filter link to be updated.
4848    pub fn profile_filter_links_update(
4849        &self,
4850        request: ProfileFilterLink,
4851        account_id: &str,
4852        web_property_id: &str,
4853        profile_id: &str,
4854        link_id: &str,
4855    ) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
4856        ManagementProfileFilterLinkUpdateCall {
4857            hub: self.hub,
4858            _request: request,
4859            _account_id: account_id.to_string(),
4860            _web_property_id: web_property_id.to_string(),
4861            _profile_id: profile_id.to_string(),
4862            _link_id: link_id.to_string(),
4863            _delegate: Default::default(),
4864            _additional_params: Default::default(),
4865            _scopes: Default::default(),
4866        }
4867    }
4868
4869    /// Create a builder to help you perform the following task:
4870    ///
4871    /// Removes a user from the given view (profile).
4872    ///
4873    /// # Arguments
4874    ///
4875    /// * `accountId` - Account ID to delete the user link for.
4876    /// * `webPropertyId` - Web Property ID to delete the user link for.
4877    /// * `profileId` - View (Profile) ID to delete the user link for.
4878    /// * `linkId` - Link ID to delete the user link for.
4879    pub fn profile_user_links_delete(
4880        &self,
4881        account_id: &str,
4882        web_property_id: &str,
4883        profile_id: &str,
4884        link_id: &str,
4885    ) -> ManagementProfileUserLinkDeleteCall<'a, C> {
4886        ManagementProfileUserLinkDeleteCall {
4887            hub: self.hub,
4888            _account_id: account_id.to_string(),
4889            _web_property_id: web_property_id.to_string(),
4890            _profile_id: profile_id.to_string(),
4891            _link_id: link_id.to_string(),
4892            _delegate: Default::default(),
4893            _additional_params: Default::default(),
4894            _scopes: Default::default(),
4895        }
4896    }
4897
4898    /// Create a builder to help you perform the following task:
4899    ///
4900    /// Adds a new user to the given view (profile).
4901    ///
4902    /// # Arguments
4903    ///
4904    /// * `request` - No description provided.
4905    /// * `accountId` - Account ID to create the user link for.
4906    /// * `webPropertyId` - Web Property ID to create the user link for.
4907    /// * `profileId` - View (Profile) ID to create the user link for.
4908    pub fn profile_user_links_insert(
4909        &self,
4910        request: EntityUserLink,
4911        account_id: &str,
4912        web_property_id: &str,
4913        profile_id: &str,
4914    ) -> ManagementProfileUserLinkInsertCall<'a, C> {
4915        ManagementProfileUserLinkInsertCall {
4916            hub: self.hub,
4917            _request: request,
4918            _account_id: account_id.to_string(),
4919            _web_property_id: web_property_id.to_string(),
4920            _profile_id: profile_id.to_string(),
4921            _delegate: Default::default(),
4922            _additional_params: Default::default(),
4923            _scopes: Default::default(),
4924        }
4925    }
4926
4927    /// Create a builder to help you perform the following task:
4928    ///
4929    /// Lists profile-user links for a given view (profile).
4930    ///
4931    /// # Arguments
4932    ///
4933    /// * `accountId` - Account ID which the given view (profile) belongs to.
4934    /// * `webPropertyId` - Web Property ID which the given view (profile) belongs to. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
4935    /// * `profileId` - View (Profile) ID to retrieve the profile-user links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to.
4936    pub fn profile_user_links_list(
4937        &self,
4938        account_id: &str,
4939        web_property_id: &str,
4940        profile_id: &str,
4941    ) -> ManagementProfileUserLinkListCall<'a, C> {
4942        ManagementProfileUserLinkListCall {
4943            hub: self.hub,
4944            _account_id: account_id.to_string(),
4945            _web_property_id: web_property_id.to_string(),
4946            _profile_id: profile_id.to_string(),
4947            _start_index: Default::default(),
4948            _max_results: Default::default(),
4949            _delegate: Default::default(),
4950            _additional_params: Default::default(),
4951            _scopes: Default::default(),
4952        }
4953    }
4954
4955    /// Create a builder to help you perform the following task:
4956    ///
4957    /// Updates permissions for an existing user on the given view (profile).
4958    ///
4959    /// # Arguments
4960    ///
4961    /// * `request` - No description provided.
4962    /// * `accountId` - Account ID to update the user link for.
4963    /// * `webPropertyId` - Web Property ID to update the user link for.
4964    /// * `profileId` - View (Profile ID) to update the user link for.
4965    /// * `linkId` - Link ID to update the user link for.
4966    pub fn profile_user_links_update(
4967        &self,
4968        request: EntityUserLink,
4969        account_id: &str,
4970        web_property_id: &str,
4971        profile_id: &str,
4972        link_id: &str,
4973    ) -> ManagementProfileUserLinkUpdateCall<'a, C> {
4974        ManagementProfileUserLinkUpdateCall {
4975            hub: self.hub,
4976            _request: request,
4977            _account_id: account_id.to_string(),
4978            _web_property_id: web_property_id.to_string(),
4979            _profile_id: profile_id.to_string(),
4980            _link_id: link_id.to_string(),
4981            _delegate: Default::default(),
4982            _additional_params: Default::default(),
4983            _scopes: Default::default(),
4984        }
4985    }
4986
4987    /// Create a builder to help you perform the following task:
4988    ///
4989    /// Deletes a view (profile).
4990    ///
4991    /// # Arguments
4992    ///
4993    /// * `accountId` - Account ID to delete the view (profile) for.
4994    /// * `webPropertyId` - Web property ID to delete the view (profile) for.
4995    /// * `profileId` - ID of the view (profile) to be deleted.
4996    pub fn profiles_delete(
4997        &self,
4998        account_id: &str,
4999        web_property_id: &str,
5000        profile_id: &str,
5001    ) -> ManagementProfileDeleteCall<'a, C> {
5002        ManagementProfileDeleteCall {
5003            hub: self.hub,
5004            _account_id: account_id.to_string(),
5005            _web_property_id: web_property_id.to_string(),
5006            _profile_id: profile_id.to_string(),
5007            _delegate: Default::default(),
5008            _additional_params: Default::default(),
5009            _scopes: Default::default(),
5010        }
5011    }
5012
5013    /// Create a builder to help you perform the following task:
5014    ///
5015    /// Gets a view (profile) to which the user has access.
5016    ///
5017    /// # Arguments
5018    ///
5019    /// * `accountId` - Account ID to retrieve the view (profile) for.
5020    /// * `webPropertyId` - Web property ID to retrieve the view (profile) for.
5021    /// * `profileId` - View (Profile) ID to retrieve the view (profile) for.
5022    pub fn profiles_get(
5023        &self,
5024        account_id: &str,
5025        web_property_id: &str,
5026        profile_id: &str,
5027    ) -> ManagementProfileGetCall<'a, C> {
5028        ManagementProfileGetCall {
5029            hub: self.hub,
5030            _account_id: account_id.to_string(),
5031            _web_property_id: web_property_id.to_string(),
5032            _profile_id: profile_id.to_string(),
5033            _delegate: Default::default(),
5034            _additional_params: Default::default(),
5035            _scopes: Default::default(),
5036        }
5037    }
5038
5039    /// Create a builder to help you perform the following task:
5040    ///
5041    /// Create a new view (profile).
5042    ///
5043    /// # Arguments
5044    ///
5045    /// * `request` - No description provided.
5046    /// * `accountId` - Account ID to create the view (profile) for.
5047    /// * `webPropertyId` - Web property ID to create the view (profile) for.
5048    pub fn profiles_insert(
5049        &self,
5050        request: Profile,
5051        account_id: &str,
5052        web_property_id: &str,
5053    ) -> ManagementProfileInsertCall<'a, C> {
5054        ManagementProfileInsertCall {
5055            hub: self.hub,
5056            _request: request,
5057            _account_id: account_id.to_string(),
5058            _web_property_id: web_property_id.to_string(),
5059            _delegate: Default::default(),
5060            _additional_params: Default::default(),
5061            _scopes: Default::default(),
5062        }
5063    }
5064
5065    /// Create a builder to help you perform the following task:
5066    ///
5067    /// Lists views (profiles) to which the user has access.
5068    ///
5069    /// # Arguments
5070    ///
5071    /// * `accountId` - Account ID for the view (profiles) to retrieve. Can either be a specific account ID or '~all', which refers to all the accounts to which the user has access.
5072    /// * `webPropertyId` - Web property ID for the views (profiles) to retrieve. Can either be a specific web property ID or '~all', which refers to all the web properties to which the user has access.
5073    pub fn profiles_list(
5074        &self,
5075        account_id: &str,
5076        web_property_id: &str,
5077    ) -> ManagementProfileListCall<'a, C> {
5078        ManagementProfileListCall {
5079            hub: self.hub,
5080            _account_id: account_id.to_string(),
5081            _web_property_id: web_property_id.to_string(),
5082            _start_index: Default::default(),
5083            _max_results: Default::default(),
5084            _delegate: Default::default(),
5085            _additional_params: Default::default(),
5086            _scopes: Default::default(),
5087        }
5088    }
5089
5090    /// Create a builder to help you perform the following task:
5091    ///
5092    /// Updates an existing view (profile). This method supports patch semantics.
5093    ///
5094    /// # Arguments
5095    ///
5096    /// * `request` - No description provided.
5097    /// * `accountId` - Account ID to which the view (profile) belongs
5098    /// * `webPropertyId` - Web property ID to which the view (profile) belongs
5099    /// * `profileId` - ID of the view (profile) to be updated.
5100    pub fn profiles_patch(
5101        &self,
5102        request: Profile,
5103        account_id: &str,
5104        web_property_id: &str,
5105        profile_id: &str,
5106    ) -> ManagementProfilePatchCall<'a, C> {
5107        ManagementProfilePatchCall {
5108            hub: self.hub,
5109            _request: request,
5110            _account_id: account_id.to_string(),
5111            _web_property_id: web_property_id.to_string(),
5112            _profile_id: profile_id.to_string(),
5113            _delegate: Default::default(),
5114            _additional_params: Default::default(),
5115            _scopes: Default::default(),
5116        }
5117    }
5118
5119    /// Create a builder to help you perform the following task:
5120    ///
5121    /// Updates an existing view (profile).
5122    ///
5123    /// # Arguments
5124    ///
5125    /// * `request` - No description provided.
5126    /// * `accountId` - Account ID to which the view (profile) belongs
5127    /// * `webPropertyId` - Web property ID to which the view (profile) belongs
5128    /// * `profileId` - ID of the view (profile) to be updated.
5129    pub fn profiles_update(
5130        &self,
5131        request: Profile,
5132        account_id: &str,
5133        web_property_id: &str,
5134        profile_id: &str,
5135    ) -> ManagementProfileUpdateCall<'a, C> {
5136        ManagementProfileUpdateCall {
5137            hub: self.hub,
5138            _request: request,
5139            _account_id: account_id.to_string(),
5140            _web_property_id: web_property_id.to_string(),
5141            _profile_id: profile_id.to_string(),
5142            _delegate: Default::default(),
5143            _additional_params: Default::default(),
5144            _scopes: Default::default(),
5145        }
5146    }
5147
5148    /// Create a builder to help you perform the following task:
5149    ///
5150    /// Delete a remarketing audience.
5151    ///
5152    /// # Arguments
5153    ///
5154    /// * `accountId` - Account ID to which the remarketing audience belongs.
5155    /// * `webPropertyId` - Web property ID to which the remarketing audience belongs.
5156    /// * `remarketingAudienceId` - The ID of the remarketing audience to delete.
5157    pub fn remarketing_audience_delete(
5158        &self,
5159        account_id: &str,
5160        web_property_id: &str,
5161        remarketing_audience_id: &str,
5162    ) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
5163        ManagementRemarketingAudienceDeleteCall {
5164            hub: self.hub,
5165            _account_id: account_id.to_string(),
5166            _web_property_id: web_property_id.to_string(),
5167            _remarketing_audience_id: remarketing_audience_id.to_string(),
5168            _delegate: Default::default(),
5169            _additional_params: Default::default(),
5170            _scopes: Default::default(),
5171        }
5172    }
5173
5174    /// Create a builder to help you perform the following task:
5175    ///
5176    /// Gets a remarketing audience to which the user has access.
5177    ///
5178    /// # Arguments
5179    ///
5180    /// * `accountId` - The account ID of the remarketing audience to retrieve.
5181    /// * `webPropertyId` - The web property ID of the remarketing audience to retrieve.
5182    /// * `remarketingAudienceId` - The ID of the remarketing audience to retrieve.
5183    pub fn remarketing_audience_get(
5184        &self,
5185        account_id: &str,
5186        web_property_id: &str,
5187        remarketing_audience_id: &str,
5188    ) -> ManagementRemarketingAudienceGetCall<'a, C> {
5189        ManagementRemarketingAudienceGetCall {
5190            hub: self.hub,
5191            _account_id: account_id.to_string(),
5192            _web_property_id: web_property_id.to_string(),
5193            _remarketing_audience_id: remarketing_audience_id.to_string(),
5194            _delegate: Default::default(),
5195            _additional_params: Default::default(),
5196            _scopes: Default::default(),
5197        }
5198    }
5199
5200    /// Create a builder to help you perform the following task:
5201    ///
5202    /// Creates a new remarketing audience.
5203    ///
5204    /// # Arguments
5205    ///
5206    /// * `request` - No description provided.
5207    /// * `accountId` - The account ID for which to create the remarketing audience.
5208    /// * `webPropertyId` - Web property ID for which to create the remarketing audience.
5209    pub fn remarketing_audience_insert(
5210        &self,
5211        request: RemarketingAudience,
5212        account_id: &str,
5213        web_property_id: &str,
5214    ) -> ManagementRemarketingAudienceInsertCall<'a, C> {
5215        ManagementRemarketingAudienceInsertCall {
5216            hub: self.hub,
5217            _request: request,
5218            _account_id: account_id.to_string(),
5219            _web_property_id: web_property_id.to_string(),
5220            _delegate: Default::default(),
5221            _additional_params: Default::default(),
5222            _scopes: Default::default(),
5223        }
5224    }
5225
5226    /// Create a builder to help you perform the following task:
5227    ///
5228    /// Lists remarketing audiences to which the user has access.
5229    ///
5230    /// # Arguments
5231    ///
5232    /// * `accountId` - The account ID of the remarketing audiences to retrieve.
5233    /// * `webPropertyId` - The web property ID of the remarketing audiences to retrieve.
5234    pub fn remarketing_audience_list(
5235        &self,
5236        account_id: &str,
5237        web_property_id: &str,
5238    ) -> ManagementRemarketingAudienceListCall<'a, C> {
5239        ManagementRemarketingAudienceListCall {
5240            hub: self.hub,
5241            _account_id: account_id.to_string(),
5242            _web_property_id: web_property_id.to_string(),
5243            _type_: Default::default(),
5244            _start_index: Default::default(),
5245            _max_results: Default::default(),
5246            _delegate: Default::default(),
5247            _additional_params: Default::default(),
5248            _scopes: Default::default(),
5249        }
5250    }
5251
5252    /// Create a builder to help you perform the following task:
5253    ///
5254    /// Updates an existing remarketing audience. This method supports patch semantics.
5255    ///
5256    /// # Arguments
5257    ///
5258    /// * `request` - No description provided.
5259    /// * `accountId` - The account ID of the remarketing audience to update.
5260    /// * `webPropertyId` - The web property ID of the remarketing audience to update.
5261    /// * `remarketingAudienceId` - The ID of the remarketing audience to update.
5262    pub fn remarketing_audience_patch(
5263        &self,
5264        request: RemarketingAudience,
5265        account_id: &str,
5266        web_property_id: &str,
5267        remarketing_audience_id: &str,
5268    ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
5269        ManagementRemarketingAudiencePatchCall {
5270            hub: self.hub,
5271            _request: request,
5272            _account_id: account_id.to_string(),
5273            _web_property_id: web_property_id.to_string(),
5274            _remarketing_audience_id: remarketing_audience_id.to_string(),
5275            _delegate: Default::default(),
5276            _additional_params: Default::default(),
5277            _scopes: Default::default(),
5278        }
5279    }
5280
5281    /// Create a builder to help you perform the following task:
5282    ///
5283    /// Updates an existing remarketing audience.
5284    ///
5285    /// # Arguments
5286    ///
5287    /// * `request` - No description provided.
5288    /// * `accountId` - The account ID of the remarketing audience to update.
5289    /// * `webPropertyId` - The web property ID of the remarketing audience to update.
5290    /// * `remarketingAudienceId` - The ID of the remarketing audience to update.
5291    pub fn remarketing_audience_update(
5292        &self,
5293        request: RemarketingAudience,
5294        account_id: &str,
5295        web_property_id: &str,
5296        remarketing_audience_id: &str,
5297    ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
5298        ManagementRemarketingAudienceUpdateCall {
5299            hub: self.hub,
5300            _request: request,
5301            _account_id: account_id.to_string(),
5302            _web_property_id: web_property_id.to_string(),
5303            _remarketing_audience_id: remarketing_audience_id.to_string(),
5304            _delegate: Default::default(),
5305            _additional_params: Default::default(),
5306            _scopes: Default::default(),
5307        }
5308    }
5309
5310    /// Create a builder to help you perform the following task:
5311    ///
5312    /// Lists segments to which the user has access.
5313    pub fn segments_list(&self) -> ManagementSegmentListCall<'a, C> {
5314        ManagementSegmentListCall {
5315            hub: self.hub,
5316            _start_index: Default::default(),
5317            _max_results: Default::default(),
5318            _delegate: Default::default(),
5319            _additional_params: Default::default(),
5320            _scopes: Default::default(),
5321        }
5322    }
5323
5324    /// Create a builder to help you perform the following task:
5325    ///
5326    /// Deletes an unsampled report.
5327    ///
5328    /// # Arguments
5329    ///
5330    /// * `accountId` - Account ID to delete the unsampled report for.
5331    /// * `webPropertyId` - Web property ID to delete the unsampled reports for.
5332    /// * `profileId` - View (Profile) ID to delete the unsampled report for.
5333    /// * `unsampledReportId` - ID of the unsampled report to be deleted.
5334    pub fn unsampled_reports_delete(
5335        &self,
5336        account_id: &str,
5337        web_property_id: &str,
5338        profile_id: &str,
5339        unsampled_report_id: &str,
5340    ) -> ManagementUnsampledReportDeleteCall<'a, C> {
5341        ManagementUnsampledReportDeleteCall {
5342            hub: self.hub,
5343            _account_id: account_id.to_string(),
5344            _web_property_id: web_property_id.to_string(),
5345            _profile_id: profile_id.to_string(),
5346            _unsampled_report_id: unsampled_report_id.to_string(),
5347            _delegate: Default::default(),
5348            _additional_params: Default::default(),
5349            _scopes: Default::default(),
5350        }
5351    }
5352
5353    /// Create a builder to help you perform the following task:
5354    ///
5355    /// Returns a single unsampled report.
5356    ///
5357    /// # Arguments
5358    ///
5359    /// * `accountId` - Account ID to retrieve unsampled report for.
5360    /// * `webPropertyId` - Web property ID to retrieve unsampled reports for.
5361    /// * `profileId` - View (Profile) ID to retrieve unsampled report for.
5362    /// * `unsampledReportId` - ID of the unsampled report to retrieve.
5363    pub fn unsampled_reports_get(
5364        &self,
5365        account_id: &str,
5366        web_property_id: &str,
5367        profile_id: &str,
5368        unsampled_report_id: &str,
5369    ) -> ManagementUnsampledReportGetCall<'a, C> {
5370        ManagementUnsampledReportGetCall {
5371            hub: self.hub,
5372            _account_id: account_id.to_string(),
5373            _web_property_id: web_property_id.to_string(),
5374            _profile_id: profile_id.to_string(),
5375            _unsampled_report_id: unsampled_report_id.to_string(),
5376            _delegate: Default::default(),
5377            _additional_params: Default::default(),
5378            _scopes: Default::default(),
5379        }
5380    }
5381
5382    /// Create a builder to help you perform the following task:
5383    ///
5384    /// Create a new unsampled report.
5385    ///
5386    /// # Arguments
5387    ///
5388    /// * `request` - No description provided.
5389    /// * `accountId` - Account ID to create the unsampled report for.
5390    /// * `webPropertyId` - Web property ID to create the unsampled report for.
5391    /// * `profileId` - View (Profile) ID to create the unsampled report for.
5392    pub fn unsampled_reports_insert(
5393        &self,
5394        request: UnsampledReport,
5395        account_id: &str,
5396        web_property_id: &str,
5397        profile_id: &str,
5398    ) -> ManagementUnsampledReportInsertCall<'a, C> {
5399        ManagementUnsampledReportInsertCall {
5400            hub: self.hub,
5401            _request: request,
5402            _account_id: account_id.to_string(),
5403            _web_property_id: web_property_id.to_string(),
5404            _profile_id: profile_id.to_string(),
5405            _delegate: Default::default(),
5406            _additional_params: Default::default(),
5407            _scopes: Default::default(),
5408        }
5409    }
5410
5411    /// Create a builder to help you perform the following task:
5412    ///
5413    /// Lists unsampled reports to which the user has access.
5414    ///
5415    /// # Arguments
5416    ///
5417    /// * `accountId` - Account ID to retrieve unsampled reports for. Must be a specific account ID, ~all is not supported.
5418    /// * `webPropertyId` - Web property ID to retrieve unsampled reports for. Must be a specific web property ID, ~all is not supported.
5419    /// * `profileId` - View (Profile) ID to retrieve unsampled reports for. Must be a specific view (profile) ID, ~all is not supported.
5420    pub fn unsampled_reports_list(
5421        &self,
5422        account_id: &str,
5423        web_property_id: &str,
5424        profile_id: &str,
5425    ) -> ManagementUnsampledReportListCall<'a, C> {
5426        ManagementUnsampledReportListCall {
5427            hub: self.hub,
5428            _account_id: account_id.to_string(),
5429            _web_property_id: web_property_id.to_string(),
5430            _profile_id: profile_id.to_string(),
5431            _start_index: Default::default(),
5432            _max_results: Default::default(),
5433            _delegate: Default::default(),
5434            _additional_params: Default::default(),
5435            _scopes: Default::default(),
5436        }
5437    }
5438
5439    /// Create a builder to help you perform the following task:
5440    ///
5441    /// Delete data associated with a previous upload.
5442    ///
5443    /// # Arguments
5444    ///
5445    /// * `request` - No description provided.
5446    /// * `accountId` - Account Id for the uploads to be deleted.
5447    /// * `webPropertyId` - Web property Id for the uploads to be deleted.
5448    /// * `customDataSourceId` - Custom data source Id for the uploads to be deleted.
5449    pub fn uploads_delete_upload_data(
5450        &self,
5451        request: AnalyticsDataimportDeleteUploadDataRequest,
5452        account_id: &str,
5453        web_property_id: &str,
5454        custom_data_source_id: &str,
5455    ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
5456        ManagementUploadDeleteUploadDataCall {
5457            hub: self.hub,
5458            _request: request,
5459            _account_id: account_id.to_string(),
5460            _web_property_id: web_property_id.to_string(),
5461            _custom_data_source_id: custom_data_source_id.to_string(),
5462            _delegate: Default::default(),
5463            _additional_params: Default::default(),
5464            _scopes: Default::default(),
5465        }
5466    }
5467
5468    /// Create a builder to help you perform the following task:
5469    ///
5470    /// List uploads to which the user has access.
5471    ///
5472    /// # Arguments
5473    ///
5474    /// * `accountId` - Account Id for the upload to retrieve.
5475    /// * `webPropertyId` - Web property Id for the upload to retrieve.
5476    /// * `customDataSourceId` - Custom data source Id for upload to retrieve.
5477    /// * `uploadId` - Upload Id to retrieve.
5478    pub fn uploads_get(
5479        &self,
5480        account_id: &str,
5481        web_property_id: &str,
5482        custom_data_source_id: &str,
5483        upload_id: &str,
5484    ) -> ManagementUploadGetCall<'a, C> {
5485        ManagementUploadGetCall {
5486            hub: self.hub,
5487            _account_id: account_id.to_string(),
5488            _web_property_id: web_property_id.to_string(),
5489            _custom_data_source_id: custom_data_source_id.to_string(),
5490            _upload_id: upload_id.to_string(),
5491            _delegate: Default::default(),
5492            _additional_params: Default::default(),
5493            _scopes: Default::default(),
5494        }
5495    }
5496
5497    /// Create a builder to help you perform the following task:
5498    ///
5499    /// List uploads to which the user has access.
5500    ///
5501    /// # Arguments
5502    ///
5503    /// * `accountId` - Account Id for the uploads to retrieve.
5504    /// * `webPropertyId` - Web property Id for the uploads to retrieve.
5505    /// * `customDataSourceId` - Custom data source Id for uploads to retrieve.
5506    pub fn uploads_list(
5507        &self,
5508        account_id: &str,
5509        web_property_id: &str,
5510        custom_data_source_id: &str,
5511    ) -> ManagementUploadListCall<'a, C> {
5512        ManagementUploadListCall {
5513            hub: self.hub,
5514            _account_id: account_id.to_string(),
5515            _web_property_id: web_property_id.to_string(),
5516            _custom_data_source_id: custom_data_source_id.to_string(),
5517            _start_index: Default::default(),
5518            _max_results: Default::default(),
5519            _delegate: Default::default(),
5520            _additional_params: Default::default(),
5521            _scopes: Default::default(),
5522        }
5523    }
5524
5525    /// Create a builder to help you perform the following task:
5526    ///
5527    /// Upload data for a custom data source.
5528    ///
5529    /// # Arguments
5530    ///
5531    /// * `accountId` - Account Id associated with the upload.
5532    /// * `webPropertyId` - Web property UA-string associated with the upload.
5533    /// * `customDataSourceId` - Custom data source Id to which the data being uploaded belongs.
5534    pub fn uploads_upload_data(
5535        &self,
5536        account_id: &str,
5537        web_property_id: &str,
5538        custom_data_source_id: &str,
5539    ) -> ManagementUploadUploadDataCall<'a, C> {
5540        ManagementUploadUploadDataCall {
5541            hub: self.hub,
5542            _account_id: account_id.to_string(),
5543            _web_property_id: web_property_id.to_string(),
5544            _custom_data_source_id: custom_data_source_id.to_string(),
5545            _delegate: Default::default(),
5546            _additional_params: Default::default(),
5547            _scopes: Default::default(),
5548        }
5549    }
5550
5551    /// Create a builder to help you perform the following task:
5552    ///
5553    /// Deletes a web property-Google Ads link.
5554    ///
5555    /// # Arguments
5556    ///
5557    /// * `accountId` - ID of the account which the given web property belongs to.
5558    /// * `webPropertyId` - Web property ID to delete the Google Ads link for.
5559    /// * `webPropertyAdWordsLinkId` - Web property Google Ads link ID.
5560    pub fn web_property_ad_words_links_delete(
5561        &self,
5562        account_id: &str,
5563        web_property_id: &str,
5564        web_property_ad_words_link_id: &str,
5565    ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
5566        ManagementWebPropertyAdWordsLinkDeleteCall {
5567            hub: self.hub,
5568            _account_id: account_id.to_string(),
5569            _web_property_id: web_property_id.to_string(),
5570            _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(),
5571            _delegate: Default::default(),
5572            _additional_params: Default::default(),
5573            _scopes: Default::default(),
5574        }
5575    }
5576
5577    /// Create a builder to help you perform the following task:
5578    ///
5579    /// Returns a web property-Google Ads link to which the user has access.
5580    ///
5581    /// # Arguments
5582    ///
5583    /// * `accountId` - ID of the account which the given web property belongs to.
5584    /// * `webPropertyId` - Web property ID to retrieve the Google Ads link for.
5585    /// * `webPropertyAdWordsLinkId` - Web property-Google Ads link ID.
5586    pub fn web_property_ad_words_links_get(
5587        &self,
5588        account_id: &str,
5589        web_property_id: &str,
5590        web_property_ad_words_link_id: &str,
5591    ) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
5592        ManagementWebPropertyAdWordsLinkGetCall {
5593            hub: self.hub,
5594            _account_id: account_id.to_string(),
5595            _web_property_id: web_property_id.to_string(),
5596            _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(),
5597            _delegate: Default::default(),
5598            _additional_params: Default::default(),
5599            _scopes: Default::default(),
5600        }
5601    }
5602
5603    /// Create a builder to help you perform the following task:
5604    ///
5605    /// Creates a webProperty-Google Ads link.
5606    ///
5607    /// # Arguments
5608    ///
5609    /// * `request` - No description provided.
5610    /// * `accountId` - ID of the Google Analytics account to create the link for.
5611    /// * `webPropertyId` - Web property ID to create the link for.
5612    pub fn web_property_ad_words_links_insert(
5613        &self,
5614        request: EntityAdWordsLink,
5615        account_id: &str,
5616        web_property_id: &str,
5617    ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
5618        ManagementWebPropertyAdWordsLinkInsertCall {
5619            hub: self.hub,
5620            _request: request,
5621            _account_id: account_id.to_string(),
5622            _web_property_id: web_property_id.to_string(),
5623            _delegate: Default::default(),
5624            _additional_params: Default::default(),
5625            _scopes: Default::default(),
5626        }
5627    }
5628
5629    /// Create a builder to help you perform the following task:
5630    ///
5631    /// Lists webProperty-Google Ads links for a given web property.
5632    ///
5633    /// # Arguments
5634    ///
5635    /// * `accountId` - ID of the account which the given web property belongs to.
5636    /// * `webPropertyId` - Web property ID to retrieve the Google Ads links for.
5637    pub fn web_property_ad_words_links_list(
5638        &self,
5639        account_id: &str,
5640        web_property_id: &str,
5641    ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
5642        ManagementWebPropertyAdWordsLinkListCall {
5643            hub: self.hub,
5644            _account_id: account_id.to_string(),
5645            _web_property_id: web_property_id.to_string(),
5646            _start_index: Default::default(),
5647            _max_results: Default::default(),
5648            _delegate: Default::default(),
5649            _additional_params: Default::default(),
5650            _scopes: Default::default(),
5651        }
5652    }
5653
5654    /// Create a builder to help you perform the following task:
5655    ///
5656    /// Updates an existing webProperty-Google Ads link. This method supports patch semantics.
5657    ///
5658    /// # Arguments
5659    ///
5660    /// * `request` - No description provided.
5661    /// * `accountId` - ID of the account which the given web property belongs to.
5662    /// * `webPropertyId` - Web property ID to retrieve the Google Ads link for.
5663    /// * `webPropertyAdWordsLinkId` - Web property-Google Ads link ID.
5664    pub fn web_property_ad_words_links_patch(
5665        &self,
5666        request: EntityAdWordsLink,
5667        account_id: &str,
5668        web_property_id: &str,
5669        web_property_ad_words_link_id: &str,
5670    ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
5671        ManagementWebPropertyAdWordsLinkPatchCall {
5672            hub: self.hub,
5673            _request: request,
5674            _account_id: account_id.to_string(),
5675            _web_property_id: web_property_id.to_string(),
5676            _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(),
5677            _delegate: Default::default(),
5678            _additional_params: Default::default(),
5679            _scopes: Default::default(),
5680        }
5681    }
5682
5683    /// Create a builder to help you perform the following task:
5684    ///
5685    /// Updates an existing webProperty-Google Ads link.
5686    ///
5687    /// # Arguments
5688    ///
5689    /// * `request` - No description provided.
5690    /// * `accountId` - ID of the account which the given web property belongs to.
5691    /// * `webPropertyId` - Web property ID to retrieve the Google Ads link for.
5692    /// * `webPropertyAdWordsLinkId` - Web property-Google Ads link ID.
5693    pub fn web_property_ad_words_links_update(
5694        &self,
5695        request: EntityAdWordsLink,
5696        account_id: &str,
5697        web_property_id: &str,
5698        web_property_ad_words_link_id: &str,
5699    ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
5700        ManagementWebPropertyAdWordsLinkUpdateCall {
5701            hub: self.hub,
5702            _request: request,
5703            _account_id: account_id.to_string(),
5704            _web_property_id: web_property_id.to_string(),
5705            _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(),
5706            _delegate: Default::default(),
5707            _additional_params: Default::default(),
5708            _scopes: Default::default(),
5709        }
5710    }
5711
5712    /// Create a builder to help you perform the following task:
5713    ///
5714    /// Gets a web property to which the user has access.
5715    ///
5716    /// # Arguments
5717    ///
5718    /// * `accountId` - Account ID to retrieve the web property for.
5719    /// * `webPropertyId` - ID to retrieve the web property for.
5720    pub fn webproperties_get(
5721        &self,
5722        account_id: &str,
5723        web_property_id: &str,
5724    ) -> ManagementWebpropertyGetCall<'a, C> {
5725        ManagementWebpropertyGetCall {
5726            hub: self.hub,
5727            _account_id: account_id.to_string(),
5728            _web_property_id: web_property_id.to_string(),
5729            _delegate: Default::default(),
5730            _additional_params: Default::default(),
5731            _scopes: Default::default(),
5732        }
5733    }
5734
5735    /// Create a builder to help you perform the following task:
5736    ///
5737    /// Create a new property if the account has fewer than 20 properties. Web properties are visible in the Google Analytics interface only if they have at least one profile.
5738    ///
5739    /// # Arguments
5740    ///
5741    /// * `request` - No description provided.
5742    /// * `accountId` - Account ID to create the web property for.
5743    pub fn webproperties_insert(
5744        &self,
5745        request: Webproperty,
5746        account_id: &str,
5747    ) -> ManagementWebpropertyInsertCall<'a, C> {
5748        ManagementWebpropertyInsertCall {
5749            hub: self.hub,
5750            _request: request,
5751            _account_id: account_id.to_string(),
5752            _delegate: Default::default(),
5753            _additional_params: Default::default(),
5754            _scopes: Default::default(),
5755        }
5756    }
5757
5758    /// Create a builder to help you perform the following task:
5759    ///
5760    /// Lists web properties to which the user has access.
5761    ///
5762    /// # Arguments
5763    ///
5764    /// * `accountId` - Account ID to retrieve web properties for. Can either be a specific account ID or '~all', which refers to all the accounts that user has access to.
5765    pub fn webproperties_list(&self, account_id: &str) -> ManagementWebpropertyListCall<'a, C> {
5766        ManagementWebpropertyListCall {
5767            hub: self.hub,
5768            _account_id: account_id.to_string(),
5769            _start_index: Default::default(),
5770            _max_results: Default::default(),
5771            _delegate: Default::default(),
5772            _additional_params: Default::default(),
5773            _scopes: Default::default(),
5774        }
5775    }
5776
5777    /// Create a builder to help you perform the following task:
5778    ///
5779    /// Updates an existing web property. This method supports patch semantics.
5780    ///
5781    /// # Arguments
5782    ///
5783    /// * `request` - No description provided.
5784    /// * `accountId` - Account ID to which the web property belongs
5785    /// * `webPropertyId` - Web property ID
5786    pub fn webproperties_patch(
5787        &self,
5788        request: Webproperty,
5789        account_id: &str,
5790        web_property_id: &str,
5791    ) -> ManagementWebpropertyPatchCall<'a, C> {
5792        ManagementWebpropertyPatchCall {
5793            hub: self.hub,
5794            _request: request,
5795            _account_id: account_id.to_string(),
5796            _web_property_id: web_property_id.to_string(),
5797            _delegate: Default::default(),
5798            _additional_params: Default::default(),
5799            _scopes: Default::default(),
5800        }
5801    }
5802
5803    /// Create a builder to help you perform the following task:
5804    ///
5805    /// Updates an existing web property.
5806    ///
5807    /// # Arguments
5808    ///
5809    /// * `request` - No description provided.
5810    /// * `accountId` - Account ID to which the web property belongs
5811    /// * `webPropertyId` - Web property ID
5812    pub fn webproperties_update(
5813        &self,
5814        request: Webproperty,
5815        account_id: &str,
5816        web_property_id: &str,
5817    ) -> ManagementWebpropertyUpdateCall<'a, C> {
5818        ManagementWebpropertyUpdateCall {
5819            hub: self.hub,
5820            _request: request,
5821            _account_id: account_id.to_string(),
5822            _web_property_id: web_property_id.to_string(),
5823            _delegate: Default::default(),
5824            _additional_params: Default::default(),
5825            _scopes: Default::default(),
5826        }
5827    }
5828
5829    /// Create a builder to help you perform the following task:
5830    ///
5831    /// Removes a user from the given web property.
5832    ///
5833    /// # Arguments
5834    ///
5835    /// * `accountId` - Account ID to delete the user link for.
5836    /// * `webPropertyId` - Web Property ID to delete the user link for.
5837    /// * `linkId` - Link ID to delete the user link for.
5838    pub fn webproperty_user_links_delete(
5839        &self,
5840        account_id: &str,
5841        web_property_id: &str,
5842        link_id: &str,
5843    ) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
5844        ManagementWebpropertyUserLinkDeleteCall {
5845            hub: self.hub,
5846            _account_id: account_id.to_string(),
5847            _web_property_id: web_property_id.to_string(),
5848            _link_id: link_id.to_string(),
5849            _delegate: Default::default(),
5850            _additional_params: Default::default(),
5851            _scopes: Default::default(),
5852        }
5853    }
5854
5855    /// Create a builder to help you perform the following task:
5856    ///
5857    /// Adds a new user to the given web property.
5858    ///
5859    /// # Arguments
5860    ///
5861    /// * `request` - No description provided.
5862    /// * `accountId` - Account ID to create the user link for.
5863    /// * `webPropertyId` - Web Property ID to create the user link for.
5864    pub fn webproperty_user_links_insert(
5865        &self,
5866        request: EntityUserLink,
5867        account_id: &str,
5868        web_property_id: &str,
5869    ) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
5870        ManagementWebpropertyUserLinkInsertCall {
5871            hub: self.hub,
5872            _request: request,
5873            _account_id: account_id.to_string(),
5874            _web_property_id: web_property_id.to_string(),
5875            _delegate: Default::default(),
5876            _additional_params: Default::default(),
5877            _scopes: Default::default(),
5878        }
5879    }
5880
5881    /// Create a builder to help you perform the following task:
5882    ///
5883    /// Lists webProperty-user links for a given web property.
5884    ///
5885    /// # Arguments
5886    ///
5887    /// * `accountId` - Account ID which the given web property belongs to.
5888    /// * `webPropertyId` - Web Property ID for the webProperty-user links to retrieve. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
5889    pub fn webproperty_user_links_list(
5890        &self,
5891        account_id: &str,
5892        web_property_id: &str,
5893    ) -> ManagementWebpropertyUserLinkListCall<'a, C> {
5894        ManagementWebpropertyUserLinkListCall {
5895            hub: self.hub,
5896            _account_id: account_id.to_string(),
5897            _web_property_id: web_property_id.to_string(),
5898            _start_index: Default::default(),
5899            _max_results: Default::default(),
5900            _delegate: Default::default(),
5901            _additional_params: Default::default(),
5902            _scopes: Default::default(),
5903        }
5904    }
5905
5906    /// Create a builder to help you perform the following task:
5907    ///
5908    /// Updates permissions for an existing user on the given web property.
5909    ///
5910    /// # Arguments
5911    ///
5912    /// * `request` - No description provided.
5913    /// * `accountId` - Account ID to update the account-user link for.
5914    /// * `webPropertyId` - Web property ID to update the account-user link for.
5915    /// * `linkId` - Link ID to update the account-user link for.
5916    pub fn webproperty_user_links_update(
5917        &self,
5918        request: EntityUserLink,
5919        account_id: &str,
5920        web_property_id: &str,
5921        link_id: &str,
5922    ) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
5923        ManagementWebpropertyUserLinkUpdateCall {
5924            hub: self.hub,
5925            _request: request,
5926            _account_id: account_id.to_string(),
5927            _web_property_id: web_property_id.to_string(),
5928            _link_id: link_id.to_string(),
5929            _delegate: Default::default(),
5930            _additional_params: Default::default(),
5931            _scopes: Default::default(),
5932        }
5933    }
5934}
5935
5936/// A builder providing access to all methods supported on *metadata* resources.
5937/// It is not used directly, but through the [`Analytics`] hub.
5938///
5939/// # Example
5940///
5941/// Instantiate a resource builder
5942///
5943/// ```test_harness,no_run
5944/// extern crate hyper;
5945/// extern crate hyper_rustls;
5946/// extern crate google_analytics3 as analytics3;
5947///
5948/// # async fn dox() {
5949/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5950///
5951/// let secret: yup_oauth2::ApplicationSecret = Default::default();
5952/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
5953///     .with_native_roots()
5954///     .unwrap()
5955///     .https_only()
5956///     .enable_http2()
5957///     .build();
5958///
5959/// let executor = hyper_util::rt::TokioExecutor::new();
5960/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5961///     secret,
5962///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5963///     yup_oauth2::client::CustomHyperClientBuilder::from(
5964///         hyper_util::client::legacy::Client::builder(executor).build(connector),
5965///     ),
5966/// ).build().await.unwrap();
5967///
5968/// let client = hyper_util::client::legacy::Client::builder(
5969///     hyper_util::rt::TokioExecutor::new()
5970/// )
5971/// .build(
5972///     hyper_rustls::HttpsConnectorBuilder::new()
5973///         .with_native_roots()
5974///         .unwrap()
5975///         .https_or_http()
5976///         .enable_http2()
5977///         .build()
5978/// );
5979/// let mut hub = Analytics::new(client, auth);
5980/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
5981/// // like `columns_list(...)`
5982/// // to build up your call.
5983/// let rb = hub.metadata();
5984/// # }
5985/// ```
5986pub struct MetadataMethods<'a, C>
5987where
5988    C: 'a,
5989{
5990    hub: &'a Analytics<C>,
5991}
5992
5993impl<'a, C> common::MethodsBuilder for MetadataMethods<'a, C> {}
5994
5995impl<'a, C> MetadataMethods<'a, C> {
5996    /// Create a builder to help you perform the following task:
5997    ///
5998    /// Lists all columns for a report type
5999    ///
6000    /// # Arguments
6001    ///
6002    /// * `reportType` - Report type. Allowed Values: 'ga'. Where 'ga' corresponds to the Core Reporting API
6003    pub fn columns_list(&self, report_type: &str) -> MetadataColumnListCall<'a, C> {
6004        MetadataColumnListCall {
6005            hub: self.hub,
6006            _report_type: report_type.to_string(),
6007            _delegate: Default::default(),
6008            _additional_params: Default::default(),
6009            _scopes: Default::default(),
6010        }
6011    }
6012}
6013
6014/// A builder providing access to all methods supported on *provisioning* resources.
6015/// It is not used directly, but through the [`Analytics`] hub.
6016///
6017/// # Example
6018///
6019/// Instantiate a resource builder
6020///
6021/// ```test_harness,no_run
6022/// extern crate hyper;
6023/// extern crate hyper_rustls;
6024/// extern crate google_analytics3 as analytics3;
6025///
6026/// # async fn dox() {
6027/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6028///
6029/// let secret: yup_oauth2::ApplicationSecret = Default::default();
6030/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
6031///     .with_native_roots()
6032///     .unwrap()
6033///     .https_only()
6034///     .enable_http2()
6035///     .build();
6036///
6037/// let executor = hyper_util::rt::TokioExecutor::new();
6038/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6039///     secret,
6040///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6041///     yup_oauth2::client::CustomHyperClientBuilder::from(
6042///         hyper_util::client::legacy::Client::builder(executor).build(connector),
6043///     ),
6044/// ).build().await.unwrap();
6045///
6046/// let client = hyper_util::client::legacy::Client::builder(
6047///     hyper_util::rt::TokioExecutor::new()
6048/// )
6049/// .build(
6050///     hyper_rustls::HttpsConnectorBuilder::new()
6051///         .with_native_roots()
6052///         .unwrap()
6053///         .https_or_http()
6054///         .enable_http2()
6055///         .build()
6056/// );
6057/// let mut hub = Analytics::new(client, auth);
6058/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
6059/// // like `create_account_ticket(...)` and `create_account_tree(...)`
6060/// // to build up your call.
6061/// let rb = hub.provisioning();
6062/// # }
6063/// ```
6064pub struct ProvisioningMethods<'a, C>
6065where
6066    C: 'a,
6067{
6068    hub: &'a Analytics<C>,
6069}
6070
6071impl<'a, C> common::MethodsBuilder for ProvisioningMethods<'a, C> {}
6072
6073impl<'a, C> ProvisioningMethods<'a, C> {
6074    /// Create a builder to help you perform the following task:
6075    ///
6076    /// Creates an account ticket.
6077    ///
6078    /// # Arguments
6079    ///
6080    /// * `request` - No description provided.
6081    pub fn create_account_ticket(
6082        &self,
6083        request: AccountTicket,
6084    ) -> ProvisioningCreateAccountTicketCall<'a, C> {
6085        ProvisioningCreateAccountTicketCall {
6086            hub: self.hub,
6087            _request: request,
6088            _delegate: Default::default(),
6089            _additional_params: Default::default(),
6090            _scopes: Default::default(),
6091        }
6092    }
6093
6094    /// Create a builder to help you perform the following task:
6095    ///
6096    /// Provision account.
6097    ///
6098    /// # Arguments
6099    ///
6100    /// * `request` - No description provided.
6101    pub fn create_account_tree(
6102        &self,
6103        request: AccountTreeRequest,
6104    ) -> ProvisioningCreateAccountTreeCall<'a, C> {
6105        ProvisioningCreateAccountTreeCall {
6106            hub: self.hub,
6107            _request: request,
6108            _delegate: Default::default(),
6109            _additional_params: Default::default(),
6110            _scopes: Default::default(),
6111        }
6112    }
6113}
6114
6115/// A builder providing access to all methods supported on *userDeletion* resources.
6116/// It is not used directly, but through the [`Analytics`] hub.
6117///
6118/// # Example
6119///
6120/// Instantiate a resource builder
6121///
6122/// ```test_harness,no_run
6123/// extern crate hyper;
6124/// extern crate hyper_rustls;
6125/// extern crate google_analytics3 as analytics3;
6126///
6127/// # async fn dox() {
6128/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6129///
6130/// let secret: yup_oauth2::ApplicationSecret = Default::default();
6131/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
6132///     .with_native_roots()
6133///     .unwrap()
6134///     .https_only()
6135///     .enable_http2()
6136///     .build();
6137///
6138/// let executor = hyper_util::rt::TokioExecutor::new();
6139/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6140///     secret,
6141///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6142///     yup_oauth2::client::CustomHyperClientBuilder::from(
6143///         hyper_util::client::legacy::Client::builder(executor).build(connector),
6144///     ),
6145/// ).build().await.unwrap();
6146///
6147/// let client = hyper_util::client::legacy::Client::builder(
6148///     hyper_util::rt::TokioExecutor::new()
6149/// )
6150/// .build(
6151///     hyper_rustls::HttpsConnectorBuilder::new()
6152///         .with_native_roots()
6153///         .unwrap()
6154///         .https_or_http()
6155///         .enable_http2()
6156///         .build()
6157/// );
6158/// let mut hub = Analytics::new(client, auth);
6159/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
6160/// // like `user_deletion_request_upsert(...)`
6161/// // to build up your call.
6162/// let rb = hub.user_deletion();
6163/// # }
6164/// ```
6165pub struct UserDeletionMethods<'a, C>
6166where
6167    C: 'a,
6168{
6169    hub: &'a Analytics<C>,
6170}
6171
6172impl<'a, C> common::MethodsBuilder for UserDeletionMethods<'a, C> {}
6173
6174impl<'a, C> UserDeletionMethods<'a, C> {
6175    /// Create a builder to help you perform the following task:
6176    ///
6177    /// Insert or update a user deletion requests.
6178    ///
6179    /// # Arguments
6180    ///
6181    /// * `request` - No description provided.
6182    pub fn user_deletion_request_upsert(
6183        &self,
6184        request: UserDeletionRequest,
6185    ) -> UserDeletionUserDeletionRequestUpsertCall<'a, C> {
6186        UserDeletionUserDeletionRequestUpsertCall {
6187            hub: self.hub,
6188            _request: request,
6189            _delegate: Default::default(),
6190            _additional_params: Default::default(),
6191            _scopes: Default::default(),
6192        }
6193    }
6194}
6195
6196// ###################
6197// CallBuilders   ###
6198// #################
6199
6200/// Returns Analytics data for a view (profile).
6201///
6202/// A builder for the *ga.get* method supported by a *data* resource.
6203/// It is not used directly, but through a [`DataMethods`] instance.
6204///
6205/// # Example
6206///
6207/// Instantiate a resource method builder
6208///
6209/// ```test_harness,no_run
6210/// # extern crate hyper;
6211/// # extern crate hyper_rustls;
6212/// # extern crate google_analytics3 as analytics3;
6213/// # async fn dox() {
6214/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6215///
6216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6217/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6218/// #     .with_native_roots()
6219/// #     .unwrap()
6220/// #     .https_only()
6221/// #     .enable_http2()
6222/// #     .build();
6223///
6224/// # let executor = hyper_util::rt::TokioExecutor::new();
6225/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6226/// #     secret,
6227/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6228/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6229/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6230/// #     ),
6231/// # ).build().await.unwrap();
6232///
6233/// # let client = hyper_util::client::legacy::Client::builder(
6234/// #     hyper_util::rt::TokioExecutor::new()
6235/// # )
6236/// # .build(
6237/// #     hyper_rustls::HttpsConnectorBuilder::new()
6238/// #         .with_native_roots()
6239/// #         .unwrap()
6240/// #         .https_or_http()
6241/// #         .enable_http2()
6242/// #         .build()
6243/// # );
6244/// # let mut hub = Analytics::new(client, auth);
6245/// // You can configure optional parameters by calling the respective setters at will, and
6246/// // execute the final call using `doit()`.
6247/// // Values shown here are possibly random and not representative !
6248/// let result = hub.data().ga_get("ids", "start-date", "end-date", "metrics")
6249///              .start_index(-75)
6250///              .sort("dolor")
6251///              .segment("ea")
6252///              .sampling_level("ipsum")
6253///              .output("invidunt")
6254///              .max_results(-47)
6255///              .include_empty_rows(true)
6256///              .filters("sed")
6257///              .dimensions("ut")
6258///              .doit().await;
6259/// # }
6260/// ```
6261pub struct DataGaGetCall<'a, C>
6262where
6263    C: 'a,
6264{
6265    hub: &'a Analytics<C>,
6266    _ids: String,
6267    _start_date: String,
6268    _end_date: String,
6269    _metrics: String,
6270    _start_index: Option<i32>,
6271    _sort: Option<String>,
6272    _segment: Option<String>,
6273    _sampling_level: Option<String>,
6274    _output: Option<String>,
6275    _max_results: Option<i32>,
6276    _include_empty_rows: Option<bool>,
6277    _filters: Option<String>,
6278    _dimensions: Option<String>,
6279    _delegate: Option<&'a mut dyn common::Delegate>,
6280    _additional_params: HashMap<String, String>,
6281    _scopes: BTreeSet<String>,
6282}
6283
6284impl<'a, C> common::CallBuilder for DataGaGetCall<'a, C> {}
6285
6286impl<'a, C> DataGaGetCall<'a, C>
6287where
6288    C: common::Connector,
6289{
6290    /// Perform the operation you have build so far.
6291    pub async fn doit(mut self) -> common::Result<(common::Response, GaData)> {
6292        use std::borrow::Cow;
6293        use std::io::{Read, Seek};
6294
6295        use common::{url::Params, ToParts};
6296        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6297
6298        let mut dd = common::DefaultDelegate;
6299        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6300        dlg.begin(common::MethodInfo {
6301            id: "analytics.data.ga.get",
6302            http_method: hyper::Method::GET,
6303        });
6304
6305        for &field in [
6306            "alt",
6307            "ids",
6308            "start-date",
6309            "end-date",
6310            "metrics",
6311            "start-index",
6312            "sort",
6313            "segment",
6314            "samplingLevel",
6315            "output",
6316            "max-results",
6317            "include-empty-rows",
6318            "filters",
6319            "dimensions",
6320        ]
6321        .iter()
6322        {
6323            if self._additional_params.contains_key(field) {
6324                dlg.finished(false);
6325                return Err(common::Error::FieldClash(field));
6326            }
6327        }
6328
6329        let mut params = Params::with_capacity(15 + self._additional_params.len());
6330        params.push("ids", self._ids);
6331        params.push("start-date", self._start_date);
6332        params.push("end-date", self._end_date);
6333        params.push("metrics", self._metrics);
6334        if let Some(value) = self._start_index.as_ref() {
6335            params.push("start-index", value.to_string());
6336        }
6337        if let Some(value) = self._sort.as_ref() {
6338            params.push("sort", value);
6339        }
6340        if let Some(value) = self._segment.as_ref() {
6341            params.push("segment", value);
6342        }
6343        if let Some(value) = self._sampling_level.as_ref() {
6344            params.push("samplingLevel", value);
6345        }
6346        if let Some(value) = self._output.as_ref() {
6347            params.push("output", value);
6348        }
6349        if let Some(value) = self._max_results.as_ref() {
6350            params.push("max-results", value.to_string());
6351        }
6352        if let Some(value) = self._include_empty_rows.as_ref() {
6353            params.push("include-empty-rows", value.to_string());
6354        }
6355        if let Some(value) = self._filters.as_ref() {
6356            params.push("filters", value);
6357        }
6358        if let Some(value) = self._dimensions.as_ref() {
6359            params.push("dimensions", value);
6360        }
6361
6362        params.extend(self._additional_params.iter());
6363
6364        params.push("alt", "json");
6365        let mut url = self.hub._base_url.clone() + "data/ga";
6366        if self._scopes.is_empty() {
6367            self._scopes.insert(Scope::Readonly.as_ref().to_string());
6368        }
6369
6370        let url = params.parse_with_url(&url);
6371
6372        loop {
6373            let token = match self
6374                .hub
6375                .auth
6376                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6377                .await
6378            {
6379                Ok(token) => token,
6380                Err(e) => match dlg.token(e) {
6381                    Ok(token) => token,
6382                    Err(e) => {
6383                        dlg.finished(false);
6384                        return Err(common::Error::MissingToken(e));
6385                    }
6386                },
6387            };
6388            let mut req_result = {
6389                let client = &self.hub.client;
6390                dlg.pre_request();
6391                let mut req_builder = hyper::Request::builder()
6392                    .method(hyper::Method::GET)
6393                    .uri(url.as_str())
6394                    .header(USER_AGENT, self.hub._user_agent.clone());
6395
6396                if let Some(token) = token.as_ref() {
6397                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6398                }
6399
6400                let request = req_builder
6401                    .header(CONTENT_LENGTH, 0_u64)
6402                    .body(common::to_body::<String>(None));
6403
6404                client.request(request.unwrap()).await
6405            };
6406
6407            match req_result {
6408                Err(err) => {
6409                    if let common::Retry::After(d) = dlg.http_error(&err) {
6410                        sleep(d).await;
6411                        continue;
6412                    }
6413                    dlg.finished(false);
6414                    return Err(common::Error::HttpError(err));
6415                }
6416                Ok(res) => {
6417                    let (mut parts, body) = res.into_parts();
6418                    let mut body = common::Body::new(body);
6419                    if !parts.status.is_success() {
6420                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6421                        let error = serde_json::from_str(&common::to_string(&bytes));
6422                        let response = common::to_response(parts, bytes.into());
6423
6424                        if let common::Retry::After(d) =
6425                            dlg.http_failure(&response, error.as_ref().ok())
6426                        {
6427                            sleep(d).await;
6428                            continue;
6429                        }
6430
6431                        dlg.finished(false);
6432
6433                        return Err(match error {
6434                            Ok(value) => common::Error::BadRequest(value),
6435                            _ => common::Error::Failure(response),
6436                        });
6437                    }
6438                    let response = {
6439                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6440                        let encoded = common::to_string(&bytes);
6441                        match serde_json::from_str(&encoded) {
6442                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6443                            Err(error) => {
6444                                dlg.response_json_decode_error(&encoded, &error);
6445                                return Err(common::Error::JsonDecodeError(
6446                                    encoded.to_string(),
6447                                    error,
6448                                ));
6449                            }
6450                        }
6451                    };
6452
6453                    dlg.finished(true);
6454                    return Ok(response);
6455                }
6456            }
6457        }
6458    }
6459
6460    /// Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
6461    ///
6462    /// Sets the *ids* query property to the given value.
6463    ///
6464    /// Even though the property as already been set when instantiating this call,
6465    /// we provide this method for API completeness.
6466    pub fn ids(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6467        self._ids = new_value.to_string();
6468        self
6469    }
6470    /// Start date for fetching Analytics data. Requests can specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is 7daysAgo.
6471    ///
6472    /// Sets the *start-date* query property to the given value.
6473    ///
6474    /// Even though the property as already been set when instantiating this call,
6475    /// we provide this method for API completeness.
6476    pub fn start_date(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6477        self._start_date = new_value.to_string();
6478        self
6479    }
6480    /// End date for fetching Analytics data. Request can should specify an end date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is yesterday.
6481    ///
6482    /// Sets the *end-date* query property to the given value.
6483    ///
6484    /// Even though the property as already been set when instantiating this call,
6485    /// we provide this method for API completeness.
6486    pub fn end_date(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6487        self._end_date = new_value.to_string();
6488        self
6489    }
6490    /// A comma-separated list of Analytics metrics. E.g., 'ga:sessions,ga:pageviews'. At least one metric must be specified.
6491    ///
6492    /// Sets the *metrics* query property to the given value.
6493    ///
6494    /// Even though the property as already been set when instantiating this call,
6495    /// we provide this method for API completeness.
6496    pub fn metrics(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6497        self._metrics = new_value.to_string();
6498        self
6499    }
6500    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
6501    ///
6502    /// Sets the *start-index* query property to the given value.
6503    pub fn start_index(mut self, new_value: i32) -> DataGaGetCall<'a, C> {
6504        self._start_index = Some(new_value);
6505        self
6506    }
6507    /// A comma-separated list of dimensions or metrics that determine the sort order for Analytics data.
6508    ///
6509    /// Sets the *sort* query property to the given value.
6510    pub fn sort(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6511        self._sort = Some(new_value.to_string());
6512        self
6513    }
6514    /// An Analytics segment to be applied to data.
6515    ///
6516    /// Sets the *segment* query property to the given value.
6517    pub fn segment(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6518        self._segment = Some(new_value.to_string());
6519        self
6520    }
6521    /// The desired sampling level.
6522    ///
6523    /// Sets the *sampling level* query property to the given value.
6524    pub fn sampling_level(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6525        self._sampling_level = Some(new_value.to_string());
6526        self
6527    }
6528    /// The selected format for the response. Default format is JSON.
6529    ///
6530    /// Sets the *output* query property to the given value.
6531    pub fn output(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6532        self._output = Some(new_value.to_string());
6533        self
6534    }
6535    /// The maximum number of entries to include in this feed.
6536    ///
6537    /// Sets the *max-results* query property to the given value.
6538    pub fn max_results(mut self, new_value: i32) -> DataGaGetCall<'a, C> {
6539        self._max_results = Some(new_value);
6540        self
6541    }
6542    /// The response will include empty rows if this parameter is set to true, the default is true
6543    ///
6544    /// Sets the *include-empty-rows* query property to the given value.
6545    pub fn include_empty_rows(mut self, new_value: bool) -> DataGaGetCall<'a, C> {
6546        self._include_empty_rows = Some(new_value);
6547        self
6548    }
6549    /// A comma-separated list of dimension or metric filters to be applied to Analytics data.
6550    ///
6551    /// Sets the *filters* query property to the given value.
6552    pub fn filters(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6553        self._filters = Some(new_value.to_string());
6554        self
6555    }
6556    /// A comma-separated list of Analytics dimensions. E.g., 'ga:browser,ga:city'.
6557    ///
6558    /// Sets the *dimensions* query property to the given value.
6559    pub fn dimensions(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6560        self._dimensions = Some(new_value.to_string());
6561        self
6562    }
6563    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6564    /// while executing the actual API request.
6565    ///
6566    /// ````text
6567    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6568    /// ````
6569    ///
6570    /// Sets the *delegate* property to the given value.
6571    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DataGaGetCall<'a, C> {
6572        self._delegate = Some(new_value);
6573        self
6574    }
6575
6576    /// Set any additional parameter of the query string used in the request.
6577    /// It should be used to set parameters which are not yet available through their own
6578    /// setters.
6579    ///
6580    /// Please note that this method must not be used to set any of the known parameters
6581    /// which have their own setter method. If done anyway, the request will fail.
6582    ///
6583    /// # Additional Parameters
6584    ///
6585    /// * *alt* (query-string) - Data format for the response.
6586    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6587    /// * *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.
6588    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6589    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6590    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6591    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6592    pub fn param<T>(mut self, name: T, value: T) -> DataGaGetCall<'a, C>
6593    where
6594        T: AsRef<str>,
6595    {
6596        self._additional_params
6597            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6598        self
6599    }
6600
6601    /// Identifies the authorization scope for the method you are building.
6602    ///
6603    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6604    /// [`Scope::Readonly`].
6605    ///
6606    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6607    /// tokens for more than one scope.
6608    ///
6609    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6610    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6611    /// sufficient, a read-write scope will do as well.
6612    pub fn add_scope<St>(mut self, scope: St) -> DataGaGetCall<'a, C>
6613    where
6614        St: AsRef<str>,
6615    {
6616        self._scopes.insert(String::from(scope.as_ref()));
6617        self
6618    }
6619    /// Identifies the authorization scope(s) for the method you are building.
6620    ///
6621    /// See [`Self::add_scope()`] for details.
6622    pub fn add_scopes<I, St>(mut self, scopes: I) -> DataGaGetCall<'a, C>
6623    where
6624        I: IntoIterator<Item = St>,
6625        St: AsRef<str>,
6626    {
6627        self._scopes
6628            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6629        self
6630    }
6631
6632    /// Removes all scopes, and no default scope will be used either.
6633    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6634    /// for details).
6635    pub fn clear_scopes(mut self) -> DataGaGetCall<'a, C> {
6636        self._scopes.clear();
6637        self
6638    }
6639}
6640
6641/// Returns Analytics Multi-Channel Funnels data for a view (profile).
6642///
6643/// A builder for the *mcf.get* method supported by a *data* resource.
6644/// It is not used directly, but through a [`DataMethods`] instance.
6645///
6646/// # Example
6647///
6648/// Instantiate a resource method builder
6649///
6650/// ```test_harness,no_run
6651/// # extern crate hyper;
6652/// # extern crate hyper_rustls;
6653/// # extern crate google_analytics3 as analytics3;
6654/// # async fn dox() {
6655/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6656///
6657/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6658/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6659/// #     .with_native_roots()
6660/// #     .unwrap()
6661/// #     .https_only()
6662/// #     .enable_http2()
6663/// #     .build();
6664///
6665/// # let executor = hyper_util::rt::TokioExecutor::new();
6666/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6667/// #     secret,
6668/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6669/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6670/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6671/// #     ),
6672/// # ).build().await.unwrap();
6673///
6674/// # let client = hyper_util::client::legacy::Client::builder(
6675/// #     hyper_util::rt::TokioExecutor::new()
6676/// # )
6677/// # .build(
6678/// #     hyper_rustls::HttpsConnectorBuilder::new()
6679/// #         .with_native_roots()
6680/// #         .unwrap()
6681/// #         .https_or_http()
6682/// #         .enable_http2()
6683/// #         .build()
6684/// # );
6685/// # let mut hub = Analytics::new(client, auth);
6686/// // You can configure optional parameters by calling the respective setters at will, and
6687/// // execute the final call using `doit()`.
6688/// // Values shown here are possibly random and not representative !
6689/// let result = hub.data().mcf_get("ids", "start-date", "end-date", "metrics")
6690///              .start_index(-50)
6691///              .sort("est")
6692///              .sampling_level("gubergren")
6693///              .max_results(-17)
6694///              .filters("dolor")
6695///              .dimensions("Lorem")
6696///              .doit().await;
6697/// # }
6698/// ```
6699pub struct DataMcfGetCall<'a, C>
6700where
6701    C: 'a,
6702{
6703    hub: &'a Analytics<C>,
6704    _ids: String,
6705    _start_date: String,
6706    _end_date: String,
6707    _metrics: String,
6708    _start_index: Option<i32>,
6709    _sort: Option<String>,
6710    _sampling_level: Option<String>,
6711    _max_results: Option<i32>,
6712    _filters: Option<String>,
6713    _dimensions: Option<String>,
6714    _delegate: Option<&'a mut dyn common::Delegate>,
6715    _additional_params: HashMap<String, String>,
6716    _scopes: BTreeSet<String>,
6717}
6718
6719impl<'a, C> common::CallBuilder for DataMcfGetCall<'a, C> {}
6720
6721impl<'a, C> DataMcfGetCall<'a, C>
6722where
6723    C: common::Connector,
6724{
6725    /// Perform the operation you have build so far.
6726    pub async fn doit(mut self) -> common::Result<(common::Response, McfData)> {
6727        use std::borrow::Cow;
6728        use std::io::{Read, Seek};
6729
6730        use common::{url::Params, ToParts};
6731        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6732
6733        let mut dd = common::DefaultDelegate;
6734        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6735        dlg.begin(common::MethodInfo {
6736            id: "analytics.data.mcf.get",
6737            http_method: hyper::Method::GET,
6738        });
6739
6740        for &field in [
6741            "alt",
6742            "ids",
6743            "start-date",
6744            "end-date",
6745            "metrics",
6746            "start-index",
6747            "sort",
6748            "samplingLevel",
6749            "max-results",
6750            "filters",
6751            "dimensions",
6752        ]
6753        .iter()
6754        {
6755            if self._additional_params.contains_key(field) {
6756                dlg.finished(false);
6757                return Err(common::Error::FieldClash(field));
6758            }
6759        }
6760
6761        let mut params = Params::with_capacity(12 + self._additional_params.len());
6762        params.push("ids", self._ids);
6763        params.push("start-date", self._start_date);
6764        params.push("end-date", self._end_date);
6765        params.push("metrics", self._metrics);
6766        if let Some(value) = self._start_index.as_ref() {
6767            params.push("start-index", value.to_string());
6768        }
6769        if let Some(value) = self._sort.as_ref() {
6770            params.push("sort", value);
6771        }
6772        if let Some(value) = self._sampling_level.as_ref() {
6773            params.push("samplingLevel", value);
6774        }
6775        if let Some(value) = self._max_results.as_ref() {
6776            params.push("max-results", value.to_string());
6777        }
6778        if let Some(value) = self._filters.as_ref() {
6779            params.push("filters", value);
6780        }
6781        if let Some(value) = self._dimensions.as_ref() {
6782            params.push("dimensions", value);
6783        }
6784
6785        params.extend(self._additional_params.iter());
6786
6787        params.push("alt", "json");
6788        let mut url = self.hub._base_url.clone() + "data/mcf";
6789        if self._scopes.is_empty() {
6790            self._scopes.insert(Scope::Readonly.as_ref().to_string());
6791        }
6792
6793        let url = params.parse_with_url(&url);
6794
6795        loop {
6796            let token = match self
6797                .hub
6798                .auth
6799                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6800                .await
6801            {
6802                Ok(token) => token,
6803                Err(e) => match dlg.token(e) {
6804                    Ok(token) => token,
6805                    Err(e) => {
6806                        dlg.finished(false);
6807                        return Err(common::Error::MissingToken(e));
6808                    }
6809                },
6810            };
6811            let mut req_result = {
6812                let client = &self.hub.client;
6813                dlg.pre_request();
6814                let mut req_builder = hyper::Request::builder()
6815                    .method(hyper::Method::GET)
6816                    .uri(url.as_str())
6817                    .header(USER_AGENT, self.hub._user_agent.clone());
6818
6819                if let Some(token) = token.as_ref() {
6820                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6821                }
6822
6823                let request = req_builder
6824                    .header(CONTENT_LENGTH, 0_u64)
6825                    .body(common::to_body::<String>(None));
6826
6827                client.request(request.unwrap()).await
6828            };
6829
6830            match req_result {
6831                Err(err) => {
6832                    if let common::Retry::After(d) = dlg.http_error(&err) {
6833                        sleep(d).await;
6834                        continue;
6835                    }
6836                    dlg.finished(false);
6837                    return Err(common::Error::HttpError(err));
6838                }
6839                Ok(res) => {
6840                    let (mut parts, body) = res.into_parts();
6841                    let mut body = common::Body::new(body);
6842                    if !parts.status.is_success() {
6843                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6844                        let error = serde_json::from_str(&common::to_string(&bytes));
6845                        let response = common::to_response(parts, bytes.into());
6846
6847                        if let common::Retry::After(d) =
6848                            dlg.http_failure(&response, error.as_ref().ok())
6849                        {
6850                            sleep(d).await;
6851                            continue;
6852                        }
6853
6854                        dlg.finished(false);
6855
6856                        return Err(match error {
6857                            Ok(value) => common::Error::BadRequest(value),
6858                            _ => common::Error::Failure(response),
6859                        });
6860                    }
6861                    let response = {
6862                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6863                        let encoded = common::to_string(&bytes);
6864                        match serde_json::from_str(&encoded) {
6865                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6866                            Err(error) => {
6867                                dlg.response_json_decode_error(&encoded, &error);
6868                                return Err(common::Error::JsonDecodeError(
6869                                    encoded.to_string(),
6870                                    error,
6871                                ));
6872                            }
6873                        }
6874                    };
6875
6876                    dlg.finished(true);
6877                    return Ok(response);
6878                }
6879            }
6880        }
6881    }
6882
6883    /// Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
6884    ///
6885    /// Sets the *ids* query property to the given value.
6886    ///
6887    /// Even though the property as already been set when instantiating this call,
6888    /// we provide this method for API completeness.
6889    pub fn ids(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6890        self._ids = new_value.to_string();
6891        self
6892    }
6893    /// Start date for fetching Analytics data. Requests can specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is 7daysAgo.
6894    ///
6895    /// Sets the *start-date* query property to the given value.
6896    ///
6897    /// Even though the property as already been set when instantiating this call,
6898    /// we provide this method for API completeness.
6899    pub fn start_date(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6900        self._start_date = new_value.to_string();
6901        self
6902    }
6903    /// End date for fetching Analytics data. Requests can specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g., today, yesterday, or 7daysAgo). The default value is 7daysAgo.
6904    ///
6905    /// Sets the *end-date* query property to the given value.
6906    ///
6907    /// Even though the property as already been set when instantiating this call,
6908    /// we provide this method for API completeness.
6909    pub fn end_date(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6910        self._end_date = new_value.to_string();
6911        self
6912    }
6913    /// A comma-separated list of Multi-Channel Funnels metrics. E.g., 'mcf:totalConversions,mcf:totalConversionValue'. At least one metric must be specified.
6914    ///
6915    /// Sets the *metrics* query property to the given value.
6916    ///
6917    /// Even though the property as already been set when instantiating this call,
6918    /// we provide this method for API completeness.
6919    pub fn metrics(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6920        self._metrics = new_value.to_string();
6921        self
6922    }
6923    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
6924    ///
6925    /// Sets the *start-index* query property to the given value.
6926    pub fn start_index(mut self, new_value: i32) -> DataMcfGetCall<'a, C> {
6927        self._start_index = Some(new_value);
6928        self
6929    }
6930    /// A comma-separated list of dimensions or metrics that determine the sort order for the Analytics data.
6931    ///
6932    /// Sets the *sort* query property to the given value.
6933    pub fn sort(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6934        self._sort = Some(new_value.to_string());
6935        self
6936    }
6937    /// The desired sampling level.
6938    ///
6939    /// Sets the *sampling level* query property to the given value.
6940    pub fn sampling_level(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6941        self._sampling_level = Some(new_value.to_string());
6942        self
6943    }
6944    /// The maximum number of entries to include in this feed.
6945    ///
6946    /// Sets the *max-results* query property to the given value.
6947    pub fn max_results(mut self, new_value: i32) -> DataMcfGetCall<'a, C> {
6948        self._max_results = Some(new_value);
6949        self
6950    }
6951    /// A comma-separated list of dimension or metric filters to be applied to the Analytics data.
6952    ///
6953    /// Sets the *filters* query property to the given value.
6954    pub fn filters(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6955        self._filters = Some(new_value.to_string());
6956        self
6957    }
6958    /// A comma-separated list of Multi-Channel Funnels dimensions. E.g., 'mcf:source,mcf:medium'.
6959    ///
6960    /// Sets the *dimensions* query property to the given value.
6961    pub fn dimensions(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6962        self._dimensions = Some(new_value.to_string());
6963        self
6964    }
6965    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6966    /// while executing the actual API request.
6967    ///
6968    /// ````text
6969    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6970    /// ````
6971    ///
6972    /// Sets the *delegate* property to the given value.
6973    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DataMcfGetCall<'a, C> {
6974        self._delegate = Some(new_value);
6975        self
6976    }
6977
6978    /// Set any additional parameter of the query string used in the request.
6979    /// It should be used to set parameters which are not yet available through their own
6980    /// setters.
6981    ///
6982    /// Please note that this method must not be used to set any of the known parameters
6983    /// which have their own setter method. If done anyway, the request will fail.
6984    ///
6985    /// # Additional Parameters
6986    ///
6987    /// * *alt* (query-string) - Data format for the response.
6988    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6989    /// * *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.
6990    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6991    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6992    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6993    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6994    pub fn param<T>(mut self, name: T, value: T) -> DataMcfGetCall<'a, C>
6995    where
6996        T: AsRef<str>,
6997    {
6998        self._additional_params
6999            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7000        self
7001    }
7002
7003    /// Identifies the authorization scope for the method you are building.
7004    ///
7005    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7006    /// [`Scope::Readonly`].
7007    ///
7008    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7009    /// tokens for more than one scope.
7010    ///
7011    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7012    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7013    /// sufficient, a read-write scope will do as well.
7014    pub fn add_scope<St>(mut self, scope: St) -> DataMcfGetCall<'a, C>
7015    where
7016        St: AsRef<str>,
7017    {
7018        self._scopes.insert(String::from(scope.as_ref()));
7019        self
7020    }
7021    /// Identifies the authorization scope(s) for the method you are building.
7022    ///
7023    /// See [`Self::add_scope()`] for details.
7024    pub fn add_scopes<I, St>(mut self, scopes: I) -> DataMcfGetCall<'a, C>
7025    where
7026        I: IntoIterator<Item = St>,
7027        St: AsRef<str>,
7028    {
7029        self._scopes
7030            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7031        self
7032    }
7033
7034    /// Removes all scopes, and no default scope will be used either.
7035    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7036    /// for details).
7037    pub fn clear_scopes(mut self) -> DataMcfGetCall<'a, C> {
7038        self._scopes.clear();
7039        self
7040    }
7041}
7042
7043/// Returns real time data for a view (profile).
7044///
7045/// A builder for the *realtime.get* method supported by a *data* resource.
7046/// It is not used directly, but through a [`DataMethods`] instance.
7047///
7048/// # Example
7049///
7050/// Instantiate a resource method builder
7051///
7052/// ```test_harness,no_run
7053/// # extern crate hyper;
7054/// # extern crate hyper_rustls;
7055/// # extern crate google_analytics3 as analytics3;
7056/// # async fn dox() {
7057/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7058///
7059/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7060/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7061/// #     .with_native_roots()
7062/// #     .unwrap()
7063/// #     .https_only()
7064/// #     .enable_http2()
7065/// #     .build();
7066///
7067/// # let executor = hyper_util::rt::TokioExecutor::new();
7068/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7069/// #     secret,
7070/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7071/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7072/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7073/// #     ),
7074/// # ).build().await.unwrap();
7075///
7076/// # let client = hyper_util::client::legacy::Client::builder(
7077/// #     hyper_util::rt::TokioExecutor::new()
7078/// # )
7079/// # .build(
7080/// #     hyper_rustls::HttpsConnectorBuilder::new()
7081/// #         .with_native_roots()
7082/// #         .unwrap()
7083/// #         .https_or_http()
7084/// #         .enable_http2()
7085/// #         .build()
7086/// # );
7087/// # let mut hub = Analytics::new(client, auth);
7088/// // You can configure optional parameters by calling the respective setters at will, and
7089/// // execute the final call using `doit()`.
7090/// // Values shown here are possibly random and not representative !
7091/// let result = hub.data().realtime_get("ids", "metrics")
7092///              .sort("sed")
7093///              .max_results(-70)
7094///              .filters("sed")
7095///              .dimensions("no")
7096///              .doit().await;
7097/// # }
7098/// ```
7099pub struct DataRealtimeGetCall<'a, C>
7100where
7101    C: 'a,
7102{
7103    hub: &'a Analytics<C>,
7104    _ids: String,
7105    _metrics: String,
7106    _sort: Option<String>,
7107    _max_results: Option<i32>,
7108    _filters: Option<String>,
7109    _dimensions: Option<String>,
7110    _delegate: Option<&'a mut dyn common::Delegate>,
7111    _additional_params: HashMap<String, String>,
7112    _scopes: BTreeSet<String>,
7113}
7114
7115impl<'a, C> common::CallBuilder for DataRealtimeGetCall<'a, C> {}
7116
7117impl<'a, C> DataRealtimeGetCall<'a, C>
7118where
7119    C: common::Connector,
7120{
7121    /// Perform the operation you have build so far.
7122    pub async fn doit(mut self) -> common::Result<(common::Response, RealtimeData)> {
7123        use std::borrow::Cow;
7124        use std::io::{Read, Seek};
7125
7126        use common::{url::Params, ToParts};
7127        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7128
7129        let mut dd = common::DefaultDelegate;
7130        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7131        dlg.begin(common::MethodInfo {
7132            id: "analytics.data.realtime.get",
7133            http_method: hyper::Method::GET,
7134        });
7135
7136        for &field in [
7137            "alt",
7138            "ids",
7139            "metrics",
7140            "sort",
7141            "max-results",
7142            "filters",
7143            "dimensions",
7144        ]
7145        .iter()
7146        {
7147            if self._additional_params.contains_key(field) {
7148                dlg.finished(false);
7149                return Err(common::Error::FieldClash(field));
7150            }
7151        }
7152
7153        let mut params = Params::with_capacity(8 + self._additional_params.len());
7154        params.push("ids", self._ids);
7155        params.push("metrics", self._metrics);
7156        if let Some(value) = self._sort.as_ref() {
7157            params.push("sort", value);
7158        }
7159        if let Some(value) = self._max_results.as_ref() {
7160            params.push("max-results", value.to_string());
7161        }
7162        if let Some(value) = self._filters.as_ref() {
7163            params.push("filters", value);
7164        }
7165        if let Some(value) = self._dimensions.as_ref() {
7166            params.push("dimensions", value);
7167        }
7168
7169        params.extend(self._additional_params.iter());
7170
7171        params.push("alt", "json");
7172        let mut url = self.hub._base_url.clone() + "data/realtime";
7173        if self._scopes.is_empty() {
7174            self._scopes.insert(Scope::Readonly.as_ref().to_string());
7175        }
7176
7177        let url = params.parse_with_url(&url);
7178
7179        loop {
7180            let token = match self
7181                .hub
7182                .auth
7183                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7184                .await
7185            {
7186                Ok(token) => token,
7187                Err(e) => match dlg.token(e) {
7188                    Ok(token) => token,
7189                    Err(e) => {
7190                        dlg.finished(false);
7191                        return Err(common::Error::MissingToken(e));
7192                    }
7193                },
7194            };
7195            let mut req_result = {
7196                let client = &self.hub.client;
7197                dlg.pre_request();
7198                let mut req_builder = hyper::Request::builder()
7199                    .method(hyper::Method::GET)
7200                    .uri(url.as_str())
7201                    .header(USER_AGENT, self.hub._user_agent.clone());
7202
7203                if let Some(token) = token.as_ref() {
7204                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7205                }
7206
7207                let request = req_builder
7208                    .header(CONTENT_LENGTH, 0_u64)
7209                    .body(common::to_body::<String>(None));
7210
7211                client.request(request.unwrap()).await
7212            };
7213
7214            match req_result {
7215                Err(err) => {
7216                    if let common::Retry::After(d) = dlg.http_error(&err) {
7217                        sleep(d).await;
7218                        continue;
7219                    }
7220                    dlg.finished(false);
7221                    return Err(common::Error::HttpError(err));
7222                }
7223                Ok(res) => {
7224                    let (mut parts, body) = res.into_parts();
7225                    let mut body = common::Body::new(body);
7226                    if !parts.status.is_success() {
7227                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7228                        let error = serde_json::from_str(&common::to_string(&bytes));
7229                        let response = common::to_response(parts, bytes.into());
7230
7231                        if let common::Retry::After(d) =
7232                            dlg.http_failure(&response, error.as_ref().ok())
7233                        {
7234                            sleep(d).await;
7235                            continue;
7236                        }
7237
7238                        dlg.finished(false);
7239
7240                        return Err(match error {
7241                            Ok(value) => common::Error::BadRequest(value),
7242                            _ => common::Error::Failure(response),
7243                        });
7244                    }
7245                    let response = {
7246                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7247                        let encoded = common::to_string(&bytes);
7248                        match serde_json::from_str(&encoded) {
7249                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7250                            Err(error) => {
7251                                dlg.response_json_decode_error(&encoded, &error);
7252                                return Err(common::Error::JsonDecodeError(
7253                                    encoded.to_string(),
7254                                    error,
7255                                ));
7256                            }
7257                        }
7258                    };
7259
7260                    dlg.finished(true);
7261                    return Ok(response);
7262                }
7263            }
7264        }
7265    }
7266
7267    /// Unique table ID for retrieving real time data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
7268    ///
7269    /// Sets the *ids* query property to the given value.
7270    ///
7271    /// Even though the property as already been set when instantiating this call,
7272    /// we provide this method for API completeness.
7273    pub fn ids(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7274        self._ids = new_value.to_string();
7275        self
7276    }
7277    /// A comma-separated list of real time metrics. E.g., 'rt:activeUsers'. At least one metric must be specified.
7278    ///
7279    /// Sets the *metrics* query property to the given value.
7280    ///
7281    /// Even though the property as already been set when instantiating this call,
7282    /// we provide this method for API completeness.
7283    pub fn metrics(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7284        self._metrics = new_value.to_string();
7285        self
7286    }
7287    /// A comma-separated list of dimensions or metrics that determine the sort order for real time data.
7288    ///
7289    /// Sets the *sort* query property to the given value.
7290    pub fn sort(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7291        self._sort = Some(new_value.to_string());
7292        self
7293    }
7294    /// The maximum number of entries to include in this feed.
7295    ///
7296    /// Sets the *max-results* query property to the given value.
7297    pub fn max_results(mut self, new_value: i32) -> DataRealtimeGetCall<'a, C> {
7298        self._max_results = Some(new_value);
7299        self
7300    }
7301    /// A comma-separated list of dimension or metric filters to be applied to real time data.
7302    ///
7303    /// Sets the *filters* query property to the given value.
7304    pub fn filters(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7305        self._filters = Some(new_value.to_string());
7306        self
7307    }
7308    /// A comma-separated list of real time dimensions. E.g., 'rt:medium,rt:city'.
7309    ///
7310    /// Sets the *dimensions* query property to the given value.
7311    pub fn dimensions(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7312        self._dimensions = Some(new_value.to_string());
7313        self
7314    }
7315    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7316    /// while executing the actual API request.
7317    ///
7318    /// ````text
7319    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7320    /// ````
7321    ///
7322    /// Sets the *delegate* property to the given value.
7323    pub fn delegate(
7324        mut self,
7325        new_value: &'a mut dyn common::Delegate,
7326    ) -> DataRealtimeGetCall<'a, C> {
7327        self._delegate = Some(new_value);
7328        self
7329    }
7330
7331    /// Set any additional parameter of the query string used in the request.
7332    /// It should be used to set parameters which are not yet available through their own
7333    /// setters.
7334    ///
7335    /// Please note that this method must not be used to set any of the known parameters
7336    /// which have their own setter method. If done anyway, the request will fail.
7337    ///
7338    /// # Additional Parameters
7339    ///
7340    /// * *alt* (query-string) - Data format for the response.
7341    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7342    /// * *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.
7343    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7344    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7345    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7346    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7347    pub fn param<T>(mut self, name: T, value: T) -> DataRealtimeGetCall<'a, C>
7348    where
7349        T: AsRef<str>,
7350    {
7351        self._additional_params
7352            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7353        self
7354    }
7355
7356    /// Identifies the authorization scope for the method you are building.
7357    ///
7358    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7359    /// [`Scope::Readonly`].
7360    ///
7361    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7362    /// tokens for more than one scope.
7363    ///
7364    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7365    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7366    /// sufficient, a read-write scope will do as well.
7367    pub fn add_scope<St>(mut self, scope: St) -> DataRealtimeGetCall<'a, C>
7368    where
7369        St: AsRef<str>,
7370    {
7371        self._scopes.insert(String::from(scope.as_ref()));
7372        self
7373    }
7374    /// Identifies the authorization scope(s) for the method you are building.
7375    ///
7376    /// See [`Self::add_scope()`] for details.
7377    pub fn add_scopes<I, St>(mut self, scopes: I) -> DataRealtimeGetCall<'a, C>
7378    where
7379        I: IntoIterator<Item = St>,
7380        St: AsRef<str>,
7381    {
7382        self._scopes
7383            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7384        self
7385    }
7386
7387    /// Removes all scopes, and no default scope will be used either.
7388    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7389    /// for details).
7390    pub fn clear_scopes(mut self) -> DataRealtimeGetCall<'a, C> {
7391        self._scopes.clear();
7392        self
7393    }
7394}
7395
7396/// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
7397///
7398/// A builder for the *accountSummaries.list* method supported by a *management* resource.
7399/// It is not used directly, but through a [`ManagementMethods`] instance.
7400///
7401/// # Example
7402///
7403/// Instantiate a resource method builder
7404///
7405/// ```test_harness,no_run
7406/// # extern crate hyper;
7407/// # extern crate hyper_rustls;
7408/// # extern crate google_analytics3 as analytics3;
7409/// # async fn dox() {
7410/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7411///
7412/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7413/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7414/// #     .with_native_roots()
7415/// #     .unwrap()
7416/// #     .https_only()
7417/// #     .enable_http2()
7418/// #     .build();
7419///
7420/// # let executor = hyper_util::rt::TokioExecutor::new();
7421/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7422/// #     secret,
7423/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7424/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7425/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7426/// #     ),
7427/// # ).build().await.unwrap();
7428///
7429/// # let client = hyper_util::client::legacy::Client::builder(
7430/// #     hyper_util::rt::TokioExecutor::new()
7431/// # )
7432/// # .build(
7433/// #     hyper_rustls::HttpsConnectorBuilder::new()
7434/// #         .with_native_roots()
7435/// #         .unwrap()
7436/// #         .https_or_http()
7437/// #         .enable_http2()
7438/// #         .build()
7439/// # );
7440/// # let mut hub = Analytics::new(client, auth);
7441/// // You can configure optional parameters by calling the respective setters at will, and
7442/// // execute the final call using `doit()`.
7443/// // Values shown here are possibly random and not representative !
7444/// let result = hub.management().account_summaries_list()
7445///              .start_index(-15)
7446///              .max_results(-13)
7447///              .doit().await;
7448/// # }
7449/// ```
7450pub struct ManagementAccountSummaryListCall<'a, C>
7451where
7452    C: 'a,
7453{
7454    hub: &'a Analytics<C>,
7455    _start_index: Option<i32>,
7456    _max_results: Option<i32>,
7457    _delegate: Option<&'a mut dyn common::Delegate>,
7458    _additional_params: HashMap<String, String>,
7459    _scopes: BTreeSet<String>,
7460}
7461
7462impl<'a, C> common::CallBuilder for ManagementAccountSummaryListCall<'a, C> {}
7463
7464impl<'a, C> ManagementAccountSummaryListCall<'a, C>
7465where
7466    C: common::Connector,
7467{
7468    /// Perform the operation you have build so far.
7469    pub async fn doit(mut self) -> common::Result<(common::Response, AccountSummaries)> {
7470        use std::borrow::Cow;
7471        use std::io::{Read, Seek};
7472
7473        use common::{url::Params, ToParts};
7474        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7475
7476        let mut dd = common::DefaultDelegate;
7477        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7478        dlg.begin(common::MethodInfo {
7479            id: "analytics.management.accountSummaries.list",
7480            http_method: hyper::Method::GET,
7481        });
7482
7483        for &field in ["alt", "start-index", "max-results"].iter() {
7484            if self._additional_params.contains_key(field) {
7485                dlg.finished(false);
7486                return Err(common::Error::FieldClash(field));
7487            }
7488        }
7489
7490        let mut params = Params::with_capacity(4 + self._additional_params.len());
7491        if let Some(value) = self._start_index.as_ref() {
7492            params.push("start-index", value.to_string());
7493        }
7494        if let Some(value) = self._max_results.as_ref() {
7495            params.push("max-results", value.to_string());
7496        }
7497
7498        params.extend(self._additional_params.iter());
7499
7500        params.push("alt", "json");
7501        let mut url = self.hub._base_url.clone() + "management/accountSummaries";
7502        if self._scopes.is_empty() {
7503            self._scopes.insert(Scope::Readonly.as_ref().to_string());
7504        }
7505
7506        let url = params.parse_with_url(&url);
7507
7508        loop {
7509            let token = match self
7510                .hub
7511                .auth
7512                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7513                .await
7514            {
7515                Ok(token) => token,
7516                Err(e) => match dlg.token(e) {
7517                    Ok(token) => token,
7518                    Err(e) => {
7519                        dlg.finished(false);
7520                        return Err(common::Error::MissingToken(e));
7521                    }
7522                },
7523            };
7524            let mut req_result = {
7525                let client = &self.hub.client;
7526                dlg.pre_request();
7527                let mut req_builder = hyper::Request::builder()
7528                    .method(hyper::Method::GET)
7529                    .uri(url.as_str())
7530                    .header(USER_AGENT, self.hub._user_agent.clone());
7531
7532                if let Some(token) = token.as_ref() {
7533                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7534                }
7535
7536                let request = req_builder
7537                    .header(CONTENT_LENGTH, 0_u64)
7538                    .body(common::to_body::<String>(None));
7539
7540                client.request(request.unwrap()).await
7541            };
7542
7543            match req_result {
7544                Err(err) => {
7545                    if let common::Retry::After(d) = dlg.http_error(&err) {
7546                        sleep(d).await;
7547                        continue;
7548                    }
7549                    dlg.finished(false);
7550                    return Err(common::Error::HttpError(err));
7551                }
7552                Ok(res) => {
7553                    let (mut parts, body) = res.into_parts();
7554                    let mut body = common::Body::new(body);
7555                    if !parts.status.is_success() {
7556                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7557                        let error = serde_json::from_str(&common::to_string(&bytes));
7558                        let response = common::to_response(parts, bytes.into());
7559
7560                        if let common::Retry::After(d) =
7561                            dlg.http_failure(&response, error.as_ref().ok())
7562                        {
7563                            sleep(d).await;
7564                            continue;
7565                        }
7566
7567                        dlg.finished(false);
7568
7569                        return Err(match error {
7570                            Ok(value) => common::Error::BadRequest(value),
7571                            _ => common::Error::Failure(response),
7572                        });
7573                    }
7574                    let response = {
7575                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7576                        let encoded = common::to_string(&bytes);
7577                        match serde_json::from_str(&encoded) {
7578                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7579                            Err(error) => {
7580                                dlg.response_json_decode_error(&encoded, &error);
7581                                return Err(common::Error::JsonDecodeError(
7582                                    encoded.to_string(),
7583                                    error,
7584                                ));
7585                            }
7586                        }
7587                    };
7588
7589                    dlg.finished(true);
7590                    return Ok(response);
7591                }
7592            }
7593        }
7594    }
7595
7596    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
7597    ///
7598    /// Sets the *start-index* query property to the given value.
7599    pub fn start_index(mut self, new_value: i32) -> ManagementAccountSummaryListCall<'a, C> {
7600        self._start_index = Some(new_value);
7601        self
7602    }
7603    /// The maximum number of account summaries to include in this response, where the largest acceptable value is 1000.
7604    ///
7605    /// Sets the *max-results* query property to the given value.
7606    pub fn max_results(mut self, new_value: i32) -> ManagementAccountSummaryListCall<'a, C> {
7607        self._max_results = Some(new_value);
7608        self
7609    }
7610    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7611    /// while executing the actual API request.
7612    ///
7613    /// ````text
7614    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7615    /// ````
7616    ///
7617    /// Sets the *delegate* property to the given value.
7618    pub fn delegate(
7619        mut self,
7620        new_value: &'a mut dyn common::Delegate,
7621    ) -> ManagementAccountSummaryListCall<'a, C> {
7622        self._delegate = Some(new_value);
7623        self
7624    }
7625
7626    /// Set any additional parameter of the query string used in the request.
7627    /// It should be used to set parameters which are not yet available through their own
7628    /// setters.
7629    ///
7630    /// Please note that this method must not be used to set any of the known parameters
7631    /// which have their own setter method. If done anyway, the request will fail.
7632    ///
7633    /// # Additional Parameters
7634    ///
7635    /// * *alt* (query-string) - Data format for the response.
7636    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7637    /// * *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.
7638    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7639    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7640    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7641    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7642    pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountSummaryListCall<'a, C>
7643    where
7644        T: AsRef<str>,
7645    {
7646        self._additional_params
7647            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7648        self
7649    }
7650
7651    /// Identifies the authorization scope for the method you are building.
7652    ///
7653    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7654    /// [`Scope::Readonly`].
7655    ///
7656    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7657    /// tokens for more than one scope.
7658    ///
7659    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7660    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7661    /// sufficient, a read-write scope will do as well.
7662    pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountSummaryListCall<'a, C>
7663    where
7664        St: AsRef<str>,
7665    {
7666        self._scopes.insert(String::from(scope.as_ref()));
7667        self
7668    }
7669    /// Identifies the authorization scope(s) for the method you are building.
7670    ///
7671    /// See [`Self::add_scope()`] for details.
7672    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountSummaryListCall<'a, C>
7673    where
7674        I: IntoIterator<Item = St>,
7675        St: AsRef<str>,
7676    {
7677        self._scopes
7678            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7679        self
7680    }
7681
7682    /// Removes all scopes, and no default scope will be used either.
7683    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7684    /// for details).
7685    pub fn clear_scopes(mut self) -> ManagementAccountSummaryListCall<'a, C> {
7686        self._scopes.clear();
7687        self
7688    }
7689}
7690
7691/// Removes a user from the given account.
7692///
7693/// A builder for the *accountUserLinks.delete* method supported by a *management* resource.
7694/// It is not used directly, but through a [`ManagementMethods`] instance.
7695///
7696/// # Example
7697///
7698/// Instantiate a resource method builder
7699///
7700/// ```test_harness,no_run
7701/// # extern crate hyper;
7702/// # extern crate hyper_rustls;
7703/// # extern crate google_analytics3 as analytics3;
7704/// # async fn dox() {
7705/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7706///
7707/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7708/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7709/// #     .with_native_roots()
7710/// #     .unwrap()
7711/// #     .https_only()
7712/// #     .enable_http2()
7713/// #     .build();
7714///
7715/// # let executor = hyper_util::rt::TokioExecutor::new();
7716/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7717/// #     secret,
7718/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7719/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7720/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7721/// #     ),
7722/// # ).build().await.unwrap();
7723///
7724/// # let client = hyper_util::client::legacy::Client::builder(
7725/// #     hyper_util::rt::TokioExecutor::new()
7726/// # )
7727/// # .build(
7728/// #     hyper_rustls::HttpsConnectorBuilder::new()
7729/// #         .with_native_roots()
7730/// #         .unwrap()
7731/// #         .https_or_http()
7732/// #         .enable_http2()
7733/// #         .build()
7734/// # );
7735/// # let mut hub = Analytics::new(client, auth);
7736/// // You can configure optional parameters by calling the respective setters at will, and
7737/// // execute the final call using `doit()`.
7738/// // Values shown here are possibly random and not representative !
7739/// let result = hub.management().account_user_links_delete("accountId", "linkId")
7740///              .doit().await;
7741/// # }
7742/// ```
7743pub struct ManagementAccountUserLinkDeleteCall<'a, C>
7744where
7745    C: 'a,
7746{
7747    hub: &'a Analytics<C>,
7748    _account_id: String,
7749    _link_id: String,
7750    _delegate: Option<&'a mut dyn common::Delegate>,
7751    _additional_params: HashMap<String, String>,
7752    _scopes: BTreeSet<String>,
7753}
7754
7755impl<'a, C> common::CallBuilder for ManagementAccountUserLinkDeleteCall<'a, C> {}
7756
7757impl<'a, C> ManagementAccountUserLinkDeleteCall<'a, C>
7758where
7759    C: common::Connector,
7760{
7761    /// Perform the operation you have build so far.
7762    pub async fn doit(mut self) -> common::Result<common::Response> {
7763        use std::borrow::Cow;
7764        use std::io::{Read, Seek};
7765
7766        use common::{url::Params, ToParts};
7767        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7768
7769        let mut dd = common::DefaultDelegate;
7770        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7771        dlg.begin(common::MethodInfo {
7772            id: "analytics.management.accountUserLinks.delete",
7773            http_method: hyper::Method::DELETE,
7774        });
7775
7776        for &field in ["accountId", "linkId"].iter() {
7777            if self._additional_params.contains_key(field) {
7778                dlg.finished(false);
7779                return Err(common::Error::FieldClash(field));
7780            }
7781        }
7782
7783        let mut params = Params::with_capacity(3 + self._additional_params.len());
7784        params.push("accountId", self._account_id);
7785        params.push("linkId", self._link_id);
7786
7787        params.extend(self._additional_params.iter());
7788
7789        let mut url =
7790            self.hub._base_url.clone() + "management/accounts/{accountId}/entityUserLinks/{linkId}";
7791        if self._scopes.is_empty() {
7792            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
7793        }
7794
7795        #[allow(clippy::single_element_loop)]
7796        for &(find_this, param_name) in
7797            [("{accountId}", "accountId"), ("{linkId}", "linkId")].iter()
7798        {
7799            url = params.uri_replacement(url, param_name, find_this, false);
7800        }
7801        {
7802            let to_remove = ["linkId", "accountId"];
7803            params.remove_params(&to_remove);
7804        }
7805
7806        let url = params.parse_with_url(&url);
7807
7808        loop {
7809            let token = match self
7810                .hub
7811                .auth
7812                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7813                .await
7814            {
7815                Ok(token) => token,
7816                Err(e) => match dlg.token(e) {
7817                    Ok(token) => token,
7818                    Err(e) => {
7819                        dlg.finished(false);
7820                        return Err(common::Error::MissingToken(e));
7821                    }
7822                },
7823            };
7824            let mut req_result = {
7825                let client = &self.hub.client;
7826                dlg.pre_request();
7827                let mut req_builder = hyper::Request::builder()
7828                    .method(hyper::Method::DELETE)
7829                    .uri(url.as_str())
7830                    .header(USER_AGENT, self.hub._user_agent.clone());
7831
7832                if let Some(token) = token.as_ref() {
7833                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7834                }
7835
7836                let request = req_builder
7837                    .header(CONTENT_LENGTH, 0_u64)
7838                    .body(common::to_body::<String>(None));
7839
7840                client.request(request.unwrap()).await
7841            };
7842
7843            match req_result {
7844                Err(err) => {
7845                    if let common::Retry::After(d) = dlg.http_error(&err) {
7846                        sleep(d).await;
7847                        continue;
7848                    }
7849                    dlg.finished(false);
7850                    return Err(common::Error::HttpError(err));
7851                }
7852                Ok(res) => {
7853                    let (mut parts, body) = res.into_parts();
7854                    let mut body = common::Body::new(body);
7855                    if !parts.status.is_success() {
7856                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7857                        let error = serde_json::from_str(&common::to_string(&bytes));
7858                        let response = common::to_response(parts, bytes.into());
7859
7860                        if let common::Retry::After(d) =
7861                            dlg.http_failure(&response, error.as_ref().ok())
7862                        {
7863                            sleep(d).await;
7864                            continue;
7865                        }
7866
7867                        dlg.finished(false);
7868
7869                        return Err(match error {
7870                            Ok(value) => common::Error::BadRequest(value),
7871                            _ => common::Error::Failure(response),
7872                        });
7873                    }
7874                    let response = common::Response::from_parts(parts, body);
7875
7876                    dlg.finished(true);
7877                    return Ok(response);
7878                }
7879            }
7880        }
7881    }
7882
7883    /// Account ID to delete the user link for.
7884    ///
7885    /// Sets the *account id* path property to the given value.
7886    ///
7887    /// Even though the property as already been set when instantiating this call,
7888    /// we provide this method for API completeness.
7889    pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkDeleteCall<'a, C> {
7890        self._account_id = new_value.to_string();
7891        self
7892    }
7893    /// Link ID to delete the user link for.
7894    ///
7895    /// Sets the *link id* path property to the given value.
7896    ///
7897    /// Even though the property as already been set when instantiating this call,
7898    /// we provide this method for API completeness.
7899    pub fn link_id(mut self, new_value: &str) -> ManagementAccountUserLinkDeleteCall<'a, C> {
7900        self._link_id = new_value.to_string();
7901        self
7902    }
7903    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7904    /// while executing the actual API request.
7905    ///
7906    /// ````text
7907    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7908    /// ````
7909    ///
7910    /// Sets the *delegate* property to the given value.
7911    pub fn delegate(
7912        mut self,
7913        new_value: &'a mut dyn common::Delegate,
7914    ) -> ManagementAccountUserLinkDeleteCall<'a, C> {
7915        self._delegate = Some(new_value);
7916        self
7917    }
7918
7919    /// Set any additional parameter of the query string used in the request.
7920    /// It should be used to set parameters which are not yet available through their own
7921    /// setters.
7922    ///
7923    /// Please note that this method must not be used to set any of the known parameters
7924    /// which have their own setter method. If done anyway, the request will fail.
7925    ///
7926    /// # Additional Parameters
7927    ///
7928    /// * *alt* (query-string) - Data format for the response.
7929    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7930    /// * *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.
7931    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7932    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7933    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7934    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7935    pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountUserLinkDeleteCall<'a, C>
7936    where
7937        T: AsRef<str>,
7938    {
7939        self._additional_params
7940            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7941        self
7942    }
7943
7944    /// Identifies the authorization scope for the method you are building.
7945    ///
7946    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7947    /// [`Scope::ManageUser`].
7948    ///
7949    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7950    /// tokens for more than one scope.
7951    ///
7952    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7953    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7954    /// sufficient, a read-write scope will do as well.
7955    pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountUserLinkDeleteCall<'a, C>
7956    where
7957        St: AsRef<str>,
7958    {
7959        self._scopes.insert(String::from(scope.as_ref()));
7960        self
7961    }
7962    /// Identifies the authorization scope(s) for the method you are building.
7963    ///
7964    /// See [`Self::add_scope()`] for details.
7965    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountUserLinkDeleteCall<'a, C>
7966    where
7967        I: IntoIterator<Item = St>,
7968        St: AsRef<str>,
7969    {
7970        self._scopes
7971            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7972        self
7973    }
7974
7975    /// Removes all scopes, and no default scope will be used either.
7976    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7977    /// for details).
7978    pub fn clear_scopes(mut self) -> ManagementAccountUserLinkDeleteCall<'a, C> {
7979        self._scopes.clear();
7980        self
7981    }
7982}
7983
7984/// Adds a new user to the given account.
7985///
7986/// A builder for the *accountUserLinks.insert* method supported by a *management* resource.
7987/// It is not used directly, but through a [`ManagementMethods`] instance.
7988///
7989/// # Example
7990///
7991/// Instantiate a resource method builder
7992///
7993/// ```test_harness,no_run
7994/// # extern crate hyper;
7995/// # extern crate hyper_rustls;
7996/// # extern crate google_analytics3 as analytics3;
7997/// use analytics3::api::EntityUserLink;
7998/// # async fn dox() {
7999/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8000///
8001/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8002/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8003/// #     .with_native_roots()
8004/// #     .unwrap()
8005/// #     .https_only()
8006/// #     .enable_http2()
8007/// #     .build();
8008///
8009/// # let executor = hyper_util::rt::TokioExecutor::new();
8010/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8011/// #     secret,
8012/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8013/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8014/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8015/// #     ),
8016/// # ).build().await.unwrap();
8017///
8018/// # let client = hyper_util::client::legacy::Client::builder(
8019/// #     hyper_util::rt::TokioExecutor::new()
8020/// # )
8021/// # .build(
8022/// #     hyper_rustls::HttpsConnectorBuilder::new()
8023/// #         .with_native_roots()
8024/// #         .unwrap()
8025/// #         .https_or_http()
8026/// #         .enable_http2()
8027/// #         .build()
8028/// # );
8029/// # let mut hub = Analytics::new(client, auth);
8030/// // As the method needs a request, you would usually fill it with the desired information
8031/// // into the respective structure. Some of the parts shown here might not be applicable !
8032/// // Values shown here are possibly random and not representative !
8033/// let mut req = EntityUserLink::default();
8034///
8035/// // You can configure optional parameters by calling the respective setters at will, and
8036/// // execute the final call using `doit()`.
8037/// // Values shown here are possibly random and not representative !
8038/// let result = hub.management().account_user_links_insert(req, "accountId")
8039///              .doit().await;
8040/// # }
8041/// ```
8042pub struct ManagementAccountUserLinkInsertCall<'a, C>
8043where
8044    C: 'a,
8045{
8046    hub: &'a Analytics<C>,
8047    _request: EntityUserLink,
8048    _account_id: String,
8049    _delegate: Option<&'a mut dyn common::Delegate>,
8050    _additional_params: HashMap<String, String>,
8051    _scopes: BTreeSet<String>,
8052}
8053
8054impl<'a, C> common::CallBuilder for ManagementAccountUserLinkInsertCall<'a, C> {}
8055
8056impl<'a, C> ManagementAccountUserLinkInsertCall<'a, C>
8057where
8058    C: common::Connector,
8059{
8060    /// Perform the operation you have build so far.
8061    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
8062        use std::borrow::Cow;
8063        use std::io::{Read, Seek};
8064
8065        use common::{url::Params, ToParts};
8066        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8067
8068        let mut dd = common::DefaultDelegate;
8069        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8070        dlg.begin(common::MethodInfo {
8071            id: "analytics.management.accountUserLinks.insert",
8072            http_method: hyper::Method::POST,
8073        });
8074
8075        for &field in ["alt", "accountId"].iter() {
8076            if self._additional_params.contains_key(field) {
8077                dlg.finished(false);
8078                return Err(common::Error::FieldClash(field));
8079            }
8080        }
8081
8082        let mut params = Params::with_capacity(4 + self._additional_params.len());
8083        params.push("accountId", self._account_id);
8084
8085        params.extend(self._additional_params.iter());
8086
8087        params.push("alt", "json");
8088        let mut url =
8089            self.hub._base_url.clone() + "management/accounts/{accountId}/entityUserLinks";
8090        if self._scopes.is_empty() {
8091            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
8092        }
8093
8094        #[allow(clippy::single_element_loop)]
8095        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
8096            url = params.uri_replacement(url, param_name, find_this, false);
8097        }
8098        {
8099            let to_remove = ["accountId"];
8100            params.remove_params(&to_remove);
8101        }
8102
8103        let url = params.parse_with_url(&url);
8104
8105        let mut json_mime_type = mime::APPLICATION_JSON;
8106        let mut request_value_reader = {
8107            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8108            common::remove_json_null_values(&mut value);
8109            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8110            serde_json::to_writer(&mut dst, &value).unwrap();
8111            dst
8112        };
8113        let request_size = request_value_reader
8114            .seek(std::io::SeekFrom::End(0))
8115            .unwrap();
8116        request_value_reader
8117            .seek(std::io::SeekFrom::Start(0))
8118            .unwrap();
8119
8120        loop {
8121            let token = match self
8122                .hub
8123                .auth
8124                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8125                .await
8126            {
8127                Ok(token) => token,
8128                Err(e) => match dlg.token(e) {
8129                    Ok(token) => token,
8130                    Err(e) => {
8131                        dlg.finished(false);
8132                        return Err(common::Error::MissingToken(e));
8133                    }
8134                },
8135            };
8136            request_value_reader
8137                .seek(std::io::SeekFrom::Start(0))
8138                .unwrap();
8139            let mut req_result = {
8140                let client = &self.hub.client;
8141                dlg.pre_request();
8142                let mut req_builder = hyper::Request::builder()
8143                    .method(hyper::Method::POST)
8144                    .uri(url.as_str())
8145                    .header(USER_AGENT, self.hub._user_agent.clone());
8146
8147                if let Some(token) = token.as_ref() {
8148                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8149                }
8150
8151                let request = req_builder
8152                    .header(CONTENT_TYPE, json_mime_type.to_string())
8153                    .header(CONTENT_LENGTH, request_size as u64)
8154                    .body(common::to_body(
8155                        request_value_reader.get_ref().clone().into(),
8156                    ));
8157
8158                client.request(request.unwrap()).await
8159            };
8160
8161            match req_result {
8162                Err(err) => {
8163                    if let common::Retry::After(d) = dlg.http_error(&err) {
8164                        sleep(d).await;
8165                        continue;
8166                    }
8167                    dlg.finished(false);
8168                    return Err(common::Error::HttpError(err));
8169                }
8170                Ok(res) => {
8171                    let (mut parts, body) = res.into_parts();
8172                    let mut body = common::Body::new(body);
8173                    if !parts.status.is_success() {
8174                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8175                        let error = serde_json::from_str(&common::to_string(&bytes));
8176                        let response = common::to_response(parts, bytes.into());
8177
8178                        if let common::Retry::After(d) =
8179                            dlg.http_failure(&response, error.as_ref().ok())
8180                        {
8181                            sleep(d).await;
8182                            continue;
8183                        }
8184
8185                        dlg.finished(false);
8186
8187                        return Err(match error {
8188                            Ok(value) => common::Error::BadRequest(value),
8189                            _ => common::Error::Failure(response),
8190                        });
8191                    }
8192                    let response = {
8193                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8194                        let encoded = common::to_string(&bytes);
8195                        match serde_json::from_str(&encoded) {
8196                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8197                            Err(error) => {
8198                                dlg.response_json_decode_error(&encoded, &error);
8199                                return Err(common::Error::JsonDecodeError(
8200                                    encoded.to_string(),
8201                                    error,
8202                                ));
8203                            }
8204                        }
8205                    };
8206
8207                    dlg.finished(true);
8208                    return Ok(response);
8209                }
8210            }
8211        }
8212    }
8213
8214    ///
8215    /// Sets the *request* property to the given value.
8216    ///
8217    /// Even though the property as already been set when instantiating this call,
8218    /// we provide this method for API completeness.
8219    pub fn request(
8220        mut self,
8221        new_value: EntityUserLink,
8222    ) -> ManagementAccountUserLinkInsertCall<'a, C> {
8223        self._request = new_value;
8224        self
8225    }
8226    /// Account ID to create the user link for.
8227    ///
8228    /// Sets the *account id* path property to the given value.
8229    ///
8230    /// Even though the property as already been set when instantiating this call,
8231    /// we provide this method for API completeness.
8232    pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkInsertCall<'a, C> {
8233        self._account_id = new_value.to_string();
8234        self
8235    }
8236    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8237    /// while executing the actual API request.
8238    ///
8239    /// ````text
8240    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8241    /// ````
8242    ///
8243    /// Sets the *delegate* property to the given value.
8244    pub fn delegate(
8245        mut self,
8246        new_value: &'a mut dyn common::Delegate,
8247    ) -> ManagementAccountUserLinkInsertCall<'a, C> {
8248        self._delegate = Some(new_value);
8249        self
8250    }
8251
8252    /// Set any additional parameter of the query string used in the request.
8253    /// It should be used to set parameters which are not yet available through their own
8254    /// setters.
8255    ///
8256    /// Please note that this method must not be used to set any of the known parameters
8257    /// which have their own setter method. If done anyway, the request will fail.
8258    ///
8259    /// # Additional Parameters
8260    ///
8261    /// * *alt* (query-string) - Data format for the response.
8262    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8263    /// * *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.
8264    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8265    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8266    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8267    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8268    pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountUserLinkInsertCall<'a, C>
8269    where
8270        T: AsRef<str>,
8271    {
8272        self._additional_params
8273            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8274        self
8275    }
8276
8277    /// Identifies the authorization scope for the method you are building.
8278    ///
8279    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8280    /// [`Scope::ManageUser`].
8281    ///
8282    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8283    /// tokens for more than one scope.
8284    ///
8285    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8286    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8287    /// sufficient, a read-write scope will do as well.
8288    pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountUserLinkInsertCall<'a, C>
8289    where
8290        St: AsRef<str>,
8291    {
8292        self._scopes.insert(String::from(scope.as_ref()));
8293        self
8294    }
8295    /// Identifies the authorization scope(s) for the method you are building.
8296    ///
8297    /// See [`Self::add_scope()`] for details.
8298    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountUserLinkInsertCall<'a, C>
8299    where
8300        I: IntoIterator<Item = St>,
8301        St: AsRef<str>,
8302    {
8303        self._scopes
8304            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8305        self
8306    }
8307
8308    /// Removes all scopes, and no default scope will be used either.
8309    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8310    /// for details).
8311    pub fn clear_scopes(mut self) -> ManagementAccountUserLinkInsertCall<'a, C> {
8312        self._scopes.clear();
8313        self
8314    }
8315}
8316
8317/// Lists account-user links for a given account.
8318///
8319/// A builder for the *accountUserLinks.list* method supported by a *management* resource.
8320/// It is not used directly, but through a [`ManagementMethods`] instance.
8321///
8322/// # Example
8323///
8324/// Instantiate a resource method builder
8325///
8326/// ```test_harness,no_run
8327/// # extern crate hyper;
8328/// # extern crate hyper_rustls;
8329/// # extern crate google_analytics3 as analytics3;
8330/// # async fn dox() {
8331/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8332///
8333/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8334/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8335/// #     .with_native_roots()
8336/// #     .unwrap()
8337/// #     .https_only()
8338/// #     .enable_http2()
8339/// #     .build();
8340///
8341/// # let executor = hyper_util::rt::TokioExecutor::new();
8342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8343/// #     secret,
8344/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8345/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8346/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8347/// #     ),
8348/// # ).build().await.unwrap();
8349///
8350/// # let client = hyper_util::client::legacy::Client::builder(
8351/// #     hyper_util::rt::TokioExecutor::new()
8352/// # )
8353/// # .build(
8354/// #     hyper_rustls::HttpsConnectorBuilder::new()
8355/// #         .with_native_roots()
8356/// #         .unwrap()
8357/// #         .https_or_http()
8358/// #         .enable_http2()
8359/// #         .build()
8360/// # );
8361/// # let mut hub = Analytics::new(client, auth);
8362/// // You can configure optional parameters by calling the respective setters at will, and
8363/// // execute the final call using `doit()`.
8364/// // Values shown here are possibly random and not representative !
8365/// let result = hub.management().account_user_links_list("accountId")
8366///              .start_index(-76)
8367///              .max_results(-31)
8368///              .doit().await;
8369/// # }
8370/// ```
8371pub struct ManagementAccountUserLinkListCall<'a, C>
8372where
8373    C: 'a,
8374{
8375    hub: &'a Analytics<C>,
8376    _account_id: String,
8377    _start_index: Option<i32>,
8378    _max_results: Option<i32>,
8379    _delegate: Option<&'a mut dyn common::Delegate>,
8380    _additional_params: HashMap<String, String>,
8381    _scopes: BTreeSet<String>,
8382}
8383
8384impl<'a, C> common::CallBuilder for ManagementAccountUserLinkListCall<'a, C> {}
8385
8386impl<'a, C> ManagementAccountUserLinkListCall<'a, C>
8387where
8388    C: common::Connector,
8389{
8390    /// Perform the operation you have build so far.
8391    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLinks)> {
8392        use std::borrow::Cow;
8393        use std::io::{Read, Seek};
8394
8395        use common::{url::Params, ToParts};
8396        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8397
8398        let mut dd = common::DefaultDelegate;
8399        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8400        dlg.begin(common::MethodInfo {
8401            id: "analytics.management.accountUserLinks.list",
8402            http_method: hyper::Method::GET,
8403        });
8404
8405        for &field in ["alt", "accountId", "start-index", "max-results"].iter() {
8406            if self._additional_params.contains_key(field) {
8407                dlg.finished(false);
8408                return Err(common::Error::FieldClash(field));
8409            }
8410        }
8411
8412        let mut params = Params::with_capacity(5 + self._additional_params.len());
8413        params.push("accountId", self._account_id);
8414        if let Some(value) = self._start_index.as_ref() {
8415            params.push("start-index", value.to_string());
8416        }
8417        if let Some(value) = self._max_results.as_ref() {
8418            params.push("max-results", value.to_string());
8419        }
8420
8421        params.extend(self._additional_params.iter());
8422
8423        params.push("alt", "json");
8424        let mut url =
8425            self.hub._base_url.clone() + "management/accounts/{accountId}/entityUserLinks";
8426        if self._scopes.is_empty() {
8427            self._scopes
8428                .insert(Scope::ManageUserReadonly.as_ref().to_string());
8429        }
8430
8431        #[allow(clippy::single_element_loop)]
8432        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
8433            url = params.uri_replacement(url, param_name, find_this, false);
8434        }
8435        {
8436            let to_remove = ["accountId"];
8437            params.remove_params(&to_remove);
8438        }
8439
8440        let url = params.parse_with_url(&url);
8441
8442        loop {
8443            let token = match self
8444                .hub
8445                .auth
8446                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8447                .await
8448            {
8449                Ok(token) => token,
8450                Err(e) => match dlg.token(e) {
8451                    Ok(token) => token,
8452                    Err(e) => {
8453                        dlg.finished(false);
8454                        return Err(common::Error::MissingToken(e));
8455                    }
8456                },
8457            };
8458            let mut req_result = {
8459                let client = &self.hub.client;
8460                dlg.pre_request();
8461                let mut req_builder = hyper::Request::builder()
8462                    .method(hyper::Method::GET)
8463                    .uri(url.as_str())
8464                    .header(USER_AGENT, self.hub._user_agent.clone());
8465
8466                if let Some(token) = token.as_ref() {
8467                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8468                }
8469
8470                let request = req_builder
8471                    .header(CONTENT_LENGTH, 0_u64)
8472                    .body(common::to_body::<String>(None));
8473
8474                client.request(request.unwrap()).await
8475            };
8476
8477            match req_result {
8478                Err(err) => {
8479                    if let common::Retry::After(d) = dlg.http_error(&err) {
8480                        sleep(d).await;
8481                        continue;
8482                    }
8483                    dlg.finished(false);
8484                    return Err(common::Error::HttpError(err));
8485                }
8486                Ok(res) => {
8487                    let (mut parts, body) = res.into_parts();
8488                    let mut body = common::Body::new(body);
8489                    if !parts.status.is_success() {
8490                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8491                        let error = serde_json::from_str(&common::to_string(&bytes));
8492                        let response = common::to_response(parts, bytes.into());
8493
8494                        if let common::Retry::After(d) =
8495                            dlg.http_failure(&response, error.as_ref().ok())
8496                        {
8497                            sleep(d).await;
8498                            continue;
8499                        }
8500
8501                        dlg.finished(false);
8502
8503                        return Err(match error {
8504                            Ok(value) => common::Error::BadRequest(value),
8505                            _ => common::Error::Failure(response),
8506                        });
8507                    }
8508                    let response = {
8509                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8510                        let encoded = common::to_string(&bytes);
8511                        match serde_json::from_str(&encoded) {
8512                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8513                            Err(error) => {
8514                                dlg.response_json_decode_error(&encoded, &error);
8515                                return Err(common::Error::JsonDecodeError(
8516                                    encoded.to_string(),
8517                                    error,
8518                                ));
8519                            }
8520                        }
8521                    };
8522
8523                    dlg.finished(true);
8524                    return Ok(response);
8525                }
8526            }
8527        }
8528    }
8529
8530    /// Account ID to retrieve the user links for.
8531    ///
8532    /// Sets the *account id* path property to the given value.
8533    ///
8534    /// Even though the property as already been set when instantiating this call,
8535    /// we provide this method for API completeness.
8536    pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkListCall<'a, C> {
8537        self._account_id = new_value.to_string();
8538        self
8539    }
8540    /// An index of the first account-user link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
8541    ///
8542    /// Sets the *start-index* query property to the given value.
8543    pub fn start_index(mut self, new_value: i32) -> ManagementAccountUserLinkListCall<'a, C> {
8544        self._start_index = Some(new_value);
8545        self
8546    }
8547    /// The maximum number of account-user links to include in this response.
8548    ///
8549    /// Sets the *max-results* query property to the given value.
8550    pub fn max_results(mut self, new_value: i32) -> ManagementAccountUserLinkListCall<'a, C> {
8551        self._max_results = Some(new_value);
8552        self
8553    }
8554    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8555    /// while executing the actual API request.
8556    ///
8557    /// ````text
8558    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8559    /// ````
8560    ///
8561    /// Sets the *delegate* property to the given value.
8562    pub fn delegate(
8563        mut self,
8564        new_value: &'a mut dyn common::Delegate,
8565    ) -> ManagementAccountUserLinkListCall<'a, C> {
8566        self._delegate = Some(new_value);
8567        self
8568    }
8569
8570    /// Set any additional parameter of the query string used in the request.
8571    /// It should be used to set parameters which are not yet available through their own
8572    /// setters.
8573    ///
8574    /// Please note that this method must not be used to set any of the known parameters
8575    /// which have their own setter method. If done anyway, the request will fail.
8576    ///
8577    /// # Additional Parameters
8578    ///
8579    /// * *alt* (query-string) - Data format for the response.
8580    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8581    /// * *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.
8582    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8583    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8584    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8585    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8586    pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountUserLinkListCall<'a, C>
8587    where
8588        T: AsRef<str>,
8589    {
8590        self._additional_params
8591            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8592        self
8593    }
8594
8595    /// Identifies the authorization scope for the method you are building.
8596    ///
8597    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8598    /// [`Scope::ManageUserReadonly`].
8599    ///
8600    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8601    /// tokens for more than one scope.
8602    ///
8603    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8604    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8605    /// sufficient, a read-write scope will do as well.
8606    pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountUserLinkListCall<'a, C>
8607    where
8608        St: AsRef<str>,
8609    {
8610        self._scopes.insert(String::from(scope.as_ref()));
8611        self
8612    }
8613    /// Identifies the authorization scope(s) for the method you are building.
8614    ///
8615    /// See [`Self::add_scope()`] for details.
8616    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountUserLinkListCall<'a, C>
8617    where
8618        I: IntoIterator<Item = St>,
8619        St: AsRef<str>,
8620    {
8621        self._scopes
8622            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8623        self
8624    }
8625
8626    /// Removes all scopes, and no default scope will be used either.
8627    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8628    /// for details).
8629    pub fn clear_scopes(mut self) -> ManagementAccountUserLinkListCall<'a, C> {
8630        self._scopes.clear();
8631        self
8632    }
8633}
8634
8635/// Updates permissions for an existing user on the given account.
8636///
8637/// A builder for the *accountUserLinks.update* method supported by a *management* resource.
8638/// It is not used directly, but through a [`ManagementMethods`] instance.
8639///
8640/// # Example
8641///
8642/// Instantiate a resource method builder
8643///
8644/// ```test_harness,no_run
8645/// # extern crate hyper;
8646/// # extern crate hyper_rustls;
8647/// # extern crate google_analytics3 as analytics3;
8648/// use analytics3::api::EntityUserLink;
8649/// # async fn dox() {
8650/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8651///
8652/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8653/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8654/// #     .with_native_roots()
8655/// #     .unwrap()
8656/// #     .https_only()
8657/// #     .enable_http2()
8658/// #     .build();
8659///
8660/// # let executor = hyper_util::rt::TokioExecutor::new();
8661/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8662/// #     secret,
8663/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8664/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8665/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8666/// #     ),
8667/// # ).build().await.unwrap();
8668///
8669/// # let client = hyper_util::client::legacy::Client::builder(
8670/// #     hyper_util::rt::TokioExecutor::new()
8671/// # )
8672/// # .build(
8673/// #     hyper_rustls::HttpsConnectorBuilder::new()
8674/// #         .with_native_roots()
8675/// #         .unwrap()
8676/// #         .https_or_http()
8677/// #         .enable_http2()
8678/// #         .build()
8679/// # );
8680/// # let mut hub = Analytics::new(client, auth);
8681/// // As the method needs a request, you would usually fill it with the desired information
8682/// // into the respective structure. Some of the parts shown here might not be applicable !
8683/// // Values shown here are possibly random and not representative !
8684/// let mut req = EntityUserLink::default();
8685///
8686/// // You can configure optional parameters by calling the respective setters at will, and
8687/// // execute the final call using `doit()`.
8688/// // Values shown here are possibly random and not representative !
8689/// let result = hub.management().account_user_links_update(req, "accountId", "linkId")
8690///              .doit().await;
8691/// # }
8692/// ```
8693pub struct ManagementAccountUserLinkUpdateCall<'a, C>
8694where
8695    C: 'a,
8696{
8697    hub: &'a Analytics<C>,
8698    _request: EntityUserLink,
8699    _account_id: String,
8700    _link_id: String,
8701    _delegate: Option<&'a mut dyn common::Delegate>,
8702    _additional_params: HashMap<String, String>,
8703    _scopes: BTreeSet<String>,
8704}
8705
8706impl<'a, C> common::CallBuilder for ManagementAccountUserLinkUpdateCall<'a, C> {}
8707
8708impl<'a, C> ManagementAccountUserLinkUpdateCall<'a, C>
8709where
8710    C: common::Connector,
8711{
8712    /// Perform the operation you have build so far.
8713    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
8714        use std::borrow::Cow;
8715        use std::io::{Read, Seek};
8716
8717        use common::{url::Params, ToParts};
8718        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8719
8720        let mut dd = common::DefaultDelegate;
8721        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8722        dlg.begin(common::MethodInfo {
8723            id: "analytics.management.accountUserLinks.update",
8724            http_method: hyper::Method::PUT,
8725        });
8726
8727        for &field in ["alt", "accountId", "linkId"].iter() {
8728            if self._additional_params.contains_key(field) {
8729                dlg.finished(false);
8730                return Err(common::Error::FieldClash(field));
8731            }
8732        }
8733
8734        let mut params = Params::with_capacity(5 + self._additional_params.len());
8735        params.push("accountId", self._account_id);
8736        params.push("linkId", self._link_id);
8737
8738        params.extend(self._additional_params.iter());
8739
8740        params.push("alt", "json");
8741        let mut url =
8742            self.hub._base_url.clone() + "management/accounts/{accountId}/entityUserLinks/{linkId}";
8743        if self._scopes.is_empty() {
8744            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
8745        }
8746
8747        #[allow(clippy::single_element_loop)]
8748        for &(find_this, param_name) in
8749            [("{accountId}", "accountId"), ("{linkId}", "linkId")].iter()
8750        {
8751            url = params.uri_replacement(url, param_name, find_this, false);
8752        }
8753        {
8754            let to_remove = ["linkId", "accountId"];
8755            params.remove_params(&to_remove);
8756        }
8757
8758        let url = params.parse_with_url(&url);
8759
8760        let mut json_mime_type = mime::APPLICATION_JSON;
8761        let mut request_value_reader = {
8762            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8763            common::remove_json_null_values(&mut value);
8764            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8765            serde_json::to_writer(&mut dst, &value).unwrap();
8766            dst
8767        };
8768        let request_size = request_value_reader
8769            .seek(std::io::SeekFrom::End(0))
8770            .unwrap();
8771        request_value_reader
8772            .seek(std::io::SeekFrom::Start(0))
8773            .unwrap();
8774
8775        loop {
8776            let token = match self
8777                .hub
8778                .auth
8779                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8780                .await
8781            {
8782                Ok(token) => token,
8783                Err(e) => match dlg.token(e) {
8784                    Ok(token) => token,
8785                    Err(e) => {
8786                        dlg.finished(false);
8787                        return Err(common::Error::MissingToken(e));
8788                    }
8789                },
8790            };
8791            request_value_reader
8792                .seek(std::io::SeekFrom::Start(0))
8793                .unwrap();
8794            let mut req_result = {
8795                let client = &self.hub.client;
8796                dlg.pre_request();
8797                let mut req_builder = hyper::Request::builder()
8798                    .method(hyper::Method::PUT)
8799                    .uri(url.as_str())
8800                    .header(USER_AGENT, self.hub._user_agent.clone());
8801
8802                if let Some(token) = token.as_ref() {
8803                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8804                }
8805
8806                let request = req_builder
8807                    .header(CONTENT_TYPE, json_mime_type.to_string())
8808                    .header(CONTENT_LENGTH, request_size as u64)
8809                    .body(common::to_body(
8810                        request_value_reader.get_ref().clone().into(),
8811                    ));
8812
8813                client.request(request.unwrap()).await
8814            };
8815
8816            match req_result {
8817                Err(err) => {
8818                    if let common::Retry::After(d) = dlg.http_error(&err) {
8819                        sleep(d).await;
8820                        continue;
8821                    }
8822                    dlg.finished(false);
8823                    return Err(common::Error::HttpError(err));
8824                }
8825                Ok(res) => {
8826                    let (mut parts, body) = res.into_parts();
8827                    let mut body = common::Body::new(body);
8828                    if !parts.status.is_success() {
8829                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8830                        let error = serde_json::from_str(&common::to_string(&bytes));
8831                        let response = common::to_response(parts, bytes.into());
8832
8833                        if let common::Retry::After(d) =
8834                            dlg.http_failure(&response, error.as_ref().ok())
8835                        {
8836                            sleep(d).await;
8837                            continue;
8838                        }
8839
8840                        dlg.finished(false);
8841
8842                        return Err(match error {
8843                            Ok(value) => common::Error::BadRequest(value),
8844                            _ => common::Error::Failure(response),
8845                        });
8846                    }
8847                    let response = {
8848                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8849                        let encoded = common::to_string(&bytes);
8850                        match serde_json::from_str(&encoded) {
8851                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8852                            Err(error) => {
8853                                dlg.response_json_decode_error(&encoded, &error);
8854                                return Err(common::Error::JsonDecodeError(
8855                                    encoded.to_string(),
8856                                    error,
8857                                ));
8858                            }
8859                        }
8860                    };
8861
8862                    dlg.finished(true);
8863                    return Ok(response);
8864                }
8865            }
8866        }
8867    }
8868
8869    ///
8870    /// Sets the *request* property to the given value.
8871    ///
8872    /// Even though the property as already been set when instantiating this call,
8873    /// we provide this method for API completeness.
8874    pub fn request(
8875        mut self,
8876        new_value: EntityUserLink,
8877    ) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8878        self._request = new_value;
8879        self
8880    }
8881    /// Account ID to update the account-user link for.
8882    ///
8883    /// Sets the *account id* path property to the given value.
8884    ///
8885    /// Even though the property as already been set when instantiating this call,
8886    /// we provide this method for API completeness.
8887    pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8888        self._account_id = new_value.to_string();
8889        self
8890    }
8891    /// Link ID to update the account-user link for.
8892    ///
8893    /// Sets the *link id* path property to the given value.
8894    ///
8895    /// Even though the property as already been set when instantiating this call,
8896    /// we provide this method for API completeness.
8897    pub fn link_id(mut self, new_value: &str) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8898        self._link_id = new_value.to_string();
8899        self
8900    }
8901    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8902    /// while executing the actual API request.
8903    ///
8904    /// ````text
8905    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8906    /// ````
8907    ///
8908    /// Sets the *delegate* property to the given value.
8909    pub fn delegate(
8910        mut self,
8911        new_value: &'a mut dyn common::Delegate,
8912    ) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8913        self._delegate = Some(new_value);
8914        self
8915    }
8916
8917    /// Set any additional parameter of the query string used in the request.
8918    /// It should be used to set parameters which are not yet available through their own
8919    /// setters.
8920    ///
8921    /// Please note that this method must not be used to set any of the known parameters
8922    /// which have their own setter method. If done anyway, the request will fail.
8923    ///
8924    /// # Additional Parameters
8925    ///
8926    /// * *alt* (query-string) - Data format for the response.
8927    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8928    /// * *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.
8929    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8930    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8931    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8932    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8933    pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountUserLinkUpdateCall<'a, C>
8934    where
8935        T: AsRef<str>,
8936    {
8937        self._additional_params
8938            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8939        self
8940    }
8941
8942    /// Identifies the authorization scope for the method you are building.
8943    ///
8944    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8945    /// [`Scope::ManageUser`].
8946    ///
8947    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8948    /// tokens for more than one scope.
8949    ///
8950    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8951    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8952    /// sufficient, a read-write scope will do as well.
8953    pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountUserLinkUpdateCall<'a, C>
8954    where
8955        St: AsRef<str>,
8956    {
8957        self._scopes.insert(String::from(scope.as_ref()));
8958        self
8959    }
8960    /// Identifies the authorization scope(s) for the method you are building.
8961    ///
8962    /// See [`Self::add_scope()`] for details.
8963    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountUserLinkUpdateCall<'a, C>
8964    where
8965        I: IntoIterator<Item = St>,
8966        St: AsRef<str>,
8967    {
8968        self._scopes
8969            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8970        self
8971    }
8972
8973    /// Removes all scopes, and no default scope will be used either.
8974    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8975    /// for details).
8976    pub fn clear_scopes(mut self) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8977        self._scopes.clear();
8978        self
8979    }
8980}
8981
8982/// Lists all accounts to which the user has access.
8983///
8984/// A builder for the *accounts.list* method supported by a *management* resource.
8985/// It is not used directly, but through a [`ManagementMethods`] instance.
8986///
8987/// # Example
8988///
8989/// Instantiate a resource method builder
8990///
8991/// ```test_harness,no_run
8992/// # extern crate hyper;
8993/// # extern crate hyper_rustls;
8994/// # extern crate google_analytics3 as analytics3;
8995/// # async fn dox() {
8996/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8997///
8998/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8999/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9000/// #     .with_native_roots()
9001/// #     .unwrap()
9002/// #     .https_only()
9003/// #     .enable_http2()
9004/// #     .build();
9005///
9006/// # let executor = hyper_util::rt::TokioExecutor::new();
9007/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9008/// #     secret,
9009/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9010/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9011/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9012/// #     ),
9013/// # ).build().await.unwrap();
9014///
9015/// # let client = hyper_util::client::legacy::Client::builder(
9016/// #     hyper_util::rt::TokioExecutor::new()
9017/// # )
9018/// # .build(
9019/// #     hyper_rustls::HttpsConnectorBuilder::new()
9020/// #         .with_native_roots()
9021/// #         .unwrap()
9022/// #         .https_or_http()
9023/// #         .enable_http2()
9024/// #         .build()
9025/// # );
9026/// # let mut hub = Analytics::new(client, auth);
9027/// // You can configure optional parameters by calling the respective setters at will, and
9028/// // execute the final call using `doit()`.
9029/// // Values shown here are possibly random and not representative !
9030/// let result = hub.management().accounts_list()
9031///              .start_index(-34)
9032///              .max_results(-22)
9033///              .doit().await;
9034/// # }
9035/// ```
9036pub struct ManagementAccountListCall<'a, C>
9037where
9038    C: 'a,
9039{
9040    hub: &'a Analytics<C>,
9041    _start_index: Option<i32>,
9042    _max_results: Option<i32>,
9043    _delegate: Option<&'a mut dyn common::Delegate>,
9044    _additional_params: HashMap<String, String>,
9045    _scopes: BTreeSet<String>,
9046}
9047
9048impl<'a, C> common::CallBuilder for ManagementAccountListCall<'a, C> {}
9049
9050impl<'a, C> ManagementAccountListCall<'a, C>
9051where
9052    C: common::Connector,
9053{
9054    /// Perform the operation you have build so far.
9055    pub async fn doit(mut self) -> common::Result<(common::Response, Accounts)> {
9056        use std::borrow::Cow;
9057        use std::io::{Read, Seek};
9058
9059        use common::{url::Params, ToParts};
9060        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9061
9062        let mut dd = common::DefaultDelegate;
9063        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9064        dlg.begin(common::MethodInfo {
9065            id: "analytics.management.accounts.list",
9066            http_method: hyper::Method::GET,
9067        });
9068
9069        for &field in ["alt", "start-index", "max-results"].iter() {
9070            if self._additional_params.contains_key(field) {
9071                dlg.finished(false);
9072                return Err(common::Error::FieldClash(field));
9073            }
9074        }
9075
9076        let mut params = Params::with_capacity(4 + self._additional_params.len());
9077        if let Some(value) = self._start_index.as_ref() {
9078            params.push("start-index", value.to_string());
9079        }
9080        if let Some(value) = self._max_results.as_ref() {
9081            params.push("max-results", value.to_string());
9082        }
9083
9084        params.extend(self._additional_params.iter());
9085
9086        params.push("alt", "json");
9087        let mut url = self.hub._base_url.clone() + "management/accounts";
9088        if self._scopes.is_empty() {
9089            self._scopes.insert(Scope::Readonly.as_ref().to_string());
9090        }
9091
9092        let url = params.parse_with_url(&url);
9093
9094        loop {
9095            let token = match self
9096                .hub
9097                .auth
9098                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9099                .await
9100            {
9101                Ok(token) => token,
9102                Err(e) => match dlg.token(e) {
9103                    Ok(token) => token,
9104                    Err(e) => {
9105                        dlg.finished(false);
9106                        return Err(common::Error::MissingToken(e));
9107                    }
9108                },
9109            };
9110            let mut req_result = {
9111                let client = &self.hub.client;
9112                dlg.pre_request();
9113                let mut req_builder = hyper::Request::builder()
9114                    .method(hyper::Method::GET)
9115                    .uri(url.as_str())
9116                    .header(USER_AGENT, self.hub._user_agent.clone());
9117
9118                if let Some(token) = token.as_ref() {
9119                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9120                }
9121
9122                let request = req_builder
9123                    .header(CONTENT_LENGTH, 0_u64)
9124                    .body(common::to_body::<String>(None));
9125
9126                client.request(request.unwrap()).await
9127            };
9128
9129            match req_result {
9130                Err(err) => {
9131                    if let common::Retry::After(d) = dlg.http_error(&err) {
9132                        sleep(d).await;
9133                        continue;
9134                    }
9135                    dlg.finished(false);
9136                    return Err(common::Error::HttpError(err));
9137                }
9138                Ok(res) => {
9139                    let (mut parts, body) = res.into_parts();
9140                    let mut body = common::Body::new(body);
9141                    if !parts.status.is_success() {
9142                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9143                        let error = serde_json::from_str(&common::to_string(&bytes));
9144                        let response = common::to_response(parts, bytes.into());
9145
9146                        if let common::Retry::After(d) =
9147                            dlg.http_failure(&response, error.as_ref().ok())
9148                        {
9149                            sleep(d).await;
9150                            continue;
9151                        }
9152
9153                        dlg.finished(false);
9154
9155                        return Err(match error {
9156                            Ok(value) => common::Error::BadRequest(value),
9157                            _ => common::Error::Failure(response),
9158                        });
9159                    }
9160                    let response = {
9161                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9162                        let encoded = common::to_string(&bytes);
9163                        match serde_json::from_str(&encoded) {
9164                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9165                            Err(error) => {
9166                                dlg.response_json_decode_error(&encoded, &error);
9167                                return Err(common::Error::JsonDecodeError(
9168                                    encoded.to_string(),
9169                                    error,
9170                                ));
9171                            }
9172                        }
9173                    };
9174
9175                    dlg.finished(true);
9176                    return Ok(response);
9177                }
9178            }
9179        }
9180    }
9181
9182    /// An index of the first account to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
9183    ///
9184    /// Sets the *start-index* query property to the given value.
9185    pub fn start_index(mut self, new_value: i32) -> ManagementAccountListCall<'a, C> {
9186        self._start_index = Some(new_value);
9187        self
9188    }
9189    /// The maximum number of accounts to include in this response.
9190    ///
9191    /// Sets the *max-results* query property to the given value.
9192    pub fn max_results(mut self, new_value: i32) -> ManagementAccountListCall<'a, C> {
9193        self._max_results = Some(new_value);
9194        self
9195    }
9196    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9197    /// while executing the actual API request.
9198    ///
9199    /// ````text
9200    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9201    /// ````
9202    ///
9203    /// Sets the *delegate* property to the given value.
9204    pub fn delegate(
9205        mut self,
9206        new_value: &'a mut dyn common::Delegate,
9207    ) -> ManagementAccountListCall<'a, C> {
9208        self._delegate = Some(new_value);
9209        self
9210    }
9211
9212    /// Set any additional parameter of the query string used in the request.
9213    /// It should be used to set parameters which are not yet available through their own
9214    /// setters.
9215    ///
9216    /// Please note that this method must not be used to set any of the known parameters
9217    /// which have their own setter method. If done anyway, the request will fail.
9218    ///
9219    /// # Additional Parameters
9220    ///
9221    /// * *alt* (query-string) - Data format for the response.
9222    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9223    /// * *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.
9224    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9225    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9226    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9227    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9228    pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountListCall<'a, C>
9229    where
9230        T: AsRef<str>,
9231    {
9232        self._additional_params
9233            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9234        self
9235    }
9236
9237    /// Identifies the authorization scope for the method you are building.
9238    ///
9239    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9240    /// [`Scope::Readonly`].
9241    ///
9242    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9243    /// tokens for more than one scope.
9244    ///
9245    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9246    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9247    /// sufficient, a read-write scope will do as well.
9248    pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountListCall<'a, C>
9249    where
9250        St: AsRef<str>,
9251    {
9252        self._scopes.insert(String::from(scope.as_ref()));
9253        self
9254    }
9255    /// Identifies the authorization scope(s) for the method you are building.
9256    ///
9257    /// See [`Self::add_scope()`] for details.
9258    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountListCall<'a, C>
9259    where
9260        I: IntoIterator<Item = St>,
9261        St: AsRef<str>,
9262    {
9263        self._scopes
9264            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9265        self
9266    }
9267
9268    /// Removes all scopes, and no default scope will be used either.
9269    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9270    /// for details).
9271    pub fn clear_scopes(mut self) -> ManagementAccountListCall<'a, C> {
9272        self._scopes.clear();
9273        self
9274    }
9275}
9276
9277/// Hashes the given Client ID.
9278///
9279/// A builder for the *clientId.hashClientId* method supported by a *management* resource.
9280/// It is not used directly, but through a [`ManagementMethods`] instance.
9281///
9282/// # Example
9283///
9284/// Instantiate a resource method builder
9285///
9286/// ```test_harness,no_run
9287/// # extern crate hyper;
9288/// # extern crate hyper_rustls;
9289/// # extern crate google_analytics3 as analytics3;
9290/// use analytics3::api::HashClientIdRequest;
9291/// # async fn dox() {
9292/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9293///
9294/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9295/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9296/// #     .with_native_roots()
9297/// #     .unwrap()
9298/// #     .https_only()
9299/// #     .enable_http2()
9300/// #     .build();
9301///
9302/// # let executor = hyper_util::rt::TokioExecutor::new();
9303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9304/// #     secret,
9305/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9306/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9307/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9308/// #     ),
9309/// # ).build().await.unwrap();
9310///
9311/// # let client = hyper_util::client::legacy::Client::builder(
9312/// #     hyper_util::rt::TokioExecutor::new()
9313/// # )
9314/// # .build(
9315/// #     hyper_rustls::HttpsConnectorBuilder::new()
9316/// #         .with_native_roots()
9317/// #         .unwrap()
9318/// #         .https_or_http()
9319/// #         .enable_http2()
9320/// #         .build()
9321/// # );
9322/// # let mut hub = Analytics::new(client, auth);
9323/// // As the method needs a request, you would usually fill it with the desired information
9324/// // into the respective structure. Some of the parts shown here might not be applicable !
9325/// // Values shown here are possibly random and not representative !
9326/// let mut req = HashClientIdRequest::default();
9327///
9328/// // You can configure optional parameters by calling the respective setters at will, and
9329/// // execute the final call using `doit()`.
9330/// // Values shown here are possibly random and not representative !
9331/// let result = hub.management().client_id_hash_client_id(req)
9332///              .doit().await;
9333/// # }
9334/// ```
9335pub struct ManagementClientIdHashClientIdCall<'a, C>
9336where
9337    C: 'a,
9338{
9339    hub: &'a Analytics<C>,
9340    _request: HashClientIdRequest,
9341    _delegate: Option<&'a mut dyn common::Delegate>,
9342    _additional_params: HashMap<String, String>,
9343    _scopes: BTreeSet<String>,
9344}
9345
9346impl<'a, C> common::CallBuilder for ManagementClientIdHashClientIdCall<'a, C> {}
9347
9348impl<'a, C> ManagementClientIdHashClientIdCall<'a, C>
9349where
9350    C: common::Connector,
9351{
9352    /// Perform the operation you have build so far.
9353    pub async fn doit(mut self) -> common::Result<(common::Response, HashClientIdResponse)> {
9354        use std::borrow::Cow;
9355        use std::io::{Read, Seek};
9356
9357        use common::{url::Params, ToParts};
9358        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9359
9360        let mut dd = common::DefaultDelegate;
9361        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9362        dlg.begin(common::MethodInfo {
9363            id: "analytics.management.clientId.hashClientId",
9364            http_method: hyper::Method::POST,
9365        });
9366
9367        for &field in ["alt"].iter() {
9368            if self._additional_params.contains_key(field) {
9369                dlg.finished(false);
9370                return Err(common::Error::FieldClash(field));
9371            }
9372        }
9373
9374        let mut params = Params::with_capacity(3 + self._additional_params.len());
9375
9376        params.extend(self._additional_params.iter());
9377
9378        params.push("alt", "json");
9379        let mut url = self.hub._base_url.clone() + "management/clientId:hashClientId";
9380        if self._scopes.is_empty() {
9381            self._scopes.insert(Scope::Readonly.as_ref().to_string());
9382        }
9383
9384        let url = params.parse_with_url(&url);
9385
9386        let mut json_mime_type = mime::APPLICATION_JSON;
9387        let mut request_value_reader = {
9388            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9389            common::remove_json_null_values(&mut value);
9390            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9391            serde_json::to_writer(&mut dst, &value).unwrap();
9392            dst
9393        };
9394        let request_size = request_value_reader
9395            .seek(std::io::SeekFrom::End(0))
9396            .unwrap();
9397        request_value_reader
9398            .seek(std::io::SeekFrom::Start(0))
9399            .unwrap();
9400
9401        loop {
9402            let token = match self
9403                .hub
9404                .auth
9405                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9406                .await
9407            {
9408                Ok(token) => token,
9409                Err(e) => match dlg.token(e) {
9410                    Ok(token) => token,
9411                    Err(e) => {
9412                        dlg.finished(false);
9413                        return Err(common::Error::MissingToken(e));
9414                    }
9415                },
9416            };
9417            request_value_reader
9418                .seek(std::io::SeekFrom::Start(0))
9419                .unwrap();
9420            let mut req_result = {
9421                let client = &self.hub.client;
9422                dlg.pre_request();
9423                let mut req_builder = hyper::Request::builder()
9424                    .method(hyper::Method::POST)
9425                    .uri(url.as_str())
9426                    .header(USER_AGENT, self.hub._user_agent.clone());
9427
9428                if let Some(token) = token.as_ref() {
9429                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9430                }
9431
9432                let request = req_builder
9433                    .header(CONTENT_TYPE, json_mime_type.to_string())
9434                    .header(CONTENT_LENGTH, request_size as u64)
9435                    .body(common::to_body(
9436                        request_value_reader.get_ref().clone().into(),
9437                    ));
9438
9439                client.request(request.unwrap()).await
9440            };
9441
9442            match req_result {
9443                Err(err) => {
9444                    if let common::Retry::After(d) = dlg.http_error(&err) {
9445                        sleep(d).await;
9446                        continue;
9447                    }
9448                    dlg.finished(false);
9449                    return Err(common::Error::HttpError(err));
9450                }
9451                Ok(res) => {
9452                    let (mut parts, body) = res.into_parts();
9453                    let mut body = common::Body::new(body);
9454                    if !parts.status.is_success() {
9455                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9456                        let error = serde_json::from_str(&common::to_string(&bytes));
9457                        let response = common::to_response(parts, bytes.into());
9458
9459                        if let common::Retry::After(d) =
9460                            dlg.http_failure(&response, error.as_ref().ok())
9461                        {
9462                            sleep(d).await;
9463                            continue;
9464                        }
9465
9466                        dlg.finished(false);
9467
9468                        return Err(match error {
9469                            Ok(value) => common::Error::BadRequest(value),
9470                            _ => common::Error::Failure(response),
9471                        });
9472                    }
9473                    let response = {
9474                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9475                        let encoded = common::to_string(&bytes);
9476                        match serde_json::from_str(&encoded) {
9477                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9478                            Err(error) => {
9479                                dlg.response_json_decode_error(&encoded, &error);
9480                                return Err(common::Error::JsonDecodeError(
9481                                    encoded.to_string(),
9482                                    error,
9483                                ));
9484                            }
9485                        }
9486                    };
9487
9488                    dlg.finished(true);
9489                    return Ok(response);
9490                }
9491            }
9492        }
9493    }
9494
9495    ///
9496    /// Sets the *request* property to the given value.
9497    ///
9498    /// Even though the property as already been set when instantiating this call,
9499    /// we provide this method for API completeness.
9500    pub fn request(
9501        mut self,
9502        new_value: HashClientIdRequest,
9503    ) -> ManagementClientIdHashClientIdCall<'a, C> {
9504        self._request = new_value;
9505        self
9506    }
9507    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9508    /// while executing the actual API request.
9509    ///
9510    /// ````text
9511    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9512    /// ````
9513    ///
9514    /// Sets the *delegate* property to the given value.
9515    pub fn delegate(
9516        mut self,
9517        new_value: &'a mut dyn common::Delegate,
9518    ) -> ManagementClientIdHashClientIdCall<'a, C> {
9519        self._delegate = Some(new_value);
9520        self
9521    }
9522
9523    /// Set any additional parameter of the query string used in the request.
9524    /// It should be used to set parameters which are not yet available through their own
9525    /// setters.
9526    ///
9527    /// Please note that this method must not be used to set any of the known parameters
9528    /// which have their own setter method. If done anyway, the request will fail.
9529    ///
9530    /// # Additional Parameters
9531    ///
9532    /// * *alt* (query-string) - Data format for the response.
9533    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9534    /// * *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.
9535    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9536    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9537    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9538    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9539    pub fn param<T>(mut self, name: T, value: T) -> ManagementClientIdHashClientIdCall<'a, C>
9540    where
9541        T: AsRef<str>,
9542    {
9543        self._additional_params
9544            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9545        self
9546    }
9547
9548    /// Identifies the authorization scope for the method you are building.
9549    ///
9550    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9551    /// [`Scope::Readonly`].
9552    ///
9553    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9554    /// tokens for more than one scope.
9555    ///
9556    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9557    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9558    /// sufficient, a read-write scope will do as well.
9559    pub fn add_scope<St>(mut self, scope: St) -> ManagementClientIdHashClientIdCall<'a, C>
9560    where
9561        St: AsRef<str>,
9562    {
9563        self._scopes.insert(String::from(scope.as_ref()));
9564        self
9565    }
9566    /// Identifies the authorization scope(s) for the method you are building.
9567    ///
9568    /// See [`Self::add_scope()`] for details.
9569    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementClientIdHashClientIdCall<'a, C>
9570    where
9571        I: IntoIterator<Item = St>,
9572        St: AsRef<str>,
9573    {
9574        self._scopes
9575            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9576        self
9577    }
9578
9579    /// Removes all scopes, and no default scope will be used either.
9580    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9581    /// for details).
9582    pub fn clear_scopes(mut self) -> ManagementClientIdHashClientIdCall<'a, C> {
9583        self._scopes.clear();
9584        self
9585    }
9586}
9587
9588/// List custom data sources to which the user has access.
9589///
9590/// A builder for the *customDataSources.list* method supported by a *management* resource.
9591/// It is not used directly, but through a [`ManagementMethods`] instance.
9592///
9593/// # Example
9594///
9595/// Instantiate a resource method builder
9596///
9597/// ```test_harness,no_run
9598/// # extern crate hyper;
9599/// # extern crate hyper_rustls;
9600/// # extern crate google_analytics3 as analytics3;
9601/// # async fn dox() {
9602/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9603///
9604/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9605/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9606/// #     .with_native_roots()
9607/// #     .unwrap()
9608/// #     .https_only()
9609/// #     .enable_http2()
9610/// #     .build();
9611///
9612/// # let executor = hyper_util::rt::TokioExecutor::new();
9613/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9614/// #     secret,
9615/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9616/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9617/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9618/// #     ),
9619/// # ).build().await.unwrap();
9620///
9621/// # let client = hyper_util::client::legacy::Client::builder(
9622/// #     hyper_util::rt::TokioExecutor::new()
9623/// # )
9624/// # .build(
9625/// #     hyper_rustls::HttpsConnectorBuilder::new()
9626/// #         .with_native_roots()
9627/// #         .unwrap()
9628/// #         .https_or_http()
9629/// #         .enable_http2()
9630/// #         .build()
9631/// # );
9632/// # let mut hub = Analytics::new(client, auth);
9633/// // You can configure optional parameters by calling the respective setters at will, and
9634/// // execute the final call using `doit()`.
9635/// // Values shown here are possibly random and not representative !
9636/// let result = hub.management().custom_data_sources_list("accountId", "webPropertyId")
9637///              .start_index(-96)
9638///              .max_results(-92)
9639///              .doit().await;
9640/// # }
9641/// ```
9642pub struct ManagementCustomDataSourceListCall<'a, C>
9643where
9644    C: 'a,
9645{
9646    hub: &'a Analytics<C>,
9647    _account_id: String,
9648    _web_property_id: String,
9649    _start_index: Option<i32>,
9650    _max_results: Option<i32>,
9651    _delegate: Option<&'a mut dyn common::Delegate>,
9652    _additional_params: HashMap<String, String>,
9653    _scopes: BTreeSet<String>,
9654}
9655
9656impl<'a, C> common::CallBuilder for ManagementCustomDataSourceListCall<'a, C> {}
9657
9658impl<'a, C> ManagementCustomDataSourceListCall<'a, C>
9659where
9660    C: common::Connector,
9661{
9662    /// Perform the operation you have build so far.
9663    pub async fn doit(mut self) -> common::Result<(common::Response, CustomDataSources)> {
9664        use std::borrow::Cow;
9665        use std::io::{Read, Seek};
9666
9667        use common::{url::Params, ToParts};
9668        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9669
9670        let mut dd = common::DefaultDelegate;
9671        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9672        dlg.begin(common::MethodInfo {
9673            id: "analytics.management.customDataSources.list",
9674            http_method: hyper::Method::GET,
9675        });
9676
9677        for &field in [
9678            "alt",
9679            "accountId",
9680            "webPropertyId",
9681            "start-index",
9682            "max-results",
9683        ]
9684        .iter()
9685        {
9686            if self._additional_params.contains_key(field) {
9687                dlg.finished(false);
9688                return Err(common::Error::FieldClash(field));
9689            }
9690        }
9691
9692        let mut params = Params::with_capacity(6 + self._additional_params.len());
9693        params.push("accountId", self._account_id);
9694        params.push("webPropertyId", self._web_property_id);
9695        if let Some(value) = self._start_index.as_ref() {
9696            params.push("start-index", value.to_string());
9697        }
9698        if let Some(value) = self._max_results.as_ref() {
9699            params.push("max-results", value.to_string());
9700        }
9701
9702        params.extend(self._additional_params.iter());
9703
9704        params.push("alt", "json");
9705        let mut url = self.hub._base_url.clone()
9706            + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources";
9707        if self._scopes.is_empty() {
9708            self._scopes.insert(Scope::Readonly.as_ref().to_string());
9709        }
9710
9711        #[allow(clippy::single_element_loop)]
9712        for &(find_this, param_name) in [
9713            ("{accountId}", "accountId"),
9714            ("{webPropertyId}", "webPropertyId"),
9715        ]
9716        .iter()
9717        {
9718            url = params.uri_replacement(url, param_name, find_this, false);
9719        }
9720        {
9721            let to_remove = ["webPropertyId", "accountId"];
9722            params.remove_params(&to_remove);
9723        }
9724
9725        let url = params.parse_with_url(&url);
9726
9727        loop {
9728            let token = match self
9729                .hub
9730                .auth
9731                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9732                .await
9733            {
9734                Ok(token) => token,
9735                Err(e) => match dlg.token(e) {
9736                    Ok(token) => token,
9737                    Err(e) => {
9738                        dlg.finished(false);
9739                        return Err(common::Error::MissingToken(e));
9740                    }
9741                },
9742            };
9743            let mut req_result = {
9744                let client = &self.hub.client;
9745                dlg.pre_request();
9746                let mut req_builder = hyper::Request::builder()
9747                    .method(hyper::Method::GET)
9748                    .uri(url.as_str())
9749                    .header(USER_AGENT, self.hub._user_agent.clone());
9750
9751                if let Some(token) = token.as_ref() {
9752                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9753                }
9754
9755                let request = req_builder
9756                    .header(CONTENT_LENGTH, 0_u64)
9757                    .body(common::to_body::<String>(None));
9758
9759                client.request(request.unwrap()).await
9760            };
9761
9762            match req_result {
9763                Err(err) => {
9764                    if let common::Retry::After(d) = dlg.http_error(&err) {
9765                        sleep(d).await;
9766                        continue;
9767                    }
9768                    dlg.finished(false);
9769                    return Err(common::Error::HttpError(err));
9770                }
9771                Ok(res) => {
9772                    let (mut parts, body) = res.into_parts();
9773                    let mut body = common::Body::new(body);
9774                    if !parts.status.is_success() {
9775                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9776                        let error = serde_json::from_str(&common::to_string(&bytes));
9777                        let response = common::to_response(parts, bytes.into());
9778
9779                        if let common::Retry::After(d) =
9780                            dlg.http_failure(&response, error.as_ref().ok())
9781                        {
9782                            sleep(d).await;
9783                            continue;
9784                        }
9785
9786                        dlg.finished(false);
9787
9788                        return Err(match error {
9789                            Ok(value) => common::Error::BadRequest(value),
9790                            _ => common::Error::Failure(response),
9791                        });
9792                    }
9793                    let response = {
9794                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9795                        let encoded = common::to_string(&bytes);
9796                        match serde_json::from_str(&encoded) {
9797                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9798                            Err(error) => {
9799                                dlg.response_json_decode_error(&encoded, &error);
9800                                return Err(common::Error::JsonDecodeError(
9801                                    encoded.to_string(),
9802                                    error,
9803                                ));
9804                            }
9805                        }
9806                    };
9807
9808                    dlg.finished(true);
9809                    return Ok(response);
9810                }
9811            }
9812        }
9813    }
9814
9815    /// Account Id for the custom data sources to retrieve.
9816    ///
9817    /// Sets the *account id* path property to the given value.
9818    ///
9819    /// Even though the property as already been set when instantiating this call,
9820    /// we provide this method for API completeness.
9821    pub fn account_id(mut self, new_value: &str) -> ManagementCustomDataSourceListCall<'a, C> {
9822        self._account_id = new_value.to_string();
9823        self
9824    }
9825    /// Web property Id for the custom data sources to retrieve.
9826    ///
9827    /// Sets the *web property id* path property to the given value.
9828    ///
9829    /// Even though the property as already been set when instantiating this call,
9830    /// we provide this method for API completeness.
9831    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomDataSourceListCall<'a, C> {
9832        self._web_property_id = new_value.to_string();
9833        self
9834    }
9835    /// A 1-based index of the first custom data source to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
9836    ///
9837    /// Sets the *start-index* query property to the given value.
9838    pub fn start_index(mut self, new_value: i32) -> ManagementCustomDataSourceListCall<'a, C> {
9839        self._start_index = Some(new_value);
9840        self
9841    }
9842    /// The maximum number of custom data sources to include in this response.
9843    ///
9844    /// Sets the *max-results* query property to the given value.
9845    pub fn max_results(mut self, new_value: i32) -> ManagementCustomDataSourceListCall<'a, C> {
9846        self._max_results = Some(new_value);
9847        self
9848    }
9849    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9850    /// while executing the actual API request.
9851    ///
9852    /// ````text
9853    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9854    /// ````
9855    ///
9856    /// Sets the *delegate* property to the given value.
9857    pub fn delegate(
9858        mut self,
9859        new_value: &'a mut dyn common::Delegate,
9860    ) -> ManagementCustomDataSourceListCall<'a, C> {
9861        self._delegate = Some(new_value);
9862        self
9863    }
9864
9865    /// Set any additional parameter of the query string used in the request.
9866    /// It should be used to set parameters which are not yet available through their own
9867    /// setters.
9868    ///
9869    /// Please note that this method must not be used to set any of the known parameters
9870    /// which have their own setter method. If done anyway, the request will fail.
9871    ///
9872    /// # Additional Parameters
9873    ///
9874    /// * *alt* (query-string) - Data format for the response.
9875    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9876    /// * *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.
9877    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9878    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9879    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9880    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9881    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDataSourceListCall<'a, C>
9882    where
9883        T: AsRef<str>,
9884    {
9885        self._additional_params
9886            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9887        self
9888    }
9889
9890    /// Identifies the authorization scope for the method you are building.
9891    ///
9892    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9893    /// [`Scope::Readonly`].
9894    ///
9895    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9896    /// tokens for more than one scope.
9897    ///
9898    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9899    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9900    /// sufficient, a read-write scope will do as well.
9901    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDataSourceListCall<'a, C>
9902    where
9903        St: AsRef<str>,
9904    {
9905        self._scopes.insert(String::from(scope.as_ref()));
9906        self
9907    }
9908    /// Identifies the authorization scope(s) for the method you are building.
9909    ///
9910    /// See [`Self::add_scope()`] for details.
9911    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDataSourceListCall<'a, C>
9912    where
9913        I: IntoIterator<Item = St>,
9914        St: AsRef<str>,
9915    {
9916        self._scopes
9917            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9918        self
9919    }
9920
9921    /// Removes all scopes, and no default scope will be used either.
9922    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9923    /// for details).
9924    pub fn clear_scopes(mut self) -> ManagementCustomDataSourceListCall<'a, C> {
9925        self._scopes.clear();
9926        self
9927    }
9928}
9929
9930/// Get a custom dimension to which the user has access.
9931///
9932/// A builder for the *customDimensions.get* method supported by a *management* resource.
9933/// It is not used directly, but through a [`ManagementMethods`] instance.
9934///
9935/// # Example
9936///
9937/// Instantiate a resource method builder
9938///
9939/// ```test_harness,no_run
9940/// # extern crate hyper;
9941/// # extern crate hyper_rustls;
9942/// # extern crate google_analytics3 as analytics3;
9943/// # async fn dox() {
9944/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9945///
9946/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9947/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9948/// #     .with_native_roots()
9949/// #     .unwrap()
9950/// #     .https_only()
9951/// #     .enable_http2()
9952/// #     .build();
9953///
9954/// # let executor = hyper_util::rt::TokioExecutor::new();
9955/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9956/// #     secret,
9957/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9958/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9959/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9960/// #     ),
9961/// # ).build().await.unwrap();
9962///
9963/// # let client = hyper_util::client::legacy::Client::builder(
9964/// #     hyper_util::rt::TokioExecutor::new()
9965/// # )
9966/// # .build(
9967/// #     hyper_rustls::HttpsConnectorBuilder::new()
9968/// #         .with_native_roots()
9969/// #         .unwrap()
9970/// #         .https_or_http()
9971/// #         .enable_http2()
9972/// #         .build()
9973/// # );
9974/// # let mut hub = Analytics::new(client, auth);
9975/// // You can configure optional parameters by calling the respective setters at will, and
9976/// // execute the final call using `doit()`.
9977/// // Values shown here are possibly random and not representative !
9978/// let result = hub.management().custom_dimensions_get("accountId", "webPropertyId", "customDimensionId")
9979///              .doit().await;
9980/// # }
9981/// ```
9982pub struct ManagementCustomDimensionGetCall<'a, C>
9983where
9984    C: 'a,
9985{
9986    hub: &'a Analytics<C>,
9987    _account_id: String,
9988    _web_property_id: String,
9989    _custom_dimension_id: String,
9990    _delegate: Option<&'a mut dyn common::Delegate>,
9991    _additional_params: HashMap<String, String>,
9992    _scopes: BTreeSet<String>,
9993}
9994
9995impl<'a, C> common::CallBuilder for ManagementCustomDimensionGetCall<'a, C> {}
9996
9997impl<'a, C> ManagementCustomDimensionGetCall<'a, C>
9998where
9999    C: common::Connector,
10000{
10001    /// Perform the operation you have build so far.
10002    pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimension)> {
10003        use std::borrow::Cow;
10004        use std::io::{Read, Seek};
10005
10006        use common::{url::Params, ToParts};
10007        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10008
10009        let mut dd = common::DefaultDelegate;
10010        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10011        dlg.begin(common::MethodInfo {
10012            id: "analytics.management.customDimensions.get",
10013            http_method: hyper::Method::GET,
10014        });
10015
10016        for &field in ["alt", "accountId", "webPropertyId", "customDimensionId"].iter() {
10017            if self._additional_params.contains_key(field) {
10018                dlg.finished(false);
10019                return Err(common::Error::FieldClash(field));
10020            }
10021        }
10022
10023        let mut params = Params::with_capacity(5 + self._additional_params.len());
10024        params.push("accountId", self._account_id);
10025        params.push("webPropertyId", self._web_property_id);
10026        params.push("customDimensionId", self._custom_dimension_id);
10027
10028        params.extend(self._additional_params.iter());
10029
10030        params.push("alt", "json");
10031        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions/{customDimensionId}";
10032        if self._scopes.is_empty() {
10033            self._scopes.insert(Scope::Readonly.as_ref().to_string());
10034        }
10035
10036        #[allow(clippy::single_element_loop)]
10037        for &(find_this, param_name) in [
10038            ("{accountId}", "accountId"),
10039            ("{webPropertyId}", "webPropertyId"),
10040            ("{customDimensionId}", "customDimensionId"),
10041        ]
10042        .iter()
10043        {
10044            url = params.uri_replacement(url, param_name, find_this, false);
10045        }
10046        {
10047            let to_remove = ["customDimensionId", "webPropertyId", "accountId"];
10048            params.remove_params(&to_remove);
10049        }
10050
10051        let url = params.parse_with_url(&url);
10052
10053        loop {
10054            let token = match self
10055                .hub
10056                .auth
10057                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10058                .await
10059            {
10060                Ok(token) => token,
10061                Err(e) => match dlg.token(e) {
10062                    Ok(token) => token,
10063                    Err(e) => {
10064                        dlg.finished(false);
10065                        return Err(common::Error::MissingToken(e));
10066                    }
10067                },
10068            };
10069            let mut req_result = {
10070                let client = &self.hub.client;
10071                dlg.pre_request();
10072                let mut req_builder = hyper::Request::builder()
10073                    .method(hyper::Method::GET)
10074                    .uri(url.as_str())
10075                    .header(USER_AGENT, self.hub._user_agent.clone());
10076
10077                if let Some(token) = token.as_ref() {
10078                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10079                }
10080
10081                let request = req_builder
10082                    .header(CONTENT_LENGTH, 0_u64)
10083                    .body(common::to_body::<String>(None));
10084
10085                client.request(request.unwrap()).await
10086            };
10087
10088            match req_result {
10089                Err(err) => {
10090                    if let common::Retry::After(d) = dlg.http_error(&err) {
10091                        sleep(d).await;
10092                        continue;
10093                    }
10094                    dlg.finished(false);
10095                    return Err(common::Error::HttpError(err));
10096                }
10097                Ok(res) => {
10098                    let (mut parts, body) = res.into_parts();
10099                    let mut body = common::Body::new(body);
10100                    if !parts.status.is_success() {
10101                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10102                        let error = serde_json::from_str(&common::to_string(&bytes));
10103                        let response = common::to_response(parts, bytes.into());
10104
10105                        if let common::Retry::After(d) =
10106                            dlg.http_failure(&response, error.as_ref().ok())
10107                        {
10108                            sleep(d).await;
10109                            continue;
10110                        }
10111
10112                        dlg.finished(false);
10113
10114                        return Err(match error {
10115                            Ok(value) => common::Error::BadRequest(value),
10116                            _ => common::Error::Failure(response),
10117                        });
10118                    }
10119                    let response = {
10120                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10121                        let encoded = common::to_string(&bytes);
10122                        match serde_json::from_str(&encoded) {
10123                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10124                            Err(error) => {
10125                                dlg.response_json_decode_error(&encoded, &error);
10126                                return Err(common::Error::JsonDecodeError(
10127                                    encoded.to_string(),
10128                                    error,
10129                                ));
10130                            }
10131                        }
10132                    };
10133
10134                    dlg.finished(true);
10135                    return Ok(response);
10136                }
10137            }
10138        }
10139    }
10140
10141    /// Account ID for the custom dimension to retrieve.
10142    ///
10143    /// Sets the *account id* path property to the given value.
10144    ///
10145    /// Even though the property as already been set when instantiating this call,
10146    /// we provide this method for API completeness.
10147    pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionGetCall<'a, C> {
10148        self._account_id = new_value.to_string();
10149        self
10150    }
10151    /// Web property ID for the custom dimension to retrieve.
10152    ///
10153    /// Sets the *web property id* path property to the given value.
10154    ///
10155    /// Even though the property as already been set when instantiating this call,
10156    /// we provide this method for API completeness.
10157    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomDimensionGetCall<'a, C> {
10158        self._web_property_id = new_value.to_string();
10159        self
10160    }
10161    /// The ID of the custom dimension to retrieve.
10162    ///
10163    /// Sets the *custom dimension id* path property to the given value.
10164    ///
10165    /// Even though the property as already been set when instantiating this call,
10166    /// we provide this method for API completeness.
10167    pub fn custom_dimension_id(
10168        mut self,
10169        new_value: &str,
10170    ) -> ManagementCustomDimensionGetCall<'a, C> {
10171        self._custom_dimension_id = new_value.to_string();
10172        self
10173    }
10174    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10175    /// while executing the actual API request.
10176    ///
10177    /// ````text
10178    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10179    /// ````
10180    ///
10181    /// Sets the *delegate* property to the given value.
10182    pub fn delegate(
10183        mut self,
10184        new_value: &'a mut dyn common::Delegate,
10185    ) -> ManagementCustomDimensionGetCall<'a, C> {
10186        self._delegate = Some(new_value);
10187        self
10188    }
10189
10190    /// Set any additional parameter of the query string used in the request.
10191    /// It should be used to set parameters which are not yet available through their own
10192    /// setters.
10193    ///
10194    /// Please note that this method must not be used to set any of the known parameters
10195    /// which have their own setter method. If done anyway, the request will fail.
10196    ///
10197    /// # Additional Parameters
10198    ///
10199    /// * *alt* (query-string) - Data format for the response.
10200    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10201    /// * *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.
10202    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10203    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10204    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10205    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10206    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionGetCall<'a, C>
10207    where
10208        T: AsRef<str>,
10209    {
10210        self._additional_params
10211            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10212        self
10213    }
10214
10215    /// Identifies the authorization scope for the method you are building.
10216    ///
10217    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10218    /// [`Scope::Readonly`].
10219    ///
10220    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10221    /// tokens for more than one scope.
10222    ///
10223    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10224    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10225    /// sufficient, a read-write scope will do as well.
10226    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionGetCall<'a, C>
10227    where
10228        St: AsRef<str>,
10229    {
10230        self._scopes.insert(String::from(scope.as_ref()));
10231        self
10232    }
10233    /// Identifies the authorization scope(s) for the method you are building.
10234    ///
10235    /// See [`Self::add_scope()`] for details.
10236    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionGetCall<'a, C>
10237    where
10238        I: IntoIterator<Item = St>,
10239        St: AsRef<str>,
10240    {
10241        self._scopes
10242            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10243        self
10244    }
10245
10246    /// Removes all scopes, and no default scope will be used either.
10247    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10248    /// for details).
10249    pub fn clear_scopes(mut self) -> ManagementCustomDimensionGetCall<'a, C> {
10250        self._scopes.clear();
10251        self
10252    }
10253}
10254
10255/// Create a new custom dimension.
10256///
10257/// A builder for the *customDimensions.insert* method supported by a *management* resource.
10258/// It is not used directly, but through a [`ManagementMethods`] instance.
10259///
10260/// # Example
10261///
10262/// Instantiate a resource method builder
10263///
10264/// ```test_harness,no_run
10265/// # extern crate hyper;
10266/// # extern crate hyper_rustls;
10267/// # extern crate google_analytics3 as analytics3;
10268/// use analytics3::api::CustomDimension;
10269/// # async fn dox() {
10270/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10271///
10272/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10273/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10274/// #     .with_native_roots()
10275/// #     .unwrap()
10276/// #     .https_only()
10277/// #     .enable_http2()
10278/// #     .build();
10279///
10280/// # let executor = hyper_util::rt::TokioExecutor::new();
10281/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10282/// #     secret,
10283/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10284/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10285/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10286/// #     ),
10287/// # ).build().await.unwrap();
10288///
10289/// # let client = hyper_util::client::legacy::Client::builder(
10290/// #     hyper_util::rt::TokioExecutor::new()
10291/// # )
10292/// # .build(
10293/// #     hyper_rustls::HttpsConnectorBuilder::new()
10294/// #         .with_native_roots()
10295/// #         .unwrap()
10296/// #         .https_or_http()
10297/// #         .enable_http2()
10298/// #         .build()
10299/// # );
10300/// # let mut hub = Analytics::new(client, auth);
10301/// // As the method needs a request, you would usually fill it with the desired information
10302/// // into the respective structure. Some of the parts shown here might not be applicable !
10303/// // Values shown here are possibly random and not representative !
10304/// let mut req = CustomDimension::default();
10305///
10306/// // You can configure optional parameters by calling the respective setters at will, and
10307/// // execute the final call using `doit()`.
10308/// // Values shown here are possibly random and not representative !
10309/// let result = hub.management().custom_dimensions_insert(req, "accountId", "webPropertyId")
10310///              .doit().await;
10311/// # }
10312/// ```
10313pub struct ManagementCustomDimensionInsertCall<'a, C>
10314where
10315    C: 'a,
10316{
10317    hub: &'a Analytics<C>,
10318    _request: CustomDimension,
10319    _account_id: String,
10320    _web_property_id: String,
10321    _delegate: Option<&'a mut dyn common::Delegate>,
10322    _additional_params: HashMap<String, String>,
10323    _scopes: BTreeSet<String>,
10324}
10325
10326impl<'a, C> common::CallBuilder for ManagementCustomDimensionInsertCall<'a, C> {}
10327
10328impl<'a, C> ManagementCustomDimensionInsertCall<'a, C>
10329where
10330    C: common::Connector,
10331{
10332    /// Perform the operation you have build so far.
10333    pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimension)> {
10334        use std::borrow::Cow;
10335        use std::io::{Read, Seek};
10336
10337        use common::{url::Params, ToParts};
10338        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10339
10340        let mut dd = common::DefaultDelegate;
10341        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10342        dlg.begin(common::MethodInfo {
10343            id: "analytics.management.customDimensions.insert",
10344            http_method: hyper::Method::POST,
10345        });
10346
10347        for &field in ["alt", "accountId", "webPropertyId"].iter() {
10348            if self._additional_params.contains_key(field) {
10349                dlg.finished(false);
10350                return Err(common::Error::FieldClash(field));
10351            }
10352        }
10353
10354        let mut params = Params::with_capacity(5 + self._additional_params.len());
10355        params.push("accountId", self._account_id);
10356        params.push("webPropertyId", self._web_property_id);
10357
10358        params.extend(self._additional_params.iter());
10359
10360        params.push("alt", "json");
10361        let mut url = self.hub._base_url.clone()
10362            + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions";
10363        if self._scopes.is_empty() {
10364            self._scopes.insert(Scope::Edit.as_ref().to_string());
10365        }
10366
10367        #[allow(clippy::single_element_loop)]
10368        for &(find_this, param_name) in [
10369            ("{accountId}", "accountId"),
10370            ("{webPropertyId}", "webPropertyId"),
10371        ]
10372        .iter()
10373        {
10374            url = params.uri_replacement(url, param_name, find_this, false);
10375        }
10376        {
10377            let to_remove = ["webPropertyId", "accountId"];
10378            params.remove_params(&to_remove);
10379        }
10380
10381        let url = params.parse_with_url(&url);
10382
10383        let mut json_mime_type = mime::APPLICATION_JSON;
10384        let mut request_value_reader = {
10385            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10386            common::remove_json_null_values(&mut value);
10387            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10388            serde_json::to_writer(&mut dst, &value).unwrap();
10389            dst
10390        };
10391        let request_size = request_value_reader
10392            .seek(std::io::SeekFrom::End(0))
10393            .unwrap();
10394        request_value_reader
10395            .seek(std::io::SeekFrom::Start(0))
10396            .unwrap();
10397
10398        loop {
10399            let token = match self
10400                .hub
10401                .auth
10402                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10403                .await
10404            {
10405                Ok(token) => token,
10406                Err(e) => match dlg.token(e) {
10407                    Ok(token) => token,
10408                    Err(e) => {
10409                        dlg.finished(false);
10410                        return Err(common::Error::MissingToken(e));
10411                    }
10412                },
10413            };
10414            request_value_reader
10415                .seek(std::io::SeekFrom::Start(0))
10416                .unwrap();
10417            let mut req_result = {
10418                let client = &self.hub.client;
10419                dlg.pre_request();
10420                let mut req_builder = hyper::Request::builder()
10421                    .method(hyper::Method::POST)
10422                    .uri(url.as_str())
10423                    .header(USER_AGENT, self.hub._user_agent.clone());
10424
10425                if let Some(token) = token.as_ref() {
10426                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10427                }
10428
10429                let request = req_builder
10430                    .header(CONTENT_TYPE, json_mime_type.to_string())
10431                    .header(CONTENT_LENGTH, request_size as u64)
10432                    .body(common::to_body(
10433                        request_value_reader.get_ref().clone().into(),
10434                    ));
10435
10436                client.request(request.unwrap()).await
10437            };
10438
10439            match req_result {
10440                Err(err) => {
10441                    if let common::Retry::After(d) = dlg.http_error(&err) {
10442                        sleep(d).await;
10443                        continue;
10444                    }
10445                    dlg.finished(false);
10446                    return Err(common::Error::HttpError(err));
10447                }
10448                Ok(res) => {
10449                    let (mut parts, body) = res.into_parts();
10450                    let mut body = common::Body::new(body);
10451                    if !parts.status.is_success() {
10452                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10453                        let error = serde_json::from_str(&common::to_string(&bytes));
10454                        let response = common::to_response(parts, bytes.into());
10455
10456                        if let common::Retry::After(d) =
10457                            dlg.http_failure(&response, error.as_ref().ok())
10458                        {
10459                            sleep(d).await;
10460                            continue;
10461                        }
10462
10463                        dlg.finished(false);
10464
10465                        return Err(match error {
10466                            Ok(value) => common::Error::BadRequest(value),
10467                            _ => common::Error::Failure(response),
10468                        });
10469                    }
10470                    let response = {
10471                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10472                        let encoded = common::to_string(&bytes);
10473                        match serde_json::from_str(&encoded) {
10474                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10475                            Err(error) => {
10476                                dlg.response_json_decode_error(&encoded, &error);
10477                                return Err(common::Error::JsonDecodeError(
10478                                    encoded.to_string(),
10479                                    error,
10480                                ));
10481                            }
10482                        }
10483                    };
10484
10485                    dlg.finished(true);
10486                    return Ok(response);
10487                }
10488            }
10489        }
10490    }
10491
10492    ///
10493    /// Sets the *request* property to the given value.
10494    ///
10495    /// Even though the property as already been set when instantiating this call,
10496    /// we provide this method for API completeness.
10497    pub fn request(
10498        mut self,
10499        new_value: CustomDimension,
10500    ) -> ManagementCustomDimensionInsertCall<'a, C> {
10501        self._request = new_value;
10502        self
10503    }
10504    /// Account ID for the custom dimension to create.
10505    ///
10506    /// Sets the *account id* path property to the given value.
10507    ///
10508    /// Even though the property as already been set when instantiating this call,
10509    /// we provide this method for API completeness.
10510    pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionInsertCall<'a, C> {
10511        self._account_id = new_value.to_string();
10512        self
10513    }
10514    /// Web property ID for the custom dimension to create.
10515    ///
10516    /// Sets the *web property id* path property to the given value.
10517    ///
10518    /// Even though the property as already been set when instantiating this call,
10519    /// we provide this method for API completeness.
10520    pub fn web_property_id(
10521        mut self,
10522        new_value: &str,
10523    ) -> ManagementCustomDimensionInsertCall<'a, C> {
10524        self._web_property_id = new_value.to_string();
10525        self
10526    }
10527    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10528    /// while executing the actual API request.
10529    ///
10530    /// ````text
10531    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10532    /// ````
10533    ///
10534    /// Sets the *delegate* property to the given value.
10535    pub fn delegate(
10536        mut self,
10537        new_value: &'a mut dyn common::Delegate,
10538    ) -> ManagementCustomDimensionInsertCall<'a, C> {
10539        self._delegate = Some(new_value);
10540        self
10541    }
10542
10543    /// Set any additional parameter of the query string used in the request.
10544    /// It should be used to set parameters which are not yet available through their own
10545    /// setters.
10546    ///
10547    /// Please note that this method must not be used to set any of the known parameters
10548    /// which have their own setter method. If done anyway, the request will fail.
10549    ///
10550    /// # Additional Parameters
10551    ///
10552    /// * *alt* (query-string) - Data format for the response.
10553    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10554    /// * *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.
10555    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10556    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10557    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10558    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10559    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionInsertCall<'a, C>
10560    where
10561        T: AsRef<str>,
10562    {
10563        self._additional_params
10564            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10565        self
10566    }
10567
10568    /// Identifies the authorization scope for the method you are building.
10569    ///
10570    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10571    /// [`Scope::Edit`].
10572    ///
10573    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10574    /// tokens for more than one scope.
10575    ///
10576    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10577    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10578    /// sufficient, a read-write scope will do as well.
10579    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionInsertCall<'a, C>
10580    where
10581        St: AsRef<str>,
10582    {
10583        self._scopes.insert(String::from(scope.as_ref()));
10584        self
10585    }
10586    /// Identifies the authorization scope(s) for the method you are building.
10587    ///
10588    /// See [`Self::add_scope()`] for details.
10589    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionInsertCall<'a, C>
10590    where
10591        I: IntoIterator<Item = St>,
10592        St: AsRef<str>,
10593    {
10594        self._scopes
10595            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10596        self
10597    }
10598
10599    /// Removes all scopes, and no default scope will be used either.
10600    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10601    /// for details).
10602    pub fn clear_scopes(mut self) -> ManagementCustomDimensionInsertCall<'a, C> {
10603        self._scopes.clear();
10604        self
10605    }
10606}
10607
10608/// Lists custom dimensions to which the user has access.
10609///
10610/// A builder for the *customDimensions.list* method supported by a *management* resource.
10611/// It is not used directly, but through a [`ManagementMethods`] instance.
10612///
10613/// # Example
10614///
10615/// Instantiate a resource method builder
10616///
10617/// ```test_harness,no_run
10618/// # extern crate hyper;
10619/// # extern crate hyper_rustls;
10620/// # extern crate google_analytics3 as analytics3;
10621/// # async fn dox() {
10622/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10623///
10624/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10625/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10626/// #     .with_native_roots()
10627/// #     .unwrap()
10628/// #     .https_only()
10629/// #     .enable_http2()
10630/// #     .build();
10631///
10632/// # let executor = hyper_util::rt::TokioExecutor::new();
10633/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10634/// #     secret,
10635/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10636/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10637/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10638/// #     ),
10639/// # ).build().await.unwrap();
10640///
10641/// # let client = hyper_util::client::legacy::Client::builder(
10642/// #     hyper_util::rt::TokioExecutor::new()
10643/// # )
10644/// # .build(
10645/// #     hyper_rustls::HttpsConnectorBuilder::new()
10646/// #         .with_native_roots()
10647/// #         .unwrap()
10648/// #         .https_or_http()
10649/// #         .enable_http2()
10650/// #         .build()
10651/// # );
10652/// # let mut hub = Analytics::new(client, auth);
10653/// // You can configure optional parameters by calling the respective setters at will, and
10654/// // execute the final call using `doit()`.
10655/// // Values shown here are possibly random and not representative !
10656/// let result = hub.management().custom_dimensions_list("accountId", "webPropertyId")
10657///              .start_index(-76)
10658///              .max_results(-76)
10659///              .doit().await;
10660/// # }
10661/// ```
10662pub struct ManagementCustomDimensionListCall<'a, C>
10663where
10664    C: 'a,
10665{
10666    hub: &'a Analytics<C>,
10667    _account_id: String,
10668    _web_property_id: String,
10669    _start_index: Option<i32>,
10670    _max_results: Option<i32>,
10671    _delegate: Option<&'a mut dyn common::Delegate>,
10672    _additional_params: HashMap<String, String>,
10673    _scopes: BTreeSet<String>,
10674}
10675
10676impl<'a, C> common::CallBuilder for ManagementCustomDimensionListCall<'a, C> {}
10677
10678impl<'a, C> ManagementCustomDimensionListCall<'a, C>
10679where
10680    C: common::Connector,
10681{
10682    /// Perform the operation you have build so far.
10683    pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimensions)> {
10684        use std::borrow::Cow;
10685        use std::io::{Read, Seek};
10686
10687        use common::{url::Params, ToParts};
10688        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10689
10690        let mut dd = common::DefaultDelegate;
10691        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10692        dlg.begin(common::MethodInfo {
10693            id: "analytics.management.customDimensions.list",
10694            http_method: hyper::Method::GET,
10695        });
10696
10697        for &field in [
10698            "alt",
10699            "accountId",
10700            "webPropertyId",
10701            "start-index",
10702            "max-results",
10703        ]
10704        .iter()
10705        {
10706            if self._additional_params.contains_key(field) {
10707                dlg.finished(false);
10708                return Err(common::Error::FieldClash(field));
10709            }
10710        }
10711
10712        let mut params = Params::with_capacity(6 + self._additional_params.len());
10713        params.push("accountId", self._account_id);
10714        params.push("webPropertyId", self._web_property_id);
10715        if let Some(value) = self._start_index.as_ref() {
10716            params.push("start-index", value.to_string());
10717        }
10718        if let Some(value) = self._max_results.as_ref() {
10719            params.push("max-results", value.to_string());
10720        }
10721
10722        params.extend(self._additional_params.iter());
10723
10724        params.push("alt", "json");
10725        let mut url = self.hub._base_url.clone()
10726            + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions";
10727        if self._scopes.is_empty() {
10728            self._scopes.insert(Scope::Readonly.as_ref().to_string());
10729        }
10730
10731        #[allow(clippy::single_element_loop)]
10732        for &(find_this, param_name) in [
10733            ("{accountId}", "accountId"),
10734            ("{webPropertyId}", "webPropertyId"),
10735        ]
10736        .iter()
10737        {
10738            url = params.uri_replacement(url, param_name, find_this, false);
10739        }
10740        {
10741            let to_remove = ["webPropertyId", "accountId"];
10742            params.remove_params(&to_remove);
10743        }
10744
10745        let url = params.parse_with_url(&url);
10746
10747        loop {
10748            let token = match self
10749                .hub
10750                .auth
10751                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10752                .await
10753            {
10754                Ok(token) => token,
10755                Err(e) => match dlg.token(e) {
10756                    Ok(token) => token,
10757                    Err(e) => {
10758                        dlg.finished(false);
10759                        return Err(common::Error::MissingToken(e));
10760                    }
10761                },
10762            };
10763            let mut req_result = {
10764                let client = &self.hub.client;
10765                dlg.pre_request();
10766                let mut req_builder = hyper::Request::builder()
10767                    .method(hyper::Method::GET)
10768                    .uri(url.as_str())
10769                    .header(USER_AGENT, self.hub._user_agent.clone());
10770
10771                if let Some(token) = token.as_ref() {
10772                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10773                }
10774
10775                let request = req_builder
10776                    .header(CONTENT_LENGTH, 0_u64)
10777                    .body(common::to_body::<String>(None));
10778
10779                client.request(request.unwrap()).await
10780            };
10781
10782            match req_result {
10783                Err(err) => {
10784                    if let common::Retry::After(d) = dlg.http_error(&err) {
10785                        sleep(d).await;
10786                        continue;
10787                    }
10788                    dlg.finished(false);
10789                    return Err(common::Error::HttpError(err));
10790                }
10791                Ok(res) => {
10792                    let (mut parts, body) = res.into_parts();
10793                    let mut body = common::Body::new(body);
10794                    if !parts.status.is_success() {
10795                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10796                        let error = serde_json::from_str(&common::to_string(&bytes));
10797                        let response = common::to_response(parts, bytes.into());
10798
10799                        if let common::Retry::After(d) =
10800                            dlg.http_failure(&response, error.as_ref().ok())
10801                        {
10802                            sleep(d).await;
10803                            continue;
10804                        }
10805
10806                        dlg.finished(false);
10807
10808                        return Err(match error {
10809                            Ok(value) => common::Error::BadRequest(value),
10810                            _ => common::Error::Failure(response),
10811                        });
10812                    }
10813                    let response = {
10814                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10815                        let encoded = common::to_string(&bytes);
10816                        match serde_json::from_str(&encoded) {
10817                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10818                            Err(error) => {
10819                                dlg.response_json_decode_error(&encoded, &error);
10820                                return Err(common::Error::JsonDecodeError(
10821                                    encoded.to_string(),
10822                                    error,
10823                                ));
10824                            }
10825                        }
10826                    };
10827
10828                    dlg.finished(true);
10829                    return Ok(response);
10830                }
10831            }
10832        }
10833    }
10834
10835    /// Account ID for the custom dimensions to retrieve.
10836    ///
10837    /// Sets the *account id* path property to the given value.
10838    ///
10839    /// Even though the property as already been set when instantiating this call,
10840    /// we provide this method for API completeness.
10841    pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionListCall<'a, C> {
10842        self._account_id = new_value.to_string();
10843        self
10844    }
10845    /// Web property ID for the custom dimensions to retrieve.
10846    ///
10847    /// Sets the *web property id* path property to the given value.
10848    ///
10849    /// Even though the property as already been set when instantiating this call,
10850    /// we provide this method for API completeness.
10851    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomDimensionListCall<'a, C> {
10852        self._web_property_id = new_value.to_string();
10853        self
10854    }
10855    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
10856    ///
10857    /// Sets the *start-index* query property to the given value.
10858    pub fn start_index(mut self, new_value: i32) -> ManagementCustomDimensionListCall<'a, C> {
10859        self._start_index = Some(new_value);
10860        self
10861    }
10862    /// The maximum number of custom dimensions to include in this response.
10863    ///
10864    /// Sets the *max-results* query property to the given value.
10865    pub fn max_results(mut self, new_value: i32) -> ManagementCustomDimensionListCall<'a, C> {
10866        self._max_results = Some(new_value);
10867        self
10868    }
10869    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10870    /// while executing the actual API request.
10871    ///
10872    /// ````text
10873    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10874    /// ````
10875    ///
10876    /// Sets the *delegate* property to the given value.
10877    pub fn delegate(
10878        mut self,
10879        new_value: &'a mut dyn common::Delegate,
10880    ) -> ManagementCustomDimensionListCall<'a, C> {
10881        self._delegate = Some(new_value);
10882        self
10883    }
10884
10885    /// Set any additional parameter of the query string used in the request.
10886    /// It should be used to set parameters which are not yet available through their own
10887    /// setters.
10888    ///
10889    /// Please note that this method must not be used to set any of the known parameters
10890    /// which have their own setter method. If done anyway, the request will fail.
10891    ///
10892    /// # Additional Parameters
10893    ///
10894    /// * *alt* (query-string) - Data format for the response.
10895    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10896    /// * *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.
10897    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10898    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10899    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10900    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10901    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionListCall<'a, C>
10902    where
10903        T: AsRef<str>,
10904    {
10905        self._additional_params
10906            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10907        self
10908    }
10909
10910    /// Identifies the authorization scope for the method you are building.
10911    ///
10912    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10913    /// [`Scope::Readonly`].
10914    ///
10915    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10916    /// tokens for more than one scope.
10917    ///
10918    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10919    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10920    /// sufficient, a read-write scope will do as well.
10921    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionListCall<'a, C>
10922    where
10923        St: AsRef<str>,
10924    {
10925        self._scopes.insert(String::from(scope.as_ref()));
10926        self
10927    }
10928    /// Identifies the authorization scope(s) for the method you are building.
10929    ///
10930    /// See [`Self::add_scope()`] for details.
10931    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionListCall<'a, C>
10932    where
10933        I: IntoIterator<Item = St>,
10934        St: AsRef<str>,
10935    {
10936        self._scopes
10937            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10938        self
10939    }
10940
10941    /// Removes all scopes, and no default scope will be used either.
10942    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10943    /// for details).
10944    pub fn clear_scopes(mut self) -> ManagementCustomDimensionListCall<'a, C> {
10945        self._scopes.clear();
10946        self
10947    }
10948}
10949
10950/// Updates an existing custom dimension. This method supports patch semantics.
10951///
10952/// A builder for the *customDimensions.patch* method supported by a *management* resource.
10953/// It is not used directly, but through a [`ManagementMethods`] instance.
10954///
10955/// # Example
10956///
10957/// Instantiate a resource method builder
10958///
10959/// ```test_harness,no_run
10960/// # extern crate hyper;
10961/// # extern crate hyper_rustls;
10962/// # extern crate google_analytics3 as analytics3;
10963/// use analytics3::api::CustomDimension;
10964/// # async fn dox() {
10965/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10966///
10967/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10968/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10969/// #     .with_native_roots()
10970/// #     .unwrap()
10971/// #     .https_only()
10972/// #     .enable_http2()
10973/// #     .build();
10974///
10975/// # let executor = hyper_util::rt::TokioExecutor::new();
10976/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10977/// #     secret,
10978/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10979/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10980/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10981/// #     ),
10982/// # ).build().await.unwrap();
10983///
10984/// # let client = hyper_util::client::legacy::Client::builder(
10985/// #     hyper_util::rt::TokioExecutor::new()
10986/// # )
10987/// # .build(
10988/// #     hyper_rustls::HttpsConnectorBuilder::new()
10989/// #         .with_native_roots()
10990/// #         .unwrap()
10991/// #         .https_or_http()
10992/// #         .enable_http2()
10993/// #         .build()
10994/// # );
10995/// # let mut hub = Analytics::new(client, auth);
10996/// // As the method needs a request, you would usually fill it with the desired information
10997/// // into the respective structure. Some of the parts shown here might not be applicable !
10998/// // Values shown here are possibly random and not representative !
10999/// let mut req = CustomDimension::default();
11000///
11001/// // You can configure optional parameters by calling the respective setters at will, and
11002/// // execute the final call using `doit()`.
11003/// // Values shown here are possibly random and not representative !
11004/// let result = hub.management().custom_dimensions_patch(req, "accountId", "webPropertyId", "customDimensionId")
11005///              .ignore_custom_data_source_links(true)
11006///              .doit().await;
11007/// # }
11008/// ```
11009pub struct ManagementCustomDimensionPatchCall<'a, C>
11010where
11011    C: 'a,
11012{
11013    hub: &'a Analytics<C>,
11014    _request: CustomDimension,
11015    _account_id: String,
11016    _web_property_id: String,
11017    _custom_dimension_id: String,
11018    _ignore_custom_data_source_links: Option<bool>,
11019    _delegate: Option<&'a mut dyn common::Delegate>,
11020    _additional_params: HashMap<String, String>,
11021    _scopes: BTreeSet<String>,
11022}
11023
11024impl<'a, C> common::CallBuilder for ManagementCustomDimensionPatchCall<'a, C> {}
11025
11026impl<'a, C> ManagementCustomDimensionPatchCall<'a, C>
11027where
11028    C: common::Connector,
11029{
11030    /// Perform the operation you have build so far.
11031    pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimension)> {
11032        use std::borrow::Cow;
11033        use std::io::{Read, Seek};
11034
11035        use common::{url::Params, ToParts};
11036        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11037
11038        let mut dd = common::DefaultDelegate;
11039        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11040        dlg.begin(common::MethodInfo {
11041            id: "analytics.management.customDimensions.patch",
11042            http_method: hyper::Method::PATCH,
11043        });
11044
11045        for &field in [
11046            "alt",
11047            "accountId",
11048            "webPropertyId",
11049            "customDimensionId",
11050            "ignoreCustomDataSourceLinks",
11051        ]
11052        .iter()
11053        {
11054            if self._additional_params.contains_key(field) {
11055                dlg.finished(false);
11056                return Err(common::Error::FieldClash(field));
11057            }
11058        }
11059
11060        let mut params = Params::with_capacity(7 + self._additional_params.len());
11061        params.push("accountId", self._account_id);
11062        params.push("webPropertyId", self._web_property_id);
11063        params.push("customDimensionId", self._custom_dimension_id);
11064        if let Some(value) = self._ignore_custom_data_source_links.as_ref() {
11065            params.push("ignoreCustomDataSourceLinks", value.to_string());
11066        }
11067
11068        params.extend(self._additional_params.iter());
11069
11070        params.push("alt", "json");
11071        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions/{customDimensionId}";
11072        if self._scopes.is_empty() {
11073            self._scopes.insert(Scope::Edit.as_ref().to_string());
11074        }
11075
11076        #[allow(clippy::single_element_loop)]
11077        for &(find_this, param_name) in [
11078            ("{accountId}", "accountId"),
11079            ("{webPropertyId}", "webPropertyId"),
11080            ("{customDimensionId}", "customDimensionId"),
11081        ]
11082        .iter()
11083        {
11084            url = params.uri_replacement(url, param_name, find_this, false);
11085        }
11086        {
11087            let to_remove = ["customDimensionId", "webPropertyId", "accountId"];
11088            params.remove_params(&to_remove);
11089        }
11090
11091        let url = params.parse_with_url(&url);
11092
11093        let mut json_mime_type = mime::APPLICATION_JSON;
11094        let mut request_value_reader = {
11095            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11096            common::remove_json_null_values(&mut value);
11097            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11098            serde_json::to_writer(&mut dst, &value).unwrap();
11099            dst
11100        };
11101        let request_size = request_value_reader
11102            .seek(std::io::SeekFrom::End(0))
11103            .unwrap();
11104        request_value_reader
11105            .seek(std::io::SeekFrom::Start(0))
11106            .unwrap();
11107
11108        loop {
11109            let token = match self
11110                .hub
11111                .auth
11112                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11113                .await
11114            {
11115                Ok(token) => token,
11116                Err(e) => match dlg.token(e) {
11117                    Ok(token) => token,
11118                    Err(e) => {
11119                        dlg.finished(false);
11120                        return Err(common::Error::MissingToken(e));
11121                    }
11122                },
11123            };
11124            request_value_reader
11125                .seek(std::io::SeekFrom::Start(0))
11126                .unwrap();
11127            let mut req_result = {
11128                let client = &self.hub.client;
11129                dlg.pre_request();
11130                let mut req_builder = hyper::Request::builder()
11131                    .method(hyper::Method::PATCH)
11132                    .uri(url.as_str())
11133                    .header(USER_AGENT, self.hub._user_agent.clone());
11134
11135                if let Some(token) = token.as_ref() {
11136                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11137                }
11138
11139                let request = req_builder
11140                    .header(CONTENT_TYPE, json_mime_type.to_string())
11141                    .header(CONTENT_LENGTH, request_size as u64)
11142                    .body(common::to_body(
11143                        request_value_reader.get_ref().clone().into(),
11144                    ));
11145
11146                client.request(request.unwrap()).await
11147            };
11148
11149            match req_result {
11150                Err(err) => {
11151                    if let common::Retry::After(d) = dlg.http_error(&err) {
11152                        sleep(d).await;
11153                        continue;
11154                    }
11155                    dlg.finished(false);
11156                    return Err(common::Error::HttpError(err));
11157                }
11158                Ok(res) => {
11159                    let (mut parts, body) = res.into_parts();
11160                    let mut body = common::Body::new(body);
11161                    if !parts.status.is_success() {
11162                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11163                        let error = serde_json::from_str(&common::to_string(&bytes));
11164                        let response = common::to_response(parts, bytes.into());
11165
11166                        if let common::Retry::After(d) =
11167                            dlg.http_failure(&response, error.as_ref().ok())
11168                        {
11169                            sleep(d).await;
11170                            continue;
11171                        }
11172
11173                        dlg.finished(false);
11174
11175                        return Err(match error {
11176                            Ok(value) => common::Error::BadRequest(value),
11177                            _ => common::Error::Failure(response),
11178                        });
11179                    }
11180                    let response = {
11181                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11182                        let encoded = common::to_string(&bytes);
11183                        match serde_json::from_str(&encoded) {
11184                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11185                            Err(error) => {
11186                                dlg.response_json_decode_error(&encoded, &error);
11187                                return Err(common::Error::JsonDecodeError(
11188                                    encoded.to_string(),
11189                                    error,
11190                                ));
11191                            }
11192                        }
11193                    };
11194
11195                    dlg.finished(true);
11196                    return Ok(response);
11197                }
11198            }
11199        }
11200    }
11201
11202    ///
11203    /// Sets the *request* property to the given value.
11204    ///
11205    /// Even though the property as already been set when instantiating this call,
11206    /// we provide this method for API completeness.
11207    pub fn request(
11208        mut self,
11209        new_value: CustomDimension,
11210    ) -> ManagementCustomDimensionPatchCall<'a, C> {
11211        self._request = new_value;
11212        self
11213    }
11214    /// Account ID for the custom dimension to update.
11215    ///
11216    /// Sets the *account id* path property to the given value.
11217    ///
11218    /// Even though the property as already been set when instantiating this call,
11219    /// we provide this method for API completeness.
11220    pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionPatchCall<'a, C> {
11221        self._account_id = new_value.to_string();
11222        self
11223    }
11224    /// Web property ID for the custom dimension to update.
11225    ///
11226    /// Sets the *web property id* path property to the given value.
11227    ///
11228    /// Even though the property as already been set when instantiating this call,
11229    /// we provide this method for API completeness.
11230    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomDimensionPatchCall<'a, C> {
11231        self._web_property_id = new_value.to_string();
11232        self
11233    }
11234    /// Custom dimension ID for the custom dimension to update.
11235    ///
11236    /// Sets the *custom dimension id* path property to the given value.
11237    ///
11238    /// Even though the property as already been set when instantiating this call,
11239    /// we provide this method for API completeness.
11240    pub fn custom_dimension_id(
11241        mut self,
11242        new_value: &str,
11243    ) -> ManagementCustomDimensionPatchCall<'a, C> {
11244        self._custom_dimension_id = new_value.to_string();
11245        self
11246    }
11247    /// Force the update and ignore any warnings related to the custom dimension being linked to a custom data source / data set.
11248    ///
11249    /// Sets the *ignore custom data source links* query property to the given value.
11250    pub fn ignore_custom_data_source_links(
11251        mut self,
11252        new_value: bool,
11253    ) -> ManagementCustomDimensionPatchCall<'a, C> {
11254        self._ignore_custom_data_source_links = Some(new_value);
11255        self
11256    }
11257    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11258    /// while executing the actual API request.
11259    ///
11260    /// ````text
11261    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11262    /// ````
11263    ///
11264    /// Sets the *delegate* property to the given value.
11265    pub fn delegate(
11266        mut self,
11267        new_value: &'a mut dyn common::Delegate,
11268    ) -> ManagementCustomDimensionPatchCall<'a, C> {
11269        self._delegate = Some(new_value);
11270        self
11271    }
11272
11273    /// Set any additional parameter of the query string used in the request.
11274    /// It should be used to set parameters which are not yet available through their own
11275    /// setters.
11276    ///
11277    /// Please note that this method must not be used to set any of the known parameters
11278    /// which have their own setter method. If done anyway, the request will fail.
11279    ///
11280    /// # Additional Parameters
11281    ///
11282    /// * *alt* (query-string) - Data format for the response.
11283    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11284    /// * *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.
11285    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11286    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11287    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11288    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11289    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionPatchCall<'a, C>
11290    where
11291        T: AsRef<str>,
11292    {
11293        self._additional_params
11294            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11295        self
11296    }
11297
11298    /// Identifies the authorization scope for the method you are building.
11299    ///
11300    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11301    /// [`Scope::Edit`].
11302    ///
11303    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11304    /// tokens for more than one scope.
11305    ///
11306    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11307    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11308    /// sufficient, a read-write scope will do as well.
11309    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionPatchCall<'a, C>
11310    where
11311        St: AsRef<str>,
11312    {
11313        self._scopes.insert(String::from(scope.as_ref()));
11314        self
11315    }
11316    /// Identifies the authorization scope(s) for the method you are building.
11317    ///
11318    /// See [`Self::add_scope()`] for details.
11319    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionPatchCall<'a, C>
11320    where
11321        I: IntoIterator<Item = St>,
11322        St: AsRef<str>,
11323    {
11324        self._scopes
11325            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11326        self
11327    }
11328
11329    /// Removes all scopes, and no default scope will be used either.
11330    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11331    /// for details).
11332    pub fn clear_scopes(mut self) -> ManagementCustomDimensionPatchCall<'a, C> {
11333        self._scopes.clear();
11334        self
11335    }
11336}
11337
11338/// Updates an existing custom dimension.
11339///
11340/// A builder for the *customDimensions.update* method supported by a *management* resource.
11341/// It is not used directly, but through a [`ManagementMethods`] instance.
11342///
11343/// # Example
11344///
11345/// Instantiate a resource method builder
11346///
11347/// ```test_harness,no_run
11348/// # extern crate hyper;
11349/// # extern crate hyper_rustls;
11350/// # extern crate google_analytics3 as analytics3;
11351/// use analytics3::api::CustomDimension;
11352/// # async fn dox() {
11353/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11354///
11355/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11356/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11357/// #     .with_native_roots()
11358/// #     .unwrap()
11359/// #     .https_only()
11360/// #     .enable_http2()
11361/// #     .build();
11362///
11363/// # let executor = hyper_util::rt::TokioExecutor::new();
11364/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11365/// #     secret,
11366/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11367/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11368/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11369/// #     ),
11370/// # ).build().await.unwrap();
11371///
11372/// # let client = hyper_util::client::legacy::Client::builder(
11373/// #     hyper_util::rt::TokioExecutor::new()
11374/// # )
11375/// # .build(
11376/// #     hyper_rustls::HttpsConnectorBuilder::new()
11377/// #         .with_native_roots()
11378/// #         .unwrap()
11379/// #         .https_or_http()
11380/// #         .enable_http2()
11381/// #         .build()
11382/// # );
11383/// # let mut hub = Analytics::new(client, auth);
11384/// // As the method needs a request, you would usually fill it with the desired information
11385/// // into the respective structure. Some of the parts shown here might not be applicable !
11386/// // Values shown here are possibly random and not representative !
11387/// let mut req = CustomDimension::default();
11388///
11389/// // You can configure optional parameters by calling the respective setters at will, and
11390/// // execute the final call using `doit()`.
11391/// // Values shown here are possibly random and not representative !
11392/// let result = hub.management().custom_dimensions_update(req, "accountId", "webPropertyId", "customDimensionId")
11393///              .ignore_custom_data_source_links(false)
11394///              .doit().await;
11395/// # }
11396/// ```
11397pub struct ManagementCustomDimensionUpdateCall<'a, C>
11398where
11399    C: 'a,
11400{
11401    hub: &'a Analytics<C>,
11402    _request: CustomDimension,
11403    _account_id: String,
11404    _web_property_id: String,
11405    _custom_dimension_id: String,
11406    _ignore_custom_data_source_links: Option<bool>,
11407    _delegate: Option<&'a mut dyn common::Delegate>,
11408    _additional_params: HashMap<String, String>,
11409    _scopes: BTreeSet<String>,
11410}
11411
11412impl<'a, C> common::CallBuilder for ManagementCustomDimensionUpdateCall<'a, C> {}
11413
11414impl<'a, C> ManagementCustomDimensionUpdateCall<'a, C>
11415where
11416    C: common::Connector,
11417{
11418    /// Perform the operation you have build so far.
11419    pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimension)> {
11420        use std::borrow::Cow;
11421        use std::io::{Read, Seek};
11422
11423        use common::{url::Params, ToParts};
11424        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11425
11426        let mut dd = common::DefaultDelegate;
11427        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11428        dlg.begin(common::MethodInfo {
11429            id: "analytics.management.customDimensions.update",
11430            http_method: hyper::Method::PUT,
11431        });
11432
11433        for &field in [
11434            "alt",
11435            "accountId",
11436            "webPropertyId",
11437            "customDimensionId",
11438            "ignoreCustomDataSourceLinks",
11439        ]
11440        .iter()
11441        {
11442            if self._additional_params.contains_key(field) {
11443                dlg.finished(false);
11444                return Err(common::Error::FieldClash(field));
11445            }
11446        }
11447
11448        let mut params = Params::with_capacity(7 + self._additional_params.len());
11449        params.push("accountId", self._account_id);
11450        params.push("webPropertyId", self._web_property_id);
11451        params.push("customDimensionId", self._custom_dimension_id);
11452        if let Some(value) = self._ignore_custom_data_source_links.as_ref() {
11453            params.push("ignoreCustomDataSourceLinks", value.to_string());
11454        }
11455
11456        params.extend(self._additional_params.iter());
11457
11458        params.push("alt", "json");
11459        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions/{customDimensionId}";
11460        if self._scopes.is_empty() {
11461            self._scopes.insert(Scope::Edit.as_ref().to_string());
11462        }
11463
11464        #[allow(clippy::single_element_loop)]
11465        for &(find_this, param_name) in [
11466            ("{accountId}", "accountId"),
11467            ("{webPropertyId}", "webPropertyId"),
11468            ("{customDimensionId}", "customDimensionId"),
11469        ]
11470        .iter()
11471        {
11472            url = params.uri_replacement(url, param_name, find_this, false);
11473        }
11474        {
11475            let to_remove = ["customDimensionId", "webPropertyId", "accountId"];
11476            params.remove_params(&to_remove);
11477        }
11478
11479        let url = params.parse_with_url(&url);
11480
11481        let mut json_mime_type = mime::APPLICATION_JSON;
11482        let mut request_value_reader = {
11483            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11484            common::remove_json_null_values(&mut value);
11485            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11486            serde_json::to_writer(&mut dst, &value).unwrap();
11487            dst
11488        };
11489        let request_size = request_value_reader
11490            .seek(std::io::SeekFrom::End(0))
11491            .unwrap();
11492        request_value_reader
11493            .seek(std::io::SeekFrom::Start(0))
11494            .unwrap();
11495
11496        loop {
11497            let token = match self
11498                .hub
11499                .auth
11500                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11501                .await
11502            {
11503                Ok(token) => token,
11504                Err(e) => match dlg.token(e) {
11505                    Ok(token) => token,
11506                    Err(e) => {
11507                        dlg.finished(false);
11508                        return Err(common::Error::MissingToken(e));
11509                    }
11510                },
11511            };
11512            request_value_reader
11513                .seek(std::io::SeekFrom::Start(0))
11514                .unwrap();
11515            let mut req_result = {
11516                let client = &self.hub.client;
11517                dlg.pre_request();
11518                let mut req_builder = hyper::Request::builder()
11519                    .method(hyper::Method::PUT)
11520                    .uri(url.as_str())
11521                    .header(USER_AGENT, self.hub._user_agent.clone());
11522
11523                if let Some(token) = token.as_ref() {
11524                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11525                }
11526
11527                let request = req_builder
11528                    .header(CONTENT_TYPE, json_mime_type.to_string())
11529                    .header(CONTENT_LENGTH, request_size as u64)
11530                    .body(common::to_body(
11531                        request_value_reader.get_ref().clone().into(),
11532                    ));
11533
11534                client.request(request.unwrap()).await
11535            };
11536
11537            match req_result {
11538                Err(err) => {
11539                    if let common::Retry::After(d) = dlg.http_error(&err) {
11540                        sleep(d).await;
11541                        continue;
11542                    }
11543                    dlg.finished(false);
11544                    return Err(common::Error::HttpError(err));
11545                }
11546                Ok(res) => {
11547                    let (mut parts, body) = res.into_parts();
11548                    let mut body = common::Body::new(body);
11549                    if !parts.status.is_success() {
11550                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11551                        let error = serde_json::from_str(&common::to_string(&bytes));
11552                        let response = common::to_response(parts, bytes.into());
11553
11554                        if let common::Retry::After(d) =
11555                            dlg.http_failure(&response, error.as_ref().ok())
11556                        {
11557                            sleep(d).await;
11558                            continue;
11559                        }
11560
11561                        dlg.finished(false);
11562
11563                        return Err(match error {
11564                            Ok(value) => common::Error::BadRequest(value),
11565                            _ => common::Error::Failure(response),
11566                        });
11567                    }
11568                    let response = {
11569                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11570                        let encoded = common::to_string(&bytes);
11571                        match serde_json::from_str(&encoded) {
11572                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11573                            Err(error) => {
11574                                dlg.response_json_decode_error(&encoded, &error);
11575                                return Err(common::Error::JsonDecodeError(
11576                                    encoded.to_string(),
11577                                    error,
11578                                ));
11579                            }
11580                        }
11581                    };
11582
11583                    dlg.finished(true);
11584                    return Ok(response);
11585                }
11586            }
11587        }
11588    }
11589
11590    ///
11591    /// Sets the *request* property to the given value.
11592    ///
11593    /// Even though the property as already been set when instantiating this call,
11594    /// we provide this method for API completeness.
11595    pub fn request(
11596        mut self,
11597        new_value: CustomDimension,
11598    ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11599        self._request = new_value;
11600        self
11601    }
11602    /// Account ID for the custom dimension to update.
11603    ///
11604    /// Sets the *account id* path property to the given value.
11605    ///
11606    /// Even though the property as already been set when instantiating this call,
11607    /// we provide this method for API completeness.
11608    pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionUpdateCall<'a, C> {
11609        self._account_id = new_value.to_string();
11610        self
11611    }
11612    /// Web property ID for the custom dimension to update.
11613    ///
11614    /// Sets the *web property id* path property to the given value.
11615    ///
11616    /// Even though the property as already been set when instantiating this call,
11617    /// we provide this method for API completeness.
11618    pub fn web_property_id(
11619        mut self,
11620        new_value: &str,
11621    ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11622        self._web_property_id = new_value.to_string();
11623        self
11624    }
11625    /// Custom dimension ID for the custom dimension to update.
11626    ///
11627    /// Sets the *custom dimension id* path property to the given value.
11628    ///
11629    /// Even though the property as already been set when instantiating this call,
11630    /// we provide this method for API completeness.
11631    pub fn custom_dimension_id(
11632        mut self,
11633        new_value: &str,
11634    ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11635        self._custom_dimension_id = new_value.to_string();
11636        self
11637    }
11638    /// Force the update and ignore any warnings related to the custom dimension being linked to a custom data source / data set.
11639    ///
11640    /// Sets the *ignore custom data source links* query property to the given value.
11641    pub fn ignore_custom_data_source_links(
11642        mut self,
11643        new_value: bool,
11644    ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11645        self._ignore_custom_data_source_links = Some(new_value);
11646        self
11647    }
11648    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11649    /// while executing the actual API request.
11650    ///
11651    /// ````text
11652    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11653    /// ````
11654    ///
11655    /// Sets the *delegate* property to the given value.
11656    pub fn delegate(
11657        mut self,
11658        new_value: &'a mut dyn common::Delegate,
11659    ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11660        self._delegate = Some(new_value);
11661        self
11662    }
11663
11664    /// Set any additional parameter of the query string used in the request.
11665    /// It should be used to set parameters which are not yet available through their own
11666    /// setters.
11667    ///
11668    /// Please note that this method must not be used to set any of the known parameters
11669    /// which have their own setter method. If done anyway, the request will fail.
11670    ///
11671    /// # Additional Parameters
11672    ///
11673    /// * *alt* (query-string) - Data format for the response.
11674    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11675    /// * *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.
11676    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11677    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11678    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11679    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11680    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionUpdateCall<'a, C>
11681    where
11682        T: AsRef<str>,
11683    {
11684        self._additional_params
11685            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11686        self
11687    }
11688
11689    /// Identifies the authorization scope for the method you are building.
11690    ///
11691    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11692    /// [`Scope::Edit`].
11693    ///
11694    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11695    /// tokens for more than one scope.
11696    ///
11697    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11698    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11699    /// sufficient, a read-write scope will do as well.
11700    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionUpdateCall<'a, C>
11701    where
11702        St: AsRef<str>,
11703    {
11704        self._scopes.insert(String::from(scope.as_ref()));
11705        self
11706    }
11707    /// Identifies the authorization scope(s) for the method you are building.
11708    ///
11709    /// See [`Self::add_scope()`] for details.
11710    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionUpdateCall<'a, C>
11711    where
11712        I: IntoIterator<Item = St>,
11713        St: AsRef<str>,
11714    {
11715        self._scopes
11716            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11717        self
11718    }
11719
11720    /// Removes all scopes, and no default scope will be used either.
11721    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11722    /// for details).
11723    pub fn clear_scopes(mut self) -> ManagementCustomDimensionUpdateCall<'a, C> {
11724        self._scopes.clear();
11725        self
11726    }
11727}
11728
11729/// Get a custom metric to which the user has access.
11730///
11731/// A builder for the *customMetrics.get* method supported by a *management* resource.
11732/// It is not used directly, but through a [`ManagementMethods`] instance.
11733///
11734/// # Example
11735///
11736/// Instantiate a resource method builder
11737///
11738/// ```test_harness,no_run
11739/// # extern crate hyper;
11740/// # extern crate hyper_rustls;
11741/// # extern crate google_analytics3 as analytics3;
11742/// # async fn dox() {
11743/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11744///
11745/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11746/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11747/// #     .with_native_roots()
11748/// #     .unwrap()
11749/// #     .https_only()
11750/// #     .enable_http2()
11751/// #     .build();
11752///
11753/// # let executor = hyper_util::rt::TokioExecutor::new();
11754/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11755/// #     secret,
11756/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11757/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11758/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11759/// #     ),
11760/// # ).build().await.unwrap();
11761///
11762/// # let client = hyper_util::client::legacy::Client::builder(
11763/// #     hyper_util::rt::TokioExecutor::new()
11764/// # )
11765/// # .build(
11766/// #     hyper_rustls::HttpsConnectorBuilder::new()
11767/// #         .with_native_roots()
11768/// #         .unwrap()
11769/// #         .https_or_http()
11770/// #         .enable_http2()
11771/// #         .build()
11772/// # );
11773/// # let mut hub = Analytics::new(client, auth);
11774/// // You can configure optional parameters by calling the respective setters at will, and
11775/// // execute the final call using `doit()`.
11776/// // Values shown here are possibly random and not representative !
11777/// let result = hub.management().custom_metrics_get("accountId", "webPropertyId", "customMetricId")
11778///              .doit().await;
11779/// # }
11780/// ```
11781pub struct ManagementCustomMetricGetCall<'a, C>
11782where
11783    C: 'a,
11784{
11785    hub: &'a Analytics<C>,
11786    _account_id: String,
11787    _web_property_id: String,
11788    _custom_metric_id: String,
11789    _delegate: Option<&'a mut dyn common::Delegate>,
11790    _additional_params: HashMap<String, String>,
11791    _scopes: BTreeSet<String>,
11792}
11793
11794impl<'a, C> common::CallBuilder for ManagementCustomMetricGetCall<'a, C> {}
11795
11796impl<'a, C> ManagementCustomMetricGetCall<'a, C>
11797where
11798    C: common::Connector,
11799{
11800    /// Perform the operation you have build so far.
11801    pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetric)> {
11802        use std::borrow::Cow;
11803        use std::io::{Read, Seek};
11804
11805        use common::{url::Params, ToParts};
11806        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11807
11808        let mut dd = common::DefaultDelegate;
11809        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11810        dlg.begin(common::MethodInfo {
11811            id: "analytics.management.customMetrics.get",
11812            http_method: hyper::Method::GET,
11813        });
11814
11815        for &field in ["alt", "accountId", "webPropertyId", "customMetricId"].iter() {
11816            if self._additional_params.contains_key(field) {
11817                dlg.finished(false);
11818                return Err(common::Error::FieldClash(field));
11819            }
11820        }
11821
11822        let mut params = Params::with_capacity(5 + self._additional_params.len());
11823        params.push("accountId", self._account_id);
11824        params.push("webPropertyId", self._web_property_id);
11825        params.push("customMetricId", self._custom_metric_id);
11826
11827        params.extend(self._additional_params.iter());
11828
11829        params.push("alt", "json");
11830        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics/{customMetricId}";
11831        if self._scopes.is_empty() {
11832            self._scopes.insert(Scope::Readonly.as_ref().to_string());
11833        }
11834
11835        #[allow(clippy::single_element_loop)]
11836        for &(find_this, param_name) in [
11837            ("{accountId}", "accountId"),
11838            ("{webPropertyId}", "webPropertyId"),
11839            ("{customMetricId}", "customMetricId"),
11840        ]
11841        .iter()
11842        {
11843            url = params.uri_replacement(url, param_name, find_this, false);
11844        }
11845        {
11846            let to_remove = ["customMetricId", "webPropertyId", "accountId"];
11847            params.remove_params(&to_remove);
11848        }
11849
11850        let url = params.parse_with_url(&url);
11851
11852        loop {
11853            let token = match self
11854                .hub
11855                .auth
11856                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11857                .await
11858            {
11859                Ok(token) => token,
11860                Err(e) => match dlg.token(e) {
11861                    Ok(token) => token,
11862                    Err(e) => {
11863                        dlg.finished(false);
11864                        return Err(common::Error::MissingToken(e));
11865                    }
11866                },
11867            };
11868            let mut req_result = {
11869                let client = &self.hub.client;
11870                dlg.pre_request();
11871                let mut req_builder = hyper::Request::builder()
11872                    .method(hyper::Method::GET)
11873                    .uri(url.as_str())
11874                    .header(USER_AGENT, self.hub._user_agent.clone());
11875
11876                if let Some(token) = token.as_ref() {
11877                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11878                }
11879
11880                let request = req_builder
11881                    .header(CONTENT_LENGTH, 0_u64)
11882                    .body(common::to_body::<String>(None));
11883
11884                client.request(request.unwrap()).await
11885            };
11886
11887            match req_result {
11888                Err(err) => {
11889                    if let common::Retry::After(d) = dlg.http_error(&err) {
11890                        sleep(d).await;
11891                        continue;
11892                    }
11893                    dlg.finished(false);
11894                    return Err(common::Error::HttpError(err));
11895                }
11896                Ok(res) => {
11897                    let (mut parts, body) = res.into_parts();
11898                    let mut body = common::Body::new(body);
11899                    if !parts.status.is_success() {
11900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11901                        let error = serde_json::from_str(&common::to_string(&bytes));
11902                        let response = common::to_response(parts, bytes.into());
11903
11904                        if let common::Retry::After(d) =
11905                            dlg.http_failure(&response, error.as_ref().ok())
11906                        {
11907                            sleep(d).await;
11908                            continue;
11909                        }
11910
11911                        dlg.finished(false);
11912
11913                        return Err(match error {
11914                            Ok(value) => common::Error::BadRequest(value),
11915                            _ => common::Error::Failure(response),
11916                        });
11917                    }
11918                    let response = {
11919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11920                        let encoded = common::to_string(&bytes);
11921                        match serde_json::from_str(&encoded) {
11922                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11923                            Err(error) => {
11924                                dlg.response_json_decode_error(&encoded, &error);
11925                                return Err(common::Error::JsonDecodeError(
11926                                    encoded.to_string(),
11927                                    error,
11928                                ));
11929                            }
11930                        }
11931                    };
11932
11933                    dlg.finished(true);
11934                    return Ok(response);
11935                }
11936            }
11937        }
11938    }
11939
11940    /// Account ID for the custom metric to retrieve.
11941    ///
11942    /// Sets the *account id* path property to the given value.
11943    ///
11944    /// Even though the property as already been set when instantiating this call,
11945    /// we provide this method for API completeness.
11946    pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricGetCall<'a, C> {
11947        self._account_id = new_value.to_string();
11948        self
11949    }
11950    /// Web property ID for the custom metric to retrieve.
11951    ///
11952    /// Sets the *web property id* path property to the given value.
11953    ///
11954    /// Even though the property as already been set when instantiating this call,
11955    /// we provide this method for API completeness.
11956    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricGetCall<'a, C> {
11957        self._web_property_id = new_value.to_string();
11958        self
11959    }
11960    /// The ID of the custom metric to retrieve.
11961    ///
11962    /// Sets the *custom metric id* path property to the given value.
11963    ///
11964    /// Even though the property as already been set when instantiating this call,
11965    /// we provide this method for API completeness.
11966    pub fn custom_metric_id(mut self, new_value: &str) -> ManagementCustomMetricGetCall<'a, C> {
11967        self._custom_metric_id = new_value.to_string();
11968        self
11969    }
11970    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11971    /// while executing the actual API request.
11972    ///
11973    /// ````text
11974    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11975    /// ````
11976    ///
11977    /// Sets the *delegate* property to the given value.
11978    pub fn delegate(
11979        mut self,
11980        new_value: &'a mut dyn common::Delegate,
11981    ) -> ManagementCustomMetricGetCall<'a, C> {
11982        self._delegate = Some(new_value);
11983        self
11984    }
11985
11986    /// Set any additional parameter of the query string used in the request.
11987    /// It should be used to set parameters which are not yet available through their own
11988    /// setters.
11989    ///
11990    /// Please note that this method must not be used to set any of the known parameters
11991    /// which have their own setter method. If done anyway, the request will fail.
11992    ///
11993    /// # Additional Parameters
11994    ///
11995    /// * *alt* (query-string) - Data format for the response.
11996    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11997    /// * *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.
11998    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11999    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12000    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12001    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12002    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricGetCall<'a, C>
12003    where
12004        T: AsRef<str>,
12005    {
12006        self._additional_params
12007            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12008        self
12009    }
12010
12011    /// Identifies the authorization scope for the method you are building.
12012    ///
12013    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12014    /// [`Scope::Readonly`].
12015    ///
12016    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12017    /// tokens for more than one scope.
12018    ///
12019    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12020    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12021    /// sufficient, a read-write scope will do as well.
12022    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricGetCall<'a, C>
12023    where
12024        St: AsRef<str>,
12025    {
12026        self._scopes.insert(String::from(scope.as_ref()));
12027        self
12028    }
12029    /// Identifies the authorization scope(s) for the method you are building.
12030    ///
12031    /// See [`Self::add_scope()`] for details.
12032    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricGetCall<'a, C>
12033    where
12034        I: IntoIterator<Item = St>,
12035        St: AsRef<str>,
12036    {
12037        self._scopes
12038            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12039        self
12040    }
12041
12042    /// Removes all scopes, and no default scope will be used either.
12043    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12044    /// for details).
12045    pub fn clear_scopes(mut self) -> ManagementCustomMetricGetCall<'a, C> {
12046        self._scopes.clear();
12047        self
12048    }
12049}
12050
12051/// Create a new custom metric.
12052///
12053/// A builder for the *customMetrics.insert* method supported by a *management* resource.
12054/// It is not used directly, but through a [`ManagementMethods`] instance.
12055///
12056/// # Example
12057///
12058/// Instantiate a resource method builder
12059///
12060/// ```test_harness,no_run
12061/// # extern crate hyper;
12062/// # extern crate hyper_rustls;
12063/// # extern crate google_analytics3 as analytics3;
12064/// use analytics3::api::CustomMetric;
12065/// # async fn dox() {
12066/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12067///
12068/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12069/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12070/// #     .with_native_roots()
12071/// #     .unwrap()
12072/// #     .https_only()
12073/// #     .enable_http2()
12074/// #     .build();
12075///
12076/// # let executor = hyper_util::rt::TokioExecutor::new();
12077/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12078/// #     secret,
12079/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12080/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12081/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12082/// #     ),
12083/// # ).build().await.unwrap();
12084///
12085/// # let client = hyper_util::client::legacy::Client::builder(
12086/// #     hyper_util::rt::TokioExecutor::new()
12087/// # )
12088/// # .build(
12089/// #     hyper_rustls::HttpsConnectorBuilder::new()
12090/// #         .with_native_roots()
12091/// #         .unwrap()
12092/// #         .https_or_http()
12093/// #         .enable_http2()
12094/// #         .build()
12095/// # );
12096/// # let mut hub = Analytics::new(client, auth);
12097/// // As the method needs a request, you would usually fill it with the desired information
12098/// // into the respective structure. Some of the parts shown here might not be applicable !
12099/// // Values shown here are possibly random and not representative !
12100/// let mut req = CustomMetric::default();
12101///
12102/// // You can configure optional parameters by calling the respective setters at will, and
12103/// // execute the final call using `doit()`.
12104/// // Values shown here are possibly random and not representative !
12105/// let result = hub.management().custom_metrics_insert(req, "accountId", "webPropertyId")
12106///              .doit().await;
12107/// # }
12108/// ```
12109pub struct ManagementCustomMetricInsertCall<'a, C>
12110where
12111    C: 'a,
12112{
12113    hub: &'a Analytics<C>,
12114    _request: CustomMetric,
12115    _account_id: String,
12116    _web_property_id: String,
12117    _delegate: Option<&'a mut dyn common::Delegate>,
12118    _additional_params: HashMap<String, String>,
12119    _scopes: BTreeSet<String>,
12120}
12121
12122impl<'a, C> common::CallBuilder for ManagementCustomMetricInsertCall<'a, C> {}
12123
12124impl<'a, C> ManagementCustomMetricInsertCall<'a, C>
12125where
12126    C: common::Connector,
12127{
12128    /// Perform the operation you have build so far.
12129    pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetric)> {
12130        use std::borrow::Cow;
12131        use std::io::{Read, Seek};
12132
12133        use common::{url::Params, ToParts};
12134        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12135
12136        let mut dd = common::DefaultDelegate;
12137        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12138        dlg.begin(common::MethodInfo {
12139            id: "analytics.management.customMetrics.insert",
12140            http_method: hyper::Method::POST,
12141        });
12142
12143        for &field in ["alt", "accountId", "webPropertyId"].iter() {
12144            if self._additional_params.contains_key(field) {
12145                dlg.finished(false);
12146                return Err(common::Error::FieldClash(field));
12147            }
12148        }
12149
12150        let mut params = Params::with_capacity(5 + self._additional_params.len());
12151        params.push("accountId", self._account_id);
12152        params.push("webPropertyId", self._web_property_id);
12153
12154        params.extend(self._additional_params.iter());
12155
12156        params.push("alt", "json");
12157        let mut url = self.hub._base_url.clone()
12158            + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics";
12159        if self._scopes.is_empty() {
12160            self._scopes.insert(Scope::Edit.as_ref().to_string());
12161        }
12162
12163        #[allow(clippy::single_element_loop)]
12164        for &(find_this, param_name) in [
12165            ("{accountId}", "accountId"),
12166            ("{webPropertyId}", "webPropertyId"),
12167        ]
12168        .iter()
12169        {
12170            url = params.uri_replacement(url, param_name, find_this, false);
12171        }
12172        {
12173            let to_remove = ["webPropertyId", "accountId"];
12174            params.remove_params(&to_remove);
12175        }
12176
12177        let url = params.parse_with_url(&url);
12178
12179        let mut json_mime_type = mime::APPLICATION_JSON;
12180        let mut request_value_reader = {
12181            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12182            common::remove_json_null_values(&mut value);
12183            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12184            serde_json::to_writer(&mut dst, &value).unwrap();
12185            dst
12186        };
12187        let request_size = request_value_reader
12188            .seek(std::io::SeekFrom::End(0))
12189            .unwrap();
12190        request_value_reader
12191            .seek(std::io::SeekFrom::Start(0))
12192            .unwrap();
12193
12194        loop {
12195            let token = match self
12196                .hub
12197                .auth
12198                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12199                .await
12200            {
12201                Ok(token) => token,
12202                Err(e) => match dlg.token(e) {
12203                    Ok(token) => token,
12204                    Err(e) => {
12205                        dlg.finished(false);
12206                        return Err(common::Error::MissingToken(e));
12207                    }
12208                },
12209            };
12210            request_value_reader
12211                .seek(std::io::SeekFrom::Start(0))
12212                .unwrap();
12213            let mut req_result = {
12214                let client = &self.hub.client;
12215                dlg.pre_request();
12216                let mut req_builder = hyper::Request::builder()
12217                    .method(hyper::Method::POST)
12218                    .uri(url.as_str())
12219                    .header(USER_AGENT, self.hub._user_agent.clone());
12220
12221                if let Some(token) = token.as_ref() {
12222                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12223                }
12224
12225                let request = req_builder
12226                    .header(CONTENT_TYPE, json_mime_type.to_string())
12227                    .header(CONTENT_LENGTH, request_size as u64)
12228                    .body(common::to_body(
12229                        request_value_reader.get_ref().clone().into(),
12230                    ));
12231
12232                client.request(request.unwrap()).await
12233            };
12234
12235            match req_result {
12236                Err(err) => {
12237                    if let common::Retry::After(d) = dlg.http_error(&err) {
12238                        sleep(d).await;
12239                        continue;
12240                    }
12241                    dlg.finished(false);
12242                    return Err(common::Error::HttpError(err));
12243                }
12244                Ok(res) => {
12245                    let (mut parts, body) = res.into_parts();
12246                    let mut body = common::Body::new(body);
12247                    if !parts.status.is_success() {
12248                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12249                        let error = serde_json::from_str(&common::to_string(&bytes));
12250                        let response = common::to_response(parts, bytes.into());
12251
12252                        if let common::Retry::After(d) =
12253                            dlg.http_failure(&response, error.as_ref().ok())
12254                        {
12255                            sleep(d).await;
12256                            continue;
12257                        }
12258
12259                        dlg.finished(false);
12260
12261                        return Err(match error {
12262                            Ok(value) => common::Error::BadRequest(value),
12263                            _ => common::Error::Failure(response),
12264                        });
12265                    }
12266                    let response = {
12267                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12268                        let encoded = common::to_string(&bytes);
12269                        match serde_json::from_str(&encoded) {
12270                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12271                            Err(error) => {
12272                                dlg.response_json_decode_error(&encoded, &error);
12273                                return Err(common::Error::JsonDecodeError(
12274                                    encoded.to_string(),
12275                                    error,
12276                                ));
12277                            }
12278                        }
12279                    };
12280
12281                    dlg.finished(true);
12282                    return Ok(response);
12283                }
12284            }
12285        }
12286    }
12287
12288    ///
12289    /// Sets the *request* property to the given value.
12290    ///
12291    /// Even though the property as already been set when instantiating this call,
12292    /// we provide this method for API completeness.
12293    pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricInsertCall<'a, C> {
12294        self._request = new_value;
12295        self
12296    }
12297    /// Account ID for the custom metric to create.
12298    ///
12299    /// Sets the *account id* path property to the given value.
12300    ///
12301    /// Even though the property as already been set when instantiating this call,
12302    /// we provide this method for API completeness.
12303    pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricInsertCall<'a, C> {
12304        self._account_id = new_value.to_string();
12305        self
12306    }
12307    /// Web property ID for the custom dimension to create.
12308    ///
12309    /// Sets the *web property id* path property to the given value.
12310    ///
12311    /// Even though the property as already been set when instantiating this call,
12312    /// we provide this method for API completeness.
12313    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricInsertCall<'a, C> {
12314        self._web_property_id = new_value.to_string();
12315        self
12316    }
12317    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12318    /// while executing the actual API request.
12319    ///
12320    /// ````text
12321    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12322    /// ````
12323    ///
12324    /// Sets the *delegate* property to the given value.
12325    pub fn delegate(
12326        mut self,
12327        new_value: &'a mut dyn common::Delegate,
12328    ) -> ManagementCustomMetricInsertCall<'a, C> {
12329        self._delegate = Some(new_value);
12330        self
12331    }
12332
12333    /// Set any additional parameter of the query string used in the request.
12334    /// It should be used to set parameters which are not yet available through their own
12335    /// setters.
12336    ///
12337    /// Please note that this method must not be used to set any of the known parameters
12338    /// which have their own setter method. If done anyway, the request will fail.
12339    ///
12340    /// # Additional Parameters
12341    ///
12342    /// * *alt* (query-string) - Data format for the response.
12343    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12344    /// * *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.
12345    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12346    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12347    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12348    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12349    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricInsertCall<'a, C>
12350    where
12351        T: AsRef<str>,
12352    {
12353        self._additional_params
12354            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12355        self
12356    }
12357
12358    /// Identifies the authorization scope for the method you are building.
12359    ///
12360    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12361    /// [`Scope::Edit`].
12362    ///
12363    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12364    /// tokens for more than one scope.
12365    ///
12366    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12367    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12368    /// sufficient, a read-write scope will do as well.
12369    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricInsertCall<'a, C>
12370    where
12371        St: AsRef<str>,
12372    {
12373        self._scopes.insert(String::from(scope.as_ref()));
12374        self
12375    }
12376    /// Identifies the authorization scope(s) for the method you are building.
12377    ///
12378    /// See [`Self::add_scope()`] for details.
12379    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricInsertCall<'a, C>
12380    where
12381        I: IntoIterator<Item = St>,
12382        St: AsRef<str>,
12383    {
12384        self._scopes
12385            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12386        self
12387    }
12388
12389    /// Removes all scopes, and no default scope will be used either.
12390    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12391    /// for details).
12392    pub fn clear_scopes(mut self) -> ManagementCustomMetricInsertCall<'a, C> {
12393        self._scopes.clear();
12394        self
12395    }
12396}
12397
12398/// Lists custom metrics to which the user has access.
12399///
12400/// A builder for the *customMetrics.list* method supported by a *management* resource.
12401/// It is not used directly, but through a [`ManagementMethods`] instance.
12402///
12403/// # Example
12404///
12405/// Instantiate a resource method builder
12406///
12407/// ```test_harness,no_run
12408/// # extern crate hyper;
12409/// # extern crate hyper_rustls;
12410/// # extern crate google_analytics3 as analytics3;
12411/// # async fn dox() {
12412/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12413///
12414/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12415/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12416/// #     .with_native_roots()
12417/// #     .unwrap()
12418/// #     .https_only()
12419/// #     .enable_http2()
12420/// #     .build();
12421///
12422/// # let executor = hyper_util::rt::TokioExecutor::new();
12423/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12424/// #     secret,
12425/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12426/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12427/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12428/// #     ),
12429/// # ).build().await.unwrap();
12430///
12431/// # let client = hyper_util::client::legacy::Client::builder(
12432/// #     hyper_util::rt::TokioExecutor::new()
12433/// # )
12434/// # .build(
12435/// #     hyper_rustls::HttpsConnectorBuilder::new()
12436/// #         .with_native_roots()
12437/// #         .unwrap()
12438/// #         .https_or_http()
12439/// #         .enable_http2()
12440/// #         .build()
12441/// # );
12442/// # let mut hub = Analytics::new(client, auth);
12443/// // You can configure optional parameters by calling the respective setters at will, and
12444/// // execute the final call using `doit()`.
12445/// // Values shown here are possibly random and not representative !
12446/// let result = hub.management().custom_metrics_list("accountId", "webPropertyId")
12447///              .start_index(-2)
12448///              .max_results(-30)
12449///              .doit().await;
12450/// # }
12451/// ```
12452pub struct ManagementCustomMetricListCall<'a, C>
12453where
12454    C: 'a,
12455{
12456    hub: &'a Analytics<C>,
12457    _account_id: String,
12458    _web_property_id: String,
12459    _start_index: Option<i32>,
12460    _max_results: Option<i32>,
12461    _delegate: Option<&'a mut dyn common::Delegate>,
12462    _additional_params: HashMap<String, String>,
12463    _scopes: BTreeSet<String>,
12464}
12465
12466impl<'a, C> common::CallBuilder for ManagementCustomMetricListCall<'a, C> {}
12467
12468impl<'a, C> ManagementCustomMetricListCall<'a, C>
12469where
12470    C: common::Connector,
12471{
12472    /// Perform the operation you have build so far.
12473    pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetrics)> {
12474        use std::borrow::Cow;
12475        use std::io::{Read, Seek};
12476
12477        use common::{url::Params, ToParts};
12478        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12479
12480        let mut dd = common::DefaultDelegate;
12481        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12482        dlg.begin(common::MethodInfo {
12483            id: "analytics.management.customMetrics.list",
12484            http_method: hyper::Method::GET,
12485        });
12486
12487        for &field in [
12488            "alt",
12489            "accountId",
12490            "webPropertyId",
12491            "start-index",
12492            "max-results",
12493        ]
12494        .iter()
12495        {
12496            if self._additional_params.contains_key(field) {
12497                dlg.finished(false);
12498                return Err(common::Error::FieldClash(field));
12499            }
12500        }
12501
12502        let mut params = Params::with_capacity(6 + self._additional_params.len());
12503        params.push("accountId", self._account_id);
12504        params.push("webPropertyId", self._web_property_id);
12505        if let Some(value) = self._start_index.as_ref() {
12506            params.push("start-index", value.to_string());
12507        }
12508        if let Some(value) = self._max_results.as_ref() {
12509            params.push("max-results", value.to_string());
12510        }
12511
12512        params.extend(self._additional_params.iter());
12513
12514        params.push("alt", "json");
12515        let mut url = self.hub._base_url.clone()
12516            + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics";
12517        if self._scopes.is_empty() {
12518            self._scopes.insert(Scope::Readonly.as_ref().to_string());
12519        }
12520
12521        #[allow(clippy::single_element_loop)]
12522        for &(find_this, param_name) in [
12523            ("{accountId}", "accountId"),
12524            ("{webPropertyId}", "webPropertyId"),
12525        ]
12526        .iter()
12527        {
12528            url = params.uri_replacement(url, param_name, find_this, false);
12529        }
12530        {
12531            let to_remove = ["webPropertyId", "accountId"];
12532            params.remove_params(&to_remove);
12533        }
12534
12535        let url = params.parse_with_url(&url);
12536
12537        loop {
12538            let token = match self
12539                .hub
12540                .auth
12541                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12542                .await
12543            {
12544                Ok(token) => token,
12545                Err(e) => match dlg.token(e) {
12546                    Ok(token) => token,
12547                    Err(e) => {
12548                        dlg.finished(false);
12549                        return Err(common::Error::MissingToken(e));
12550                    }
12551                },
12552            };
12553            let mut req_result = {
12554                let client = &self.hub.client;
12555                dlg.pre_request();
12556                let mut req_builder = hyper::Request::builder()
12557                    .method(hyper::Method::GET)
12558                    .uri(url.as_str())
12559                    .header(USER_AGENT, self.hub._user_agent.clone());
12560
12561                if let Some(token) = token.as_ref() {
12562                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12563                }
12564
12565                let request = req_builder
12566                    .header(CONTENT_LENGTH, 0_u64)
12567                    .body(common::to_body::<String>(None));
12568
12569                client.request(request.unwrap()).await
12570            };
12571
12572            match req_result {
12573                Err(err) => {
12574                    if let common::Retry::After(d) = dlg.http_error(&err) {
12575                        sleep(d).await;
12576                        continue;
12577                    }
12578                    dlg.finished(false);
12579                    return Err(common::Error::HttpError(err));
12580                }
12581                Ok(res) => {
12582                    let (mut parts, body) = res.into_parts();
12583                    let mut body = common::Body::new(body);
12584                    if !parts.status.is_success() {
12585                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12586                        let error = serde_json::from_str(&common::to_string(&bytes));
12587                        let response = common::to_response(parts, bytes.into());
12588
12589                        if let common::Retry::After(d) =
12590                            dlg.http_failure(&response, error.as_ref().ok())
12591                        {
12592                            sleep(d).await;
12593                            continue;
12594                        }
12595
12596                        dlg.finished(false);
12597
12598                        return Err(match error {
12599                            Ok(value) => common::Error::BadRequest(value),
12600                            _ => common::Error::Failure(response),
12601                        });
12602                    }
12603                    let response = {
12604                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12605                        let encoded = common::to_string(&bytes);
12606                        match serde_json::from_str(&encoded) {
12607                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12608                            Err(error) => {
12609                                dlg.response_json_decode_error(&encoded, &error);
12610                                return Err(common::Error::JsonDecodeError(
12611                                    encoded.to_string(),
12612                                    error,
12613                                ));
12614                            }
12615                        }
12616                    };
12617
12618                    dlg.finished(true);
12619                    return Ok(response);
12620                }
12621            }
12622        }
12623    }
12624
12625    /// Account ID for the custom metrics to retrieve.
12626    ///
12627    /// Sets the *account id* path property to the given value.
12628    ///
12629    /// Even though the property as already been set when instantiating this call,
12630    /// we provide this method for API completeness.
12631    pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricListCall<'a, C> {
12632        self._account_id = new_value.to_string();
12633        self
12634    }
12635    /// Web property ID for the custom metrics to retrieve.
12636    ///
12637    /// Sets the *web property id* path property to the given value.
12638    ///
12639    /// Even though the property as already been set when instantiating this call,
12640    /// we provide this method for API completeness.
12641    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricListCall<'a, C> {
12642        self._web_property_id = new_value.to_string();
12643        self
12644    }
12645    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
12646    ///
12647    /// Sets the *start-index* query property to the given value.
12648    pub fn start_index(mut self, new_value: i32) -> ManagementCustomMetricListCall<'a, C> {
12649        self._start_index = Some(new_value);
12650        self
12651    }
12652    /// The maximum number of custom metrics to include in this response.
12653    ///
12654    /// Sets the *max-results* query property to the given value.
12655    pub fn max_results(mut self, new_value: i32) -> ManagementCustomMetricListCall<'a, C> {
12656        self._max_results = Some(new_value);
12657        self
12658    }
12659    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12660    /// while executing the actual API request.
12661    ///
12662    /// ````text
12663    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12664    /// ````
12665    ///
12666    /// Sets the *delegate* property to the given value.
12667    pub fn delegate(
12668        mut self,
12669        new_value: &'a mut dyn common::Delegate,
12670    ) -> ManagementCustomMetricListCall<'a, C> {
12671        self._delegate = Some(new_value);
12672        self
12673    }
12674
12675    /// Set any additional parameter of the query string used in the request.
12676    /// It should be used to set parameters which are not yet available through their own
12677    /// setters.
12678    ///
12679    /// Please note that this method must not be used to set any of the known parameters
12680    /// which have their own setter method. If done anyway, the request will fail.
12681    ///
12682    /// # Additional Parameters
12683    ///
12684    /// * *alt* (query-string) - Data format for the response.
12685    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12686    /// * *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.
12687    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12688    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12689    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12690    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12691    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricListCall<'a, C>
12692    where
12693        T: AsRef<str>,
12694    {
12695        self._additional_params
12696            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12697        self
12698    }
12699
12700    /// Identifies the authorization scope for the method you are building.
12701    ///
12702    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12703    /// [`Scope::Readonly`].
12704    ///
12705    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12706    /// tokens for more than one scope.
12707    ///
12708    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12709    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12710    /// sufficient, a read-write scope will do as well.
12711    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricListCall<'a, C>
12712    where
12713        St: AsRef<str>,
12714    {
12715        self._scopes.insert(String::from(scope.as_ref()));
12716        self
12717    }
12718    /// Identifies the authorization scope(s) for the method you are building.
12719    ///
12720    /// See [`Self::add_scope()`] for details.
12721    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricListCall<'a, C>
12722    where
12723        I: IntoIterator<Item = St>,
12724        St: AsRef<str>,
12725    {
12726        self._scopes
12727            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12728        self
12729    }
12730
12731    /// Removes all scopes, and no default scope will be used either.
12732    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12733    /// for details).
12734    pub fn clear_scopes(mut self) -> ManagementCustomMetricListCall<'a, C> {
12735        self._scopes.clear();
12736        self
12737    }
12738}
12739
12740/// Updates an existing custom metric. This method supports patch semantics.
12741///
12742/// A builder for the *customMetrics.patch* method supported by a *management* resource.
12743/// It is not used directly, but through a [`ManagementMethods`] instance.
12744///
12745/// # Example
12746///
12747/// Instantiate a resource method builder
12748///
12749/// ```test_harness,no_run
12750/// # extern crate hyper;
12751/// # extern crate hyper_rustls;
12752/// # extern crate google_analytics3 as analytics3;
12753/// use analytics3::api::CustomMetric;
12754/// # async fn dox() {
12755/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12756///
12757/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12758/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12759/// #     .with_native_roots()
12760/// #     .unwrap()
12761/// #     .https_only()
12762/// #     .enable_http2()
12763/// #     .build();
12764///
12765/// # let executor = hyper_util::rt::TokioExecutor::new();
12766/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12767/// #     secret,
12768/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12769/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12770/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12771/// #     ),
12772/// # ).build().await.unwrap();
12773///
12774/// # let client = hyper_util::client::legacy::Client::builder(
12775/// #     hyper_util::rt::TokioExecutor::new()
12776/// # )
12777/// # .build(
12778/// #     hyper_rustls::HttpsConnectorBuilder::new()
12779/// #         .with_native_roots()
12780/// #         .unwrap()
12781/// #         .https_or_http()
12782/// #         .enable_http2()
12783/// #         .build()
12784/// # );
12785/// # let mut hub = Analytics::new(client, auth);
12786/// // As the method needs a request, you would usually fill it with the desired information
12787/// // into the respective structure. Some of the parts shown here might not be applicable !
12788/// // Values shown here are possibly random and not representative !
12789/// let mut req = CustomMetric::default();
12790///
12791/// // You can configure optional parameters by calling the respective setters at will, and
12792/// // execute the final call using `doit()`.
12793/// // Values shown here are possibly random and not representative !
12794/// let result = hub.management().custom_metrics_patch(req, "accountId", "webPropertyId", "customMetricId")
12795///              .ignore_custom_data_source_links(false)
12796///              .doit().await;
12797/// # }
12798/// ```
12799pub struct ManagementCustomMetricPatchCall<'a, C>
12800where
12801    C: 'a,
12802{
12803    hub: &'a Analytics<C>,
12804    _request: CustomMetric,
12805    _account_id: String,
12806    _web_property_id: String,
12807    _custom_metric_id: String,
12808    _ignore_custom_data_source_links: Option<bool>,
12809    _delegate: Option<&'a mut dyn common::Delegate>,
12810    _additional_params: HashMap<String, String>,
12811    _scopes: BTreeSet<String>,
12812}
12813
12814impl<'a, C> common::CallBuilder for ManagementCustomMetricPatchCall<'a, C> {}
12815
12816impl<'a, C> ManagementCustomMetricPatchCall<'a, C>
12817where
12818    C: common::Connector,
12819{
12820    /// Perform the operation you have build so far.
12821    pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetric)> {
12822        use std::borrow::Cow;
12823        use std::io::{Read, Seek};
12824
12825        use common::{url::Params, ToParts};
12826        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12827
12828        let mut dd = common::DefaultDelegate;
12829        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12830        dlg.begin(common::MethodInfo {
12831            id: "analytics.management.customMetrics.patch",
12832            http_method: hyper::Method::PATCH,
12833        });
12834
12835        for &field in [
12836            "alt",
12837            "accountId",
12838            "webPropertyId",
12839            "customMetricId",
12840            "ignoreCustomDataSourceLinks",
12841        ]
12842        .iter()
12843        {
12844            if self._additional_params.contains_key(field) {
12845                dlg.finished(false);
12846                return Err(common::Error::FieldClash(field));
12847            }
12848        }
12849
12850        let mut params = Params::with_capacity(7 + self._additional_params.len());
12851        params.push("accountId", self._account_id);
12852        params.push("webPropertyId", self._web_property_id);
12853        params.push("customMetricId", self._custom_metric_id);
12854        if let Some(value) = self._ignore_custom_data_source_links.as_ref() {
12855            params.push("ignoreCustomDataSourceLinks", value.to_string());
12856        }
12857
12858        params.extend(self._additional_params.iter());
12859
12860        params.push("alt", "json");
12861        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics/{customMetricId}";
12862        if self._scopes.is_empty() {
12863            self._scopes.insert(Scope::Edit.as_ref().to_string());
12864        }
12865
12866        #[allow(clippy::single_element_loop)]
12867        for &(find_this, param_name) in [
12868            ("{accountId}", "accountId"),
12869            ("{webPropertyId}", "webPropertyId"),
12870            ("{customMetricId}", "customMetricId"),
12871        ]
12872        .iter()
12873        {
12874            url = params.uri_replacement(url, param_name, find_this, false);
12875        }
12876        {
12877            let to_remove = ["customMetricId", "webPropertyId", "accountId"];
12878            params.remove_params(&to_remove);
12879        }
12880
12881        let url = params.parse_with_url(&url);
12882
12883        let mut json_mime_type = mime::APPLICATION_JSON;
12884        let mut request_value_reader = {
12885            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12886            common::remove_json_null_values(&mut value);
12887            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12888            serde_json::to_writer(&mut dst, &value).unwrap();
12889            dst
12890        };
12891        let request_size = request_value_reader
12892            .seek(std::io::SeekFrom::End(0))
12893            .unwrap();
12894        request_value_reader
12895            .seek(std::io::SeekFrom::Start(0))
12896            .unwrap();
12897
12898        loop {
12899            let token = match self
12900                .hub
12901                .auth
12902                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12903                .await
12904            {
12905                Ok(token) => token,
12906                Err(e) => match dlg.token(e) {
12907                    Ok(token) => token,
12908                    Err(e) => {
12909                        dlg.finished(false);
12910                        return Err(common::Error::MissingToken(e));
12911                    }
12912                },
12913            };
12914            request_value_reader
12915                .seek(std::io::SeekFrom::Start(0))
12916                .unwrap();
12917            let mut req_result = {
12918                let client = &self.hub.client;
12919                dlg.pre_request();
12920                let mut req_builder = hyper::Request::builder()
12921                    .method(hyper::Method::PATCH)
12922                    .uri(url.as_str())
12923                    .header(USER_AGENT, self.hub._user_agent.clone());
12924
12925                if let Some(token) = token.as_ref() {
12926                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12927                }
12928
12929                let request = req_builder
12930                    .header(CONTENT_TYPE, json_mime_type.to_string())
12931                    .header(CONTENT_LENGTH, request_size as u64)
12932                    .body(common::to_body(
12933                        request_value_reader.get_ref().clone().into(),
12934                    ));
12935
12936                client.request(request.unwrap()).await
12937            };
12938
12939            match req_result {
12940                Err(err) => {
12941                    if let common::Retry::After(d) = dlg.http_error(&err) {
12942                        sleep(d).await;
12943                        continue;
12944                    }
12945                    dlg.finished(false);
12946                    return Err(common::Error::HttpError(err));
12947                }
12948                Ok(res) => {
12949                    let (mut parts, body) = res.into_parts();
12950                    let mut body = common::Body::new(body);
12951                    if !parts.status.is_success() {
12952                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12953                        let error = serde_json::from_str(&common::to_string(&bytes));
12954                        let response = common::to_response(parts, bytes.into());
12955
12956                        if let common::Retry::After(d) =
12957                            dlg.http_failure(&response, error.as_ref().ok())
12958                        {
12959                            sleep(d).await;
12960                            continue;
12961                        }
12962
12963                        dlg.finished(false);
12964
12965                        return Err(match error {
12966                            Ok(value) => common::Error::BadRequest(value),
12967                            _ => common::Error::Failure(response),
12968                        });
12969                    }
12970                    let response = {
12971                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12972                        let encoded = common::to_string(&bytes);
12973                        match serde_json::from_str(&encoded) {
12974                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12975                            Err(error) => {
12976                                dlg.response_json_decode_error(&encoded, &error);
12977                                return Err(common::Error::JsonDecodeError(
12978                                    encoded.to_string(),
12979                                    error,
12980                                ));
12981                            }
12982                        }
12983                    };
12984
12985                    dlg.finished(true);
12986                    return Ok(response);
12987                }
12988            }
12989        }
12990    }
12991
12992    ///
12993    /// Sets the *request* property to the given value.
12994    ///
12995    /// Even though the property as already been set when instantiating this call,
12996    /// we provide this method for API completeness.
12997    pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricPatchCall<'a, C> {
12998        self._request = new_value;
12999        self
13000    }
13001    /// Account ID for the custom metric to update.
13002    ///
13003    /// Sets the *account id* path property to the given value.
13004    ///
13005    /// Even though the property as already been set when instantiating this call,
13006    /// we provide this method for API completeness.
13007    pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricPatchCall<'a, C> {
13008        self._account_id = new_value.to_string();
13009        self
13010    }
13011    /// Web property ID for the custom metric to update.
13012    ///
13013    /// Sets the *web property id* path property to the given value.
13014    ///
13015    /// Even though the property as already been set when instantiating this call,
13016    /// we provide this method for API completeness.
13017    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricPatchCall<'a, C> {
13018        self._web_property_id = new_value.to_string();
13019        self
13020    }
13021    /// Custom metric ID for the custom metric to update.
13022    ///
13023    /// Sets the *custom metric id* path property to the given value.
13024    ///
13025    /// Even though the property as already been set when instantiating this call,
13026    /// we provide this method for API completeness.
13027    pub fn custom_metric_id(mut self, new_value: &str) -> ManagementCustomMetricPatchCall<'a, C> {
13028        self._custom_metric_id = new_value.to_string();
13029        self
13030    }
13031    /// Force the update and ignore any warnings related to the custom metric being linked to a custom data source / data set.
13032    ///
13033    /// Sets the *ignore custom data source links* query property to the given value.
13034    pub fn ignore_custom_data_source_links(
13035        mut self,
13036        new_value: bool,
13037    ) -> ManagementCustomMetricPatchCall<'a, C> {
13038        self._ignore_custom_data_source_links = Some(new_value);
13039        self
13040    }
13041    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13042    /// while executing the actual API request.
13043    ///
13044    /// ````text
13045    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13046    /// ````
13047    ///
13048    /// Sets the *delegate* property to the given value.
13049    pub fn delegate(
13050        mut self,
13051        new_value: &'a mut dyn common::Delegate,
13052    ) -> ManagementCustomMetricPatchCall<'a, C> {
13053        self._delegate = Some(new_value);
13054        self
13055    }
13056
13057    /// Set any additional parameter of the query string used in the request.
13058    /// It should be used to set parameters which are not yet available through their own
13059    /// setters.
13060    ///
13061    /// Please note that this method must not be used to set any of the known parameters
13062    /// which have their own setter method. If done anyway, the request will fail.
13063    ///
13064    /// # Additional Parameters
13065    ///
13066    /// * *alt* (query-string) - Data format for the response.
13067    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13068    /// * *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.
13069    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13070    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13071    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13072    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13073    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricPatchCall<'a, C>
13074    where
13075        T: AsRef<str>,
13076    {
13077        self._additional_params
13078            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13079        self
13080    }
13081
13082    /// Identifies the authorization scope for the method you are building.
13083    ///
13084    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13085    /// [`Scope::Edit`].
13086    ///
13087    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13088    /// tokens for more than one scope.
13089    ///
13090    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13091    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13092    /// sufficient, a read-write scope will do as well.
13093    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricPatchCall<'a, C>
13094    where
13095        St: AsRef<str>,
13096    {
13097        self._scopes.insert(String::from(scope.as_ref()));
13098        self
13099    }
13100    /// Identifies the authorization scope(s) for the method you are building.
13101    ///
13102    /// See [`Self::add_scope()`] for details.
13103    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricPatchCall<'a, C>
13104    where
13105        I: IntoIterator<Item = St>,
13106        St: AsRef<str>,
13107    {
13108        self._scopes
13109            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13110        self
13111    }
13112
13113    /// Removes all scopes, and no default scope will be used either.
13114    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13115    /// for details).
13116    pub fn clear_scopes(mut self) -> ManagementCustomMetricPatchCall<'a, C> {
13117        self._scopes.clear();
13118        self
13119    }
13120}
13121
13122/// Updates an existing custom metric.
13123///
13124/// A builder for the *customMetrics.update* method supported by a *management* resource.
13125/// It is not used directly, but through a [`ManagementMethods`] instance.
13126///
13127/// # Example
13128///
13129/// Instantiate a resource method builder
13130///
13131/// ```test_harness,no_run
13132/// # extern crate hyper;
13133/// # extern crate hyper_rustls;
13134/// # extern crate google_analytics3 as analytics3;
13135/// use analytics3::api::CustomMetric;
13136/// # async fn dox() {
13137/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13138///
13139/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13140/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13141/// #     .with_native_roots()
13142/// #     .unwrap()
13143/// #     .https_only()
13144/// #     .enable_http2()
13145/// #     .build();
13146///
13147/// # let executor = hyper_util::rt::TokioExecutor::new();
13148/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13149/// #     secret,
13150/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13151/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13152/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13153/// #     ),
13154/// # ).build().await.unwrap();
13155///
13156/// # let client = hyper_util::client::legacy::Client::builder(
13157/// #     hyper_util::rt::TokioExecutor::new()
13158/// # )
13159/// # .build(
13160/// #     hyper_rustls::HttpsConnectorBuilder::new()
13161/// #         .with_native_roots()
13162/// #         .unwrap()
13163/// #         .https_or_http()
13164/// #         .enable_http2()
13165/// #         .build()
13166/// # );
13167/// # let mut hub = Analytics::new(client, auth);
13168/// // As the method needs a request, you would usually fill it with the desired information
13169/// // into the respective structure. Some of the parts shown here might not be applicable !
13170/// // Values shown here are possibly random and not representative !
13171/// let mut req = CustomMetric::default();
13172///
13173/// // You can configure optional parameters by calling the respective setters at will, and
13174/// // execute the final call using `doit()`.
13175/// // Values shown here are possibly random and not representative !
13176/// let result = hub.management().custom_metrics_update(req, "accountId", "webPropertyId", "customMetricId")
13177///              .ignore_custom_data_source_links(false)
13178///              .doit().await;
13179/// # }
13180/// ```
13181pub struct ManagementCustomMetricUpdateCall<'a, C>
13182where
13183    C: 'a,
13184{
13185    hub: &'a Analytics<C>,
13186    _request: CustomMetric,
13187    _account_id: String,
13188    _web_property_id: String,
13189    _custom_metric_id: String,
13190    _ignore_custom_data_source_links: Option<bool>,
13191    _delegate: Option<&'a mut dyn common::Delegate>,
13192    _additional_params: HashMap<String, String>,
13193    _scopes: BTreeSet<String>,
13194}
13195
13196impl<'a, C> common::CallBuilder for ManagementCustomMetricUpdateCall<'a, C> {}
13197
13198impl<'a, C> ManagementCustomMetricUpdateCall<'a, C>
13199where
13200    C: common::Connector,
13201{
13202    /// Perform the operation you have build so far.
13203    pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetric)> {
13204        use std::borrow::Cow;
13205        use std::io::{Read, Seek};
13206
13207        use common::{url::Params, ToParts};
13208        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13209
13210        let mut dd = common::DefaultDelegate;
13211        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13212        dlg.begin(common::MethodInfo {
13213            id: "analytics.management.customMetrics.update",
13214            http_method: hyper::Method::PUT,
13215        });
13216
13217        for &field in [
13218            "alt",
13219            "accountId",
13220            "webPropertyId",
13221            "customMetricId",
13222            "ignoreCustomDataSourceLinks",
13223        ]
13224        .iter()
13225        {
13226            if self._additional_params.contains_key(field) {
13227                dlg.finished(false);
13228                return Err(common::Error::FieldClash(field));
13229            }
13230        }
13231
13232        let mut params = Params::with_capacity(7 + self._additional_params.len());
13233        params.push("accountId", self._account_id);
13234        params.push("webPropertyId", self._web_property_id);
13235        params.push("customMetricId", self._custom_metric_id);
13236        if let Some(value) = self._ignore_custom_data_source_links.as_ref() {
13237            params.push("ignoreCustomDataSourceLinks", value.to_string());
13238        }
13239
13240        params.extend(self._additional_params.iter());
13241
13242        params.push("alt", "json");
13243        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics/{customMetricId}";
13244        if self._scopes.is_empty() {
13245            self._scopes.insert(Scope::Edit.as_ref().to_string());
13246        }
13247
13248        #[allow(clippy::single_element_loop)]
13249        for &(find_this, param_name) in [
13250            ("{accountId}", "accountId"),
13251            ("{webPropertyId}", "webPropertyId"),
13252            ("{customMetricId}", "customMetricId"),
13253        ]
13254        .iter()
13255        {
13256            url = params.uri_replacement(url, param_name, find_this, false);
13257        }
13258        {
13259            let to_remove = ["customMetricId", "webPropertyId", "accountId"];
13260            params.remove_params(&to_remove);
13261        }
13262
13263        let url = params.parse_with_url(&url);
13264
13265        let mut json_mime_type = mime::APPLICATION_JSON;
13266        let mut request_value_reader = {
13267            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13268            common::remove_json_null_values(&mut value);
13269            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13270            serde_json::to_writer(&mut dst, &value).unwrap();
13271            dst
13272        };
13273        let request_size = request_value_reader
13274            .seek(std::io::SeekFrom::End(0))
13275            .unwrap();
13276        request_value_reader
13277            .seek(std::io::SeekFrom::Start(0))
13278            .unwrap();
13279
13280        loop {
13281            let token = match self
13282                .hub
13283                .auth
13284                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13285                .await
13286            {
13287                Ok(token) => token,
13288                Err(e) => match dlg.token(e) {
13289                    Ok(token) => token,
13290                    Err(e) => {
13291                        dlg.finished(false);
13292                        return Err(common::Error::MissingToken(e));
13293                    }
13294                },
13295            };
13296            request_value_reader
13297                .seek(std::io::SeekFrom::Start(0))
13298                .unwrap();
13299            let mut req_result = {
13300                let client = &self.hub.client;
13301                dlg.pre_request();
13302                let mut req_builder = hyper::Request::builder()
13303                    .method(hyper::Method::PUT)
13304                    .uri(url.as_str())
13305                    .header(USER_AGENT, self.hub._user_agent.clone());
13306
13307                if let Some(token) = token.as_ref() {
13308                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13309                }
13310
13311                let request = req_builder
13312                    .header(CONTENT_TYPE, json_mime_type.to_string())
13313                    .header(CONTENT_LENGTH, request_size as u64)
13314                    .body(common::to_body(
13315                        request_value_reader.get_ref().clone().into(),
13316                    ));
13317
13318                client.request(request.unwrap()).await
13319            };
13320
13321            match req_result {
13322                Err(err) => {
13323                    if let common::Retry::After(d) = dlg.http_error(&err) {
13324                        sleep(d).await;
13325                        continue;
13326                    }
13327                    dlg.finished(false);
13328                    return Err(common::Error::HttpError(err));
13329                }
13330                Ok(res) => {
13331                    let (mut parts, body) = res.into_parts();
13332                    let mut body = common::Body::new(body);
13333                    if !parts.status.is_success() {
13334                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13335                        let error = serde_json::from_str(&common::to_string(&bytes));
13336                        let response = common::to_response(parts, bytes.into());
13337
13338                        if let common::Retry::After(d) =
13339                            dlg.http_failure(&response, error.as_ref().ok())
13340                        {
13341                            sleep(d).await;
13342                            continue;
13343                        }
13344
13345                        dlg.finished(false);
13346
13347                        return Err(match error {
13348                            Ok(value) => common::Error::BadRequest(value),
13349                            _ => common::Error::Failure(response),
13350                        });
13351                    }
13352                    let response = {
13353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13354                        let encoded = common::to_string(&bytes);
13355                        match serde_json::from_str(&encoded) {
13356                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13357                            Err(error) => {
13358                                dlg.response_json_decode_error(&encoded, &error);
13359                                return Err(common::Error::JsonDecodeError(
13360                                    encoded.to_string(),
13361                                    error,
13362                                ));
13363                            }
13364                        }
13365                    };
13366
13367                    dlg.finished(true);
13368                    return Ok(response);
13369                }
13370            }
13371        }
13372    }
13373
13374    ///
13375    /// Sets the *request* property to the given value.
13376    ///
13377    /// Even though the property as already been set when instantiating this call,
13378    /// we provide this method for API completeness.
13379    pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricUpdateCall<'a, C> {
13380        self._request = new_value;
13381        self
13382    }
13383    /// Account ID for the custom metric to update.
13384    ///
13385    /// Sets the *account id* path property to the given value.
13386    ///
13387    /// Even though the property as already been set when instantiating this call,
13388    /// we provide this method for API completeness.
13389    pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C> {
13390        self._account_id = new_value.to_string();
13391        self
13392    }
13393    /// Web property ID for the custom metric to update.
13394    ///
13395    /// Sets the *web property id* path property to the given value.
13396    ///
13397    /// Even though the property as already been set when instantiating this call,
13398    /// we provide this method for API completeness.
13399    pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C> {
13400        self._web_property_id = new_value.to_string();
13401        self
13402    }
13403    /// Custom metric ID for the custom metric to update.
13404    ///
13405    /// Sets the *custom metric id* path property to the given value.
13406    ///
13407    /// Even though the property as already been set when instantiating this call,
13408    /// we provide this method for API completeness.
13409    pub fn custom_metric_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C> {
13410        self._custom_metric_id = new_value.to_string();
13411        self
13412    }
13413    /// Force the update and ignore any warnings related to the custom metric being linked to a custom data source / data set.
13414    ///
13415    /// Sets the *ignore custom data source links* query property to the given value.
13416    pub fn ignore_custom_data_source_links(
13417        mut self,
13418        new_value: bool,
13419    ) -> ManagementCustomMetricUpdateCall<'a, C> {
13420        self._ignore_custom_data_source_links = Some(new_value);
13421        self
13422    }
13423    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13424    /// while executing the actual API request.
13425    ///
13426    /// ````text
13427    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13428    /// ````
13429    ///
13430    /// Sets the *delegate* property to the given value.
13431    pub fn delegate(
13432        mut self,
13433        new_value: &'a mut dyn common::Delegate,
13434    ) -> ManagementCustomMetricUpdateCall<'a, C> {
13435        self._delegate = Some(new_value);
13436        self
13437    }
13438
13439    /// Set any additional parameter of the query string used in the request.
13440    /// It should be used to set parameters which are not yet available through their own
13441    /// setters.
13442    ///
13443    /// Please note that this method must not be used to set any of the known parameters
13444    /// which have their own setter method. If done anyway, the request will fail.
13445    ///
13446    /// # Additional Parameters
13447    ///
13448    /// * *alt* (query-string) - Data format for the response.
13449    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13450    /// * *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.
13451    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13452    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13453    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13454    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13455    pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricUpdateCall<'a, C>
13456    where
13457        T: AsRef<str>,
13458    {
13459        self._additional_params
13460            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13461        self
13462    }
13463
13464    /// Identifies the authorization scope for the method you are building.
13465    ///
13466    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13467    /// [`Scope::Edit`].
13468    ///
13469    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13470    /// tokens for more than one scope.
13471    ///
13472    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13473    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13474    /// sufficient, a read-write scope will do as well.
13475    pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricUpdateCall<'a, C>
13476    where
13477        St: AsRef<str>,
13478    {
13479        self._scopes.insert(String::from(scope.as_ref()));
13480        self
13481    }
13482    /// Identifies the authorization scope(s) for the method you are building.
13483    ///
13484    /// See [`Self::add_scope()`] for details.
13485    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricUpdateCall<'a, C>
13486    where
13487        I: IntoIterator<Item = St>,
13488        St: AsRef<str>,
13489    {
13490        self._scopes
13491            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13492        self
13493    }
13494
13495    /// Removes all scopes, and no default scope will be used either.
13496    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13497    /// for details).
13498    pub fn clear_scopes(mut self) -> ManagementCustomMetricUpdateCall<'a, C> {
13499        self._scopes.clear();
13500        self
13501    }
13502}
13503
13504/// Delete an experiment.
13505///
13506/// A builder for the *experiments.delete* method supported by a *management* resource.
13507/// It is not used directly, but through a [`ManagementMethods`] instance.
13508///
13509/// # Example
13510///
13511/// Instantiate a resource method builder
13512///
13513/// ```test_harness,no_run
13514/// # extern crate hyper;
13515/// # extern crate hyper_rustls;
13516/// # extern crate google_analytics3 as analytics3;
13517/// # async fn dox() {
13518/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13519///
13520/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13521/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13522/// #     .with_native_roots()
13523/// #     .unwrap()
13524/// #     .https_only()
13525/// #     .enable_http2()
13526/// #     .build();
13527///
13528/// # let executor = hyper_util::rt::TokioExecutor::new();
13529/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13530/// #     secret,
13531/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13532/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13533/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13534/// #     ),
13535/// # ).build().await.unwrap();
13536///
13537/// # let client = hyper_util::client::legacy::Client::builder(
13538/// #     hyper_util::rt::TokioExecutor::new()
13539/// # )
13540/// # .build(
13541/// #     hyper_rustls::HttpsConnectorBuilder::new()
13542/// #         .with_native_roots()
13543/// #         .unwrap()
13544/// #         .https_or_http()
13545/// #         .enable_http2()
13546/// #         .build()
13547/// # );
13548/// # let mut hub = Analytics::new(client, auth);
13549/// // You can configure optional parameters by calling the respective setters at will, and
13550/// // execute the final call using `doit()`.
13551/// // Values shown here are possibly random and not representative !
13552/// let result = hub.management().experiments_delete("accountId", "webPropertyId", "profileId", "experimentId")
13553///              .doit().await;
13554/// # }
13555/// ```
13556pub struct ManagementExperimentDeleteCall<'a, C>
13557where
13558    C: 'a,
13559{
13560    hub: &'a Analytics<C>,
13561    _account_id: String,
13562    _web_property_id: String,
13563    _profile_id: String,
13564    _experiment_id: String,
13565    _delegate: Option<&'a mut dyn common::Delegate>,
13566    _additional_params: HashMap<String, String>,
13567    _scopes: BTreeSet<String>,
13568}
13569
13570impl<'a, C> common::CallBuilder for ManagementExperimentDeleteCall<'a, C> {}
13571
13572impl<'a, C> ManagementExperimentDeleteCall<'a, C>
13573where
13574    C: common::Connector,
13575{
13576    /// Perform the operation you have build so far.
13577    pub async fn doit(mut self) -> common::Result<common::Response> {
13578        use std::borrow::Cow;
13579        use std::io::{Read, Seek};
13580
13581        use common::{url::Params, ToParts};
13582        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13583
13584        let mut dd = common::DefaultDelegate;
13585        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13586        dlg.begin(common::MethodInfo {
13587            id: "analytics.management.experiments.delete",
13588            http_method: hyper::Method::DELETE,
13589        });
13590
13591        for &field in ["accountId", "webPropertyId", "profileId", "experimentId"].iter() {
13592            if self._additional_params.contains_key(field) {
13593                dlg.finished(false);
13594                return Err(common::Error::FieldClash(field));
13595            }
13596        }
13597
13598        let mut params = Params::with_capacity(5 + self._additional_params.len());
13599        params.push("accountId", self._account_id);
13600        params.push("webPropertyId", self._web_property_id);
13601        params.push("profileId", self._profile_id);
13602        params.push("experimentId", self._experiment_id);
13603
13604        params.extend(self._additional_params.iter());
13605
13606        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}";
13607        if self._scopes.is_empty() {
13608            self._scopes.insert(Scope::Full.as_ref().to_string());
13609        }
13610
13611        #[allow(clippy::single_element_loop)]
13612        for &(find_this, param_name) in [
13613            ("{accountId}", "accountId"),
13614            ("{webPropertyId}", "webPropertyId"),
13615            ("{profileId}", "profileId"),
13616            ("{experimentId}", "experimentId"),
13617        ]
13618        .iter()
13619        {
13620            url = params.uri_replacement(url, param_name, find_this, false);
13621        }
13622        {
13623            let to_remove = ["experimentId", "profileId", "webPropertyId", "accountId"];
13624            params.remove_params(&to_remove);
13625        }
13626
13627        let url = params.parse_with_url(&url);
13628
13629        loop {
13630            let token = match self
13631                .hub
13632                .auth
13633                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13634                .await
13635            {
13636                Ok(token) => token,
13637                Err(e) => match dlg.token(e) {
13638                    Ok(token) => token,
13639                    Err(e) => {
13640                        dlg.finished(false);
13641                        return Err(common::Error::MissingToken(e));
13642                    }
13643                },
13644            };
13645            let mut req_result = {
13646                let client = &self.hub.client;
13647                dlg.pre_request();
13648                let mut req_builder = hyper::Request::builder()
13649                    .method(hyper::Method::DELETE)
13650                    .uri(url.as_str())
13651                    .header(USER_AGENT, self.hub._user_agent.clone());
13652
13653                if let Some(token) = token.as_ref() {
13654                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13655                }
13656
13657                let request = req_builder
13658                    .header(CONTENT_LENGTH, 0_u64)
13659                    .body(common::to_body::<String>(None));
13660
13661                client.request(request.unwrap()).await
13662            };
13663
13664            match req_result {
13665                Err(err) => {
13666                    if let common::Retry::After(d) = dlg.http_error(&err) {
13667                        sleep(d).await;
13668                        continue;
13669                    }
13670                    dlg.finished(false);
13671                    return Err(common::Error::HttpError(err));
13672                }
13673                Ok(res) => {
13674                    let (mut parts, body) = res.into_parts();
13675                    let mut body = common::Body::new(body);
13676                    if !parts.status.is_success() {
13677                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13678                        let error = serde_json::from_str(&common::to_string(&bytes));
13679                        let response = common::to_response(parts, bytes.into());
13680
13681                        if let common::Retry::After(d) =
13682                            dlg.http_failure(&response, error.as_ref().ok())
13683                        {
13684                            sleep(d).await;
13685                            continue;
13686                        }
13687
13688                        dlg.finished(false);
13689
13690                        return Err(match error {
13691                            Ok(value) => common::Error::BadRequest(value),
13692                            _ => common::Error::Failure(response),
13693                        });
13694                    }
13695                    let response = common::Response::from_parts(parts, body);
13696
13697                    dlg.finished(true);
13698                    return Ok(response);
13699                }
13700            }
13701        }
13702    }
13703
13704    /// Account ID to which the experiment belongs
13705    ///
13706    /// Sets the *account id* path property to the given value.
13707    ///
13708    /// Even though the property as already been set when instantiating this call,
13709    /// we provide this method for API completeness.
13710    pub fn account_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C> {
13711        self._account_id = new_value.to_string();
13712        self
13713    }
13714    /// Web property ID to which the experiment belongs
13715    ///
13716    /// Sets the *web property id* path property to the given value.
13717    ///
13718    /// Even though the property as already been set when instantiating this call,
13719    /// we provide this method for API completeness.
13720    pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C> {
13721        self._web_property_id = new_value.to_string();
13722        self
13723    }
13724    /// View (Profile) ID to which the experiment belongs
13725    ///
13726    /// Sets the *profile id* path property to the given value.
13727    ///
13728    /// Even though the property as already been set when instantiating this call,
13729    /// we provide this method for API completeness.
13730    pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C> {
13731        self._profile_id = new_value.to_string();
13732        self
13733    }
13734    /// ID of the experiment to delete
13735    ///
13736    /// Sets the *experiment id* path property to the given value.
13737    ///
13738    /// Even though the property as already been set when instantiating this call,
13739    /// we provide this method for API completeness.
13740    pub fn experiment_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C> {
13741        self._experiment_id = new_value.to_string();
13742        self
13743    }
13744    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13745    /// while executing the actual API request.
13746    ///
13747    /// ````text
13748    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13749    /// ````
13750    ///
13751    /// Sets the *delegate* property to the given value.
13752    pub fn delegate(
13753        mut self,
13754        new_value: &'a mut dyn common::Delegate,
13755    ) -> ManagementExperimentDeleteCall<'a, C> {
13756        self._delegate = Some(new_value);
13757        self
13758    }
13759
13760    /// Set any additional parameter of the query string used in the request.
13761    /// It should be used to set parameters which are not yet available through their own
13762    /// setters.
13763    ///
13764    /// Please note that this method must not be used to set any of the known parameters
13765    /// which have their own setter method. If done anyway, the request will fail.
13766    ///
13767    /// # Additional Parameters
13768    ///
13769    /// * *alt* (query-string) - Data format for the response.
13770    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13771    /// * *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.
13772    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13773    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13774    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13775    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13776    pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentDeleteCall<'a, C>
13777    where
13778        T: AsRef<str>,
13779    {
13780        self._additional_params
13781            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13782        self
13783    }
13784
13785    /// Identifies the authorization scope for the method you are building.
13786    ///
13787    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13788    /// [`Scope::Full`].
13789    ///
13790    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13791    /// tokens for more than one scope.
13792    ///
13793    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13794    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13795    /// sufficient, a read-write scope will do as well.
13796    pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentDeleteCall<'a, C>
13797    where
13798        St: AsRef<str>,
13799    {
13800        self._scopes.insert(String::from(scope.as_ref()));
13801        self
13802    }
13803    /// Identifies the authorization scope(s) for the method you are building.
13804    ///
13805    /// See [`Self::add_scope()`] for details.
13806    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentDeleteCall<'a, C>
13807    where
13808        I: IntoIterator<Item = St>,
13809        St: AsRef<str>,
13810    {
13811        self._scopes
13812            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13813        self
13814    }
13815
13816    /// Removes all scopes, and no default scope will be used either.
13817    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13818    /// for details).
13819    pub fn clear_scopes(mut self) -> ManagementExperimentDeleteCall<'a, C> {
13820        self._scopes.clear();
13821        self
13822    }
13823}
13824
13825/// Returns an experiment to which the user has access.
13826///
13827/// A builder for the *experiments.get* method supported by a *management* resource.
13828/// It is not used directly, but through a [`ManagementMethods`] instance.
13829///
13830/// # Example
13831///
13832/// Instantiate a resource method builder
13833///
13834/// ```test_harness,no_run
13835/// # extern crate hyper;
13836/// # extern crate hyper_rustls;
13837/// # extern crate google_analytics3 as analytics3;
13838/// # async fn dox() {
13839/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13840///
13841/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13842/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13843/// #     .with_native_roots()
13844/// #     .unwrap()
13845/// #     .https_only()
13846/// #     .enable_http2()
13847/// #     .build();
13848///
13849/// # let executor = hyper_util::rt::TokioExecutor::new();
13850/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13851/// #     secret,
13852/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13853/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13854/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13855/// #     ),
13856/// # ).build().await.unwrap();
13857///
13858/// # let client = hyper_util::client::legacy::Client::builder(
13859/// #     hyper_util::rt::TokioExecutor::new()
13860/// # )
13861/// # .build(
13862/// #     hyper_rustls::HttpsConnectorBuilder::new()
13863/// #         .with_native_roots()
13864/// #         .unwrap()
13865/// #         .https_or_http()
13866/// #         .enable_http2()
13867/// #         .build()
13868/// # );
13869/// # let mut hub = Analytics::new(client, auth);
13870/// // You can configure optional parameters by calling the respective setters at will, and
13871/// // execute the final call using `doit()`.
13872/// // Values shown here are possibly random and not representative !
13873/// let result = hub.management().experiments_get("accountId", "webPropertyId", "profileId", "experimentId")
13874///              .doit().await;
13875/// # }
13876/// ```
13877pub struct ManagementExperimentGetCall<'a, C>
13878where
13879    C: 'a,
13880{
13881    hub: &'a Analytics<C>,
13882    _account_id: String,
13883    _web_property_id: String,
13884    _profile_id: String,
13885    _experiment_id: String,
13886    _delegate: Option<&'a mut dyn common::Delegate>,
13887    _additional_params: HashMap<String, String>,
13888    _scopes: BTreeSet<String>,
13889}
13890
13891impl<'a, C> common::CallBuilder for ManagementExperimentGetCall<'a, C> {}
13892
13893impl<'a, C> ManagementExperimentGetCall<'a, C>
13894where
13895    C: common::Connector,
13896{
13897    /// Perform the operation you have build so far.
13898    pub async fn doit(mut self) -> common::Result<(common::Response, Experiment)> {
13899        use std::borrow::Cow;
13900        use std::io::{Read, Seek};
13901
13902        use common::{url::Params, ToParts};
13903        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13904
13905        let mut dd = common::DefaultDelegate;
13906        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13907        dlg.begin(common::MethodInfo {
13908            id: "analytics.management.experiments.get",
13909            http_method: hyper::Method::GET,
13910        });
13911
13912        for &field in [
13913            "alt",
13914            "accountId",
13915            "webPropertyId",
13916            "profileId",
13917            "experimentId",
13918        ]
13919        .iter()
13920        {
13921            if self._additional_params.contains_key(field) {
13922                dlg.finished(false);
13923                return Err(common::Error::FieldClash(field));
13924            }
13925        }
13926
13927        let mut params = Params::with_capacity(6 + self._additional_params.len());
13928        params.push("accountId", self._account_id);
13929        params.push("webPropertyId", self._web_property_id);
13930        params.push("profileId", self._profile_id);
13931        params.push("experimentId", self._experiment_id);
13932
13933        params.extend(self._additional_params.iter());
13934
13935        params.push("alt", "json");
13936        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}";
13937        if self._scopes.is_empty() {
13938            self._scopes.insert(Scope::Readonly.as_ref().to_string());
13939        }
13940
13941        #[allow(clippy::single_element_loop)]
13942        for &(find_this, param_name) in [
13943            ("{accountId}", "accountId"),
13944            ("{webPropertyId}", "webPropertyId"),
13945            ("{profileId}", "profileId"),
13946            ("{experimentId}", "experimentId"),
13947        ]
13948        .iter()
13949        {
13950            url = params.uri_replacement(url, param_name, find_this, false);
13951        }
13952        {
13953            let to_remove = ["experimentId", "profileId", "webPropertyId", "accountId"];
13954            params.remove_params(&to_remove);
13955        }
13956
13957        let url = params.parse_with_url(&url);
13958
13959        loop {
13960            let token = match self
13961                .hub
13962                .auth
13963                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13964                .await
13965            {
13966                Ok(token) => token,
13967                Err(e) => match dlg.token(e) {
13968                    Ok(token) => token,
13969                    Err(e) => {
13970                        dlg.finished(false);
13971                        return Err(common::Error::MissingToken(e));
13972                    }
13973                },
13974            };
13975            let mut req_result = {
13976                let client = &self.hub.client;
13977                dlg.pre_request();
13978                let mut req_builder = hyper::Request::builder()
13979                    .method(hyper::Method::GET)
13980                    .uri(url.as_str())
13981                    .header(USER_AGENT, self.hub._user_agent.clone());
13982
13983                if let Some(token) = token.as_ref() {
13984                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13985                }
13986
13987                let request = req_builder
13988                    .header(CONTENT_LENGTH, 0_u64)
13989                    .body(common::to_body::<String>(None));
13990
13991                client.request(request.unwrap()).await
13992            };
13993
13994            match req_result {
13995                Err(err) => {
13996                    if let common::Retry::After(d) = dlg.http_error(&err) {
13997                        sleep(d).await;
13998                        continue;
13999                    }
14000                    dlg.finished(false);
14001                    return Err(common::Error::HttpError(err));
14002                }
14003                Ok(res) => {
14004                    let (mut parts, body) = res.into_parts();
14005                    let mut body = common::Body::new(body);
14006                    if !parts.status.is_success() {
14007                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14008                        let error = serde_json::from_str(&common::to_string(&bytes));
14009                        let response = common::to_response(parts, bytes.into());
14010
14011                        if let common::Retry::After(d) =
14012                            dlg.http_failure(&response, error.as_ref().ok())
14013                        {
14014                            sleep(d).await;
14015                            continue;
14016                        }
14017
14018                        dlg.finished(false);
14019
14020                        return Err(match error {
14021                            Ok(value) => common::Error::BadRequest(value),
14022                            _ => common::Error::Failure(response),
14023                        });
14024                    }
14025                    let response = {
14026                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14027                        let encoded = common::to_string(&bytes);
14028                        match serde_json::from_str(&encoded) {
14029                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14030                            Err(error) => {
14031                                dlg.response_json_decode_error(&encoded, &error);
14032                                return Err(common::Error::JsonDecodeError(
14033                                    encoded.to_string(),
14034                                    error,
14035                                ));
14036                            }
14037                        }
14038                    };
14039
14040                    dlg.finished(true);
14041                    return Ok(response);
14042                }
14043            }
14044        }
14045    }
14046
14047    /// Account ID to retrieve the experiment for.
14048    ///
14049    /// Sets the *account id* path property to the given value.
14050    ///
14051    /// Even though the property as already been set when instantiating this call,
14052    /// we provide this method for API completeness.
14053    pub fn account_id(mut self, new_value: &str) -> ManagementExperimentGetCall<'a, C> {
14054        self._account_id = new_value.to_string();
14055        self
14056    }
14057    /// Web property ID to retrieve the experiment for.
14058    ///
14059    /// Sets the *web property id* path property to the given value.
14060    ///
14061    /// Even though the property as already been set when instantiating this call,
14062    /// we provide this method for API completeness.
14063    pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentGetCall<'a, C> {
14064        self._web_property_id = new_value.to_string();
14065        self
14066    }
14067    /// View (Profile) ID to retrieve the experiment for.
14068    ///
14069    /// Sets the *profile id* path property to the given value.
14070    ///
14071    /// Even though the property as already been set when instantiating this call,
14072    /// we provide this method for API completeness.
14073    pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentGetCall<'a, C> {
14074        self._profile_id = new_value.to_string();
14075        self
14076    }
14077    /// Experiment ID to retrieve the experiment for.
14078    ///
14079    /// Sets the *experiment id* path property to the given value.
14080    ///
14081    /// Even though the property as already been set when instantiating this call,
14082    /// we provide this method for API completeness.
14083    pub fn experiment_id(mut self, new_value: &str) -> ManagementExperimentGetCall<'a, C> {
14084        self._experiment_id = new_value.to_string();
14085        self
14086    }
14087    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14088    /// while executing the actual API request.
14089    ///
14090    /// ````text
14091    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14092    /// ````
14093    ///
14094    /// Sets the *delegate* property to the given value.
14095    pub fn delegate(
14096        mut self,
14097        new_value: &'a mut dyn common::Delegate,
14098    ) -> ManagementExperimentGetCall<'a, C> {
14099        self._delegate = Some(new_value);
14100        self
14101    }
14102
14103    /// Set any additional parameter of the query string used in the request.
14104    /// It should be used to set parameters which are not yet available through their own
14105    /// setters.
14106    ///
14107    /// Please note that this method must not be used to set any of the known parameters
14108    /// which have their own setter method. If done anyway, the request will fail.
14109    ///
14110    /// # Additional Parameters
14111    ///
14112    /// * *alt* (query-string) - Data format for the response.
14113    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14114    /// * *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.
14115    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14116    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14117    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14118    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14119    pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentGetCall<'a, C>
14120    where
14121        T: AsRef<str>,
14122    {
14123        self._additional_params
14124            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14125        self
14126    }
14127
14128    /// Identifies the authorization scope for the method you are building.
14129    ///
14130    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14131    /// [`Scope::Readonly`].
14132    ///
14133    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14134    /// tokens for more than one scope.
14135    ///
14136    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14137    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14138    /// sufficient, a read-write scope will do as well.
14139    pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentGetCall<'a, C>
14140    where
14141        St: AsRef<str>,
14142    {
14143        self._scopes.insert(String::from(scope.as_ref()));
14144        self
14145    }
14146    /// Identifies the authorization scope(s) for the method you are building.
14147    ///
14148    /// See [`Self::add_scope()`] for details.
14149    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentGetCall<'a, C>
14150    where
14151        I: IntoIterator<Item = St>,
14152        St: AsRef<str>,
14153    {
14154        self._scopes
14155            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14156        self
14157    }
14158
14159    /// Removes all scopes, and no default scope will be used either.
14160    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14161    /// for details).
14162    pub fn clear_scopes(mut self) -> ManagementExperimentGetCall<'a, C> {
14163        self._scopes.clear();
14164        self
14165    }
14166}
14167
14168/// Create a new experiment.
14169///
14170/// A builder for the *experiments.insert* method supported by a *management* resource.
14171/// It is not used directly, but through a [`ManagementMethods`] instance.
14172///
14173/// # Example
14174///
14175/// Instantiate a resource method builder
14176///
14177/// ```test_harness,no_run
14178/// # extern crate hyper;
14179/// # extern crate hyper_rustls;
14180/// # extern crate google_analytics3 as analytics3;
14181/// use analytics3::api::Experiment;
14182/// # async fn dox() {
14183/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14184///
14185/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14186/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14187/// #     .with_native_roots()
14188/// #     .unwrap()
14189/// #     .https_only()
14190/// #     .enable_http2()
14191/// #     .build();
14192///
14193/// # let executor = hyper_util::rt::TokioExecutor::new();
14194/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14195/// #     secret,
14196/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14197/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14198/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14199/// #     ),
14200/// # ).build().await.unwrap();
14201///
14202/// # let client = hyper_util::client::legacy::Client::builder(
14203/// #     hyper_util::rt::TokioExecutor::new()
14204/// # )
14205/// # .build(
14206/// #     hyper_rustls::HttpsConnectorBuilder::new()
14207/// #         .with_native_roots()
14208/// #         .unwrap()
14209/// #         .https_or_http()
14210/// #         .enable_http2()
14211/// #         .build()
14212/// # );
14213/// # let mut hub = Analytics::new(client, auth);
14214/// // As the method needs a request, you would usually fill it with the desired information
14215/// // into the respective structure. Some of the parts shown here might not be applicable !
14216/// // Values shown here are possibly random and not representative !
14217/// let mut req = Experiment::default();
14218///
14219/// // You can configure optional parameters by calling the respective setters at will, and
14220/// // execute the final call using `doit()`.
14221/// // Values shown here are possibly random and not representative !
14222/// let result = hub.management().experiments_insert(req, "accountId", "webPropertyId", "profileId")
14223///              .doit().await;
14224/// # }
14225/// ```
14226pub struct ManagementExperimentInsertCall<'a, C>
14227where
14228    C: 'a,
14229{
14230    hub: &'a Analytics<C>,
14231    _request: Experiment,
14232    _account_id: String,
14233    _web_property_id: String,
14234    _profile_id: String,
14235    _delegate: Option<&'a mut dyn common::Delegate>,
14236    _additional_params: HashMap<String, String>,
14237    _scopes: BTreeSet<String>,
14238}
14239
14240impl<'a, C> common::CallBuilder for ManagementExperimentInsertCall<'a, C> {}
14241
14242impl<'a, C> ManagementExperimentInsertCall<'a, C>
14243where
14244    C: common::Connector,
14245{
14246    /// Perform the operation you have build so far.
14247    pub async fn doit(mut self) -> common::Result<(common::Response, Experiment)> {
14248        use std::borrow::Cow;
14249        use std::io::{Read, Seek};
14250
14251        use common::{url::Params, ToParts};
14252        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14253
14254        let mut dd = common::DefaultDelegate;
14255        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14256        dlg.begin(common::MethodInfo {
14257            id: "analytics.management.experiments.insert",
14258            http_method: hyper::Method::POST,
14259        });
14260
14261        for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
14262            if self._additional_params.contains_key(field) {
14263                dlg.finished(false);
14264                return Err(common::Error::FieldClash(field));
14265            }
14266        }
14267
14268        let mut params = Params::with_capacity(6 + self._additional_params.len());
14269        params.push("accountId", self._account_id);
14270        params.push("webPropertyId", self._web_property_id);
14271        params.push("profileId", self._profile_id);
14272
14273        params.extend(self._additional_params.iter());
14274
14275        params.push("alt", "json");
14276        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments";
14277        if self._scopes.is_empty() {
14278            self._scopes.insert(Scope::Full.as_ref().to_string());
14279        }
14280
14281        #[allow(clippy::single_element_loop)]
14282        for &(find_this, param_name) in [
14283            ("{accountId}", "accountId"),
14284            ("{webPropertyId}", "webPropertyId"),
14285            ("{profileId}", "profileId"),
14286        ]
14287        .iter()
14288        {
14289            url = params.uri_replacement(url, param_name, find_this, false);
14290        }
14291        {
14292            let to_remove = ["profileId", "webPropertyId", "accountId"];
14293            params.remove_params(&to_remove);
14294        }
14295
14296        let url = params.parse_with_url(&url);
14297
14298        let mut json_mime_type = mime::APPLICATION_JSON;
14299        let mut request_value_reader = {
14300            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14301            common::remove_json_null_values(&mut value);
14302            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14303            serde_json::to_writer(&mut dst, &value).unwrap();
14304            dst
14305        };
14306        let request_size = request_value_reader
14307            .seek(std::io::SeekFrom::End(0))
14308            .unwrap();
14309        request_value_reader
14310            .seek(std::io::SeekFrom::Start(0))
14311            .unwrap();
14312
14313        loop {
14314            let token = match self
14315                .hub
14316                .auth
14317                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14318                .await
14319            {
14320                Ok(token) => token,
14321                Err(e) => match dlg.token(e) {
14322                    Ok(token) => token,
14323                    Err(e) => {
14324                        dlg.finished(false);
14325                        return Err(common::Error::MissingToken(e));
14326                    }
14327                },
14328            };
14329            request_value_reader
14330                .seek(std::io::SeekFrom::Start(0))
14331                .unwrap();
14332            let mut req_result = {
14333                let client = &self.hub.client;
14334                dlg.pre_request();
14335                let mut req_builder = hyper::Request::builder()
14336                    .method(hyper::Method::POST)
14337                    .uri(url.as_str())
14338                    .header(USER_AGENT, self.hub._user_agent.clone());
14339
14340                if let Some(token) = token.as_ref() {
14341                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14342                }
14343
14344                let request = req_builder
14345                    .header(CONTENT_TYPE, json_mime_type.to_string())
14346                    .header(CONTENT_LENGTH, request_size as u64)
14347                    .body(common::to_body(
14348                        request_value_reader.get_ref().clone().into(),
14349                    ));
14350
14351                client.request(request.unwrap()).await
14352            };
14353
14354            match req_result {
14355                Err(err) => {
14356                    if let common::Retry::After(d) = dlg.http_error(&err) {
14357                        sleep(d).await;
14358                        continue;
14359                    }
14360                    dlg.finished(false);
14361                    return Err(common::Error::HttpError(err));
14362                }
14363                Ok(res) => {
14364                    let (mut parts, body) = res.into_parts();
14365                    let mut body = common::Body::new(body);
14366                    if !parts.status.is_success() {
14367                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14368                        let error = serde_json::from_str(&common::to_string(&bytes));
14369                        let response = common::to_response(parts, bytes.into());
14370
14371                        if let common::Retry::After(d) =
14372                            dlg.http_failure(&response, error.as_ref().ok())
14373                        {
14374                            sleep(d).await;
14375                            continue;
14376                        }
14377
14378                        dlg.finished(false);
14379
14380                        return Err(match error {
14381                            Ok(value) => common::Error::BadRequest(value),
14382                            _ => common::Error::Failure(response),
14383                        });
14384                    }
14385                    let response = {
14386                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14387                        let encoded = common::to_string(&bytes);
14388                        match serde_json::from_str(&encoded) {
14389                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14390                            Err(error) => {
14391                                dlg.response_json_decode_error(&encoded, &error);
14392                                return Err(common::Error::JsonDecodeError(
14393                                    encoded.to_string(),
14394                                    error,
14395                                ));
14396                            }
14397                        }
14398                    };
14399
14400                    dlg.finished(true);
14401                    return Ok(response);
14402                }
14403            }
14404        }
14405    }
14406
14407    ///
14408    /// Sets the *request* property to the given value.
14409    ///
14410    /// Even though the property as already been set when instantiating this call,
14411    /// we provide this method for API completeness.
14412    pub fn request(mut self, new_value: Experiment) -> ManagementExperimentInsertCall<'a, C> {
14413        self._request = new_value;
14414        self
14415    }
14416    /// Account ID to create the experiment for.
14417    ///
14418    /// Sets the *account id* path property to the given value.
14419    ///
14420    /// Even though the property as already been set when instantiating this call,
14421    /// we provide this method for API completeness.
14422    pub fn account_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C> {
14423        self._account_id = new_value.to_string();
14424        self
14425    }
14426    /// Web property ID to create the experiment for.
14427    ///
14428    /// Sets the *web property id* path property to the given value.
14429    ///
14430    /// Even though the property as already been set when instantiating this call,
14431    /// we provide this method for API completeness.
14432    pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C> {
14433        self._web_property_id = new_value.to_string();
14434        self
14435    }
14436    /// View (Profile) ID to create the experiment for.
14437    ///
14438    /// Sets the *profile id* path property to the given value.
14439    ///
14440    /// Even though the property as already been set when instantiating this call,
14441    /// we provide this method for API completeness.
14442    pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C> {
14443        self._profile_id = new_value.to_string();
14444        self
14445    }
14446    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14447    /// while executing the actual API request.
14448    ///
14449    /// ````text
14450    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14451    /// ````
14452    ///
14453    /// Sets the *delegate* property to the given value.
14454    pub fn delegate(
14455        mut self,
14456        new_value: &'a mut dyn common::Delegate,
14457    ) -> ManagementExperimentInsertCall<'a, C> {
14458        self._delegate = Some(new_value);
14459        self
14460    }
14461
14462    /// Set any additional parameter of the query string used in the request.
14463    /// It should be used to set parameters which are not yet available through their own
14464    /// setters.
14465    ///
14466    /// Please note that this method must not be used to set any of the known parameters
14467    /// which have their own setter method. If done anyway, the request will fail.
14468    ///
14469    /// # Additional Parameters
14470    ///
14471    /// * *alt* (query-string) - Data format for the response.
14472    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14473    /// * *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.
14474    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14475    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14476    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14477    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14478    pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentInsertCall<'a, C>
14479    where
14480        T: AsRef<str>,
14481    {
14482        self._additional_params
14483            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14484        self
14485    }
14486
14487    /// Identifies the authorization scope for the method you are building.
14488    ///
14489    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14490    /// [`Scope::Full`].
14491    ///
14492    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14493    /// tokens for more than one scope.
14494    ///
14495    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14496    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14497    /// sufficient, a read-write scope will do as well.
14498    pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentInsertCall<'a, C>
14499    where
14500        St: AsRef<str>,
14501    {
14502        self._scopes.insert(String::from(scope.as_ref()));
14503        self
14504    }
14505    /// Identifies the authorization scope(s) for the method you are building.
14506    ///
14507    /// See [`Self::add_scope()`] for details.
14508    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentInsertCall<'a, C>
14509    where
14510        I: IntoIterator<Item = St>,
14511        St: AsRef<str>,
14512    {
14513        self._scopes
14514            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14515        self
14516    }
14517
14518    /// Removes all scopes, and no default scope will be used either.
14519    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14520    /// for details).
14521    pub fn clear_scopes(mut self) -> ManagementExperimentInsertCall<'a, C> {
14522        self._scopes.clear();
14523        self
14524    }
14525}
14526
14527/// Lists experiments to which the user has access.
14528///
14529/// A builder for the *experiments.list* method supported by a *management* resource.
14530/// It is not used directly, but through a [`ManagementMethods`] instance.
14531///
14532/// # Example
14533///
14534/// Instantiate a resource method builder
14535///
14536/// ```test_harness,no_run
14537/// # extern crate hyper;
14538/// # extern crate hyper_rustls;
14539/// # extern crate google_analytics3 as analytics3;
14540/// # async fn dox() {
14541/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14542///
14543/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14544/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14545/// #     .with_native_roots()
14546/// #     .unwrap()
14547/// #     .https_only()
14548/// #     .enable_http2()
14549/// #     .build();
14550///
14551/// # let executor = hyper_util::rt::TokioExecutor::new();
14552/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14553/// #     secret,
14554/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14555/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14556/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14557/// #     ),
14558/// # ).build().await.unwrap();
14559///
14560/// # let client = hyper_util::client::legacy::Client::builder(
14561/// #     hyper_util::rt::TokioExecutor::new()
14562/// # )
14563/// # .build(
14564/// #     hyper_rustls::HttpsConnectorBuilder::new()
14565/// #         .with_native_roots()
14566/// #         .unwrap()
14567/// #         .https_or_http()
14568/// #         .enable_http2()
14569/// #         .build()
14570/// # );
14571/// # let mut hub = Analytics::new(client, auth);
14572/// // You can configure optional parameters by calling the respective setters at will, and
14573/// // execute the final call using `doit()`.
14574/// // Values shown here are possibly random and not representative !
14575/// let result = hub.management().experiments_list("accountId", "webPropertyId", "profileId")
14576///              .start_index(-18)
14577///              .max_results(-8)
14578///              .doit().await;
14579/// # }
14580/// ```
14581pub struct ManagementExperimentListCall<'a, C>
14582where
14583    C: 'a,
14584{
14585    hub: &'a Analytics<C>,
14586    _account_id: String,
14587    _web_property_id: String,
14588    _profile_id: String,
14589    _start_index: Option<i32>,
14590    _max_results: Option<i32>,
14591    _delegate: Option<&'a mut dyn common::Delegate>,
14592    _additional_params: HashMap<String, String>,
14593    _scopes: BTreeSet<String>,
14594}
14595
14596impl<'a, C> common::CallBuilder for ManagementExperimentListCall<'a, C> {}
14597
14598impl<'a, C> ManagementExperimentListCall<'a, C>
14599where
14600    C: common::Connector,
14601{
14602    /// Perform the operation you have build so far.
14603    pub async fn doit(mut self) -> common::Result<(common::Response, Experiments)> {
14604        use std::borrow::Cow;
14605        use std::io::{Read, Seek};
14606
14607        use common::{url::Params, ToParts};
14608        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14609
14610        let mut dd = common::DefaultDelegate;
14611        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14612        dlg.begin(common::MethodInfo {
14613            id: "analytics.management.experiments.list",
14614            http_method: hyper::Method::GET,
14615        });
14616
14617        for &field in [
14618            "alt",
14619            "accountId",
14620            "webPropertyId",
14621            "profileId",
14622            "start-index",
14623            "max-results",
14624        ]
14625        .iter()
14626        {
14627            if self._additional_params.contains_key(field) {
14628                dlg.finished(false);
14629                return Err(common::Error::FieldClash(field));
14630            }
14631        }
14632
14633        let mut params = Params::with_capacity(7 + self._additional_params.len());
14634        params.push("accountId", self._account_id);
14635        params.push("webPropertyId", self._web_property_id);
14636        params.push("profileId", self._profile_id);
14637        if let Some(value) = self._start_index.as_ref() {
14638            params.push("start-index", value.to_string());
14639        }
14640        if let Some(value) = self._max_results.as_ref() {
14641            params.push("max-results", value.to_string());
14642        }
14643
14644        params.extend(self._additional_params.iter());
14645
14646        params.push("alt", "json");
14647        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments";
14648        if self._scopes.is_empty() {
14649            self._scopes.insert(Scope::Readonly.as_ref().to_string());
14650        }
14651
14652        #[allow(clippy::single_element_loop)]
14653        for &(find_this, param_name) in [
14654            ("{accountId}", "accountId"),
14655            ("{webPropertyId}", "webPropertyId"),
14656            ("{profileId}", "profileId"),
14657        ]
14658        .iter()
14659        {
14660            url = params.uri_replacement(url, param_name, find_this, false);
14661        }
14662        {
14663            let to_remove = ["profileId", "webPropertyId", "accountId"];
14664            params.remove_params(&to_remove);
14665        }
14666
14667        let url = params.parse_with_url(&url);
14668
14669        loop {
14670            let token = match self
14671                .hub
14672                .auth
14673                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14674                .await
14675            {
14676                Ok(token) => token,
14677                Err(e) => match dlg.token(e) {
14678                    Ok(token) => token,
14679                    Err(e) => {
14680                        dlg.finished(false);
14681                        return Err(common::Error::MissingToken(e));
14682                    }
14683                },
14684            };
14685            let mut req_result = {
14686                let client = &self.hub.client;
14687                dlg.pre_request();
14688                let mut req_builder = hyper::Request::builder()
14689                    .method(hyper::Method::GET)
14690                    .uri(url.as_str())
14691                    .header(USER_AGENT, self.hub._user_agent.clone());
14692
14693                if let Some(token) = token.as_ref() {
14694                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14695                }
14696
14697                let request = req_builder
14698                    .header(CONTENT_LENGTH, 0_u64)
14699                    .body(common::to_body::<String>(None));
14700
14701                client.request(request.unwrap()).await
14702            };
14703
14704            match req_result {
14705                Err(err) => {
14706                    if let common::Retry::After(d) = dlg.http_error(&err) {
14707                        sleep(d).await;
14708                        continue;
14709                    }
14710                    dlg.finished(false);
14711                    return Err(common::Error::HttpError(err));
14712                }
14713                Ok(res) => {
14714                    let (mut parts, body) = res.into_parts();
14715                    let mut body = common::Body::new(body);
14716                    if !parts.status.is_success() {
14717                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14718                        let error = serde_json::from_str(&common::to_string(&bytes));
14719                        let response = common::to_response(parts, bytes.into());
14720
14721                        if let common::Retry::After(d) =
14722                            dlg.http_failure(&response, error.as_ref().ok())
14723                        {
14724                            sleep(d).await;
14725                            continue;
14726                        }
14727
14728                        dlg.finished(false);
14729
14730                        return Err(match error {
14731                            Ok(value) => common::Error::BadRequest(value),
14732                            _ => common::Error::Failure(response),
14733                        });
14734                    }
14735                    let response = {
14736                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14737                        let encoded = common::to_string(&bytes);
14738                        match serde_json::from_str(&encoded) {
14739                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14740                            Err(error) => {
14741                                dlg.response_json_decode_error(&encoded, &error);
14742                                return Err(common::Error::JsonDecodeError(
14743                                    encoded.to_string(),
14744                                    error,
14745                                ));
14746                            }
14747                        }
14748                    };
14749
14750                    dlg.finished(true);
14751                    return Ok(response);
14752                }
14753            }
14754        }
14755    }
14756
14757    /// Account ID to retrieve experiments for.
14758    ///
14759    /// Sets the *account id* path property to the given value.
14760    ///
14761    /// Even though the property as already been set when instantiating this call,
14762    /// we provide this method for API completeness.
14763    pub fn account_id(mut self, new_value: &str) -> ManagementExperimentListCall<'a, C> {
14764        self._account_id = new_value.to_string();
14765        self
14766    }
14767    /// Web property ID to retrieve experiments for.
14768    ///
14769    /// Sets the *web property id* path property to the given value.
14770    ///
14771    /// Even though the property as already been set when instantiating this call,
14772    /// we provide this method for API completeness.
14773    pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentListCall<'a, C> {
14774        self._web_property_id = new_value.to_string();
14775        self
14776    }
14777    /// View (Profile) ID to retrieve experiments for.
14778    ///
14779    /// Sets the *profile id* path property to the given value.
14780    ///
14781    /// Even though the property as already been set when instantiating this call,
14782    /// we provide this method for API completeness.
14783    pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentListCall<'a, C> {
14784        self._profile_id = new_value.to_string();
14785        self
14786    }
14787    /// An index of the first experiment to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
14788    ///
14789    /// Sets the *start-index* query property to the given value.
14790    pub fn start_index(mut self, new_value: i32) -> ManagementExperimentListCall<'a, C> {
14791        self._start_index = Some(new_value);
14792        self
14793    }
14794    /// The maximum number of experiments to include in this response.
14795    ///
14796    /// Sets the *max-results* query property to the given value.
14797    pub fn max_results(mut self, new_value: i32) -> ManagementExperimentListCall<'a, C> {
14798        self._max_results = Some(new_value);
14799        self
14800    }
14801    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14802    /// while executing the actual API request.
14803    ///
14804    /// ````text
14805    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14806    /// ````
14807    ///
14808    /// Sets the *delegate* property to the given value.
14809    pub fn delegate(
14810        mut self,
14811        new_value: &'a mut dyn common::Delegate,
14812    ) -> ManagementExperimentListCall<'a, C> {
14813        self._delegate = Some(new_value);
14814        self
14815    }
14816
14817    /// Set any additional parameter of the query string used in the request.
14818    /// It should be used to set parameters which are not yet available through their own
14819    /// setters.
14820    ///
14821    /// Please note that this method must not be used to set any of the known parameters
14822    /// which have their own setter method. If done anyway, the request will fail.
14823    ///
14824    /// # Additional Parameters
14825    ///
14826    /// * *alt* (query-string) - Data format for the response.
14827    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14828    /// * *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.
14829    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14830    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14831    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14832    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14833    pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentListCall<'a, C>
14834    where
14835        T: AsRef<str>,
14836    {
14837        self._additional_params
14838            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14839        self
14840    }
14841
14842    /// Identifies the authorization scope for the method you are building.
14843    ///
14844    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14845    /// [`Scope::Readonly`].
14846    ///
14847    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14848    /// tokens for more than one scope.
14849    ///
14850    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14851    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14852    /// sufficient, a read-write scope will do as well.
14853    pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentListCall<'a, C>
14854    where
14855        St: AsRef<str>,
14856    {
14857        self._scopes.insert(String::from(scope.as_ref()));
14858        self
14859    }
14860    /// Identifies the authorization scope(s) for the method you are building.
14861    ///
14862    /// See [`Self::add_scope()`] for details.
14863    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentListCall<'a, C>
14864    where
14865        I: IntoIterator<Item = St>,
14866        St: AsRef<str>,
14867    {
14868        self._scopes
14869            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14870        self
14871    }
14872
14873    /// Removes all scopes, and no default scope will be used either.
14874    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14875    /// for details).
14876    pub fn clear_scopes(mut self) -> ManagementExperimentListCall<'a, C> {
14877        self._scopes.clear();
14878        self
14879    }
14880}
14881
14882/// Update an existing experiment. This method supports patch semantics.
14883///
14884/// A builder for the *experiments.patch* method supported by a *management* resource.
14885/// It is not used directly, but through a [`ManagementMethods`] instance.
14886///
14887/// # Example
14888///
14889/// Instantiate a resource method builder
14890///
14891/// ```test_harness,no_run
14892/// # extern crate hyper;
14893/// # extern crate hyper_rustls;
14894/// # extern crate google_analytics3 as analytics3;
14895/// use analytics3::api::Experiment;
14896/// # async fn dox() {
14897/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14898///
14899/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14900/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14901/// #     .with_native_roots()
14902/// #     .unwrap()
14903/// #     .https_only()
14904/// #     .enable_http2()
14905/// #     .build();
14906///
14907/// # let executor = hyper_util::rt::TokioExecutor::new();
14908/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14909/// #     secret,
14910/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14911/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14912/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14913/// #     ),
14914/// # ).build().await.unwrap();
14915///
14916/// # let client = hyper_util::client::legacy::Client::builder(
14917/// #     hyper_util::rt::TokioExecutor::new()
14918/// # )
14919/// # .build(
14920/// #     hyper_rustls::HttpsConnectorBuilder::new()
14921/// #         .with_native_roots()
14922/// #         .unwrap()
14923/// #         .https_or_http()
14924/// #         .enable_http2()
14925/// #         .build()
14926/// # );
14927/// # let mut hub = Analytics::new(client, auth);
14928/// // As the method needs a request, you would usually fill it with the desired information
14929/// // into the respective structure. Some of the parts shown here might not be applicable !
14930/// // Values shown here are possibly random and not representative !
14931/// let mut req = Experiment::default();
14932///
14933/// // You can configure optional parameters by calling the respective setters at will, and
14934/// // execute the final call using `doit()`.
14935/// // Values shown here are possibly random and not representative !
14936/// let result = hub.management().experiments_patch(req, "accountId", "webPropertyId", "profileId", "experimentId")
14937///              .doit().await;
14938/// # }
14939/// ```
14940pub struct ManagementExperimentPatchCall<'a, C>
14941where
14942    C: 'a,
14943{
14944    hub: &'a Analytics<C>,
14945    _request: Experiment,
14946    _account_id: String,
14947    _web_property_id: String,
14948    _profile_id: String,
14949    _experiment_id: String,
14950    _delegate: Option<&'a mut dyn common::Delegate>,
14951    _additional_params: HashMap<String, String>,
14952    _scopes: BTreeSet<String>,
14953}
14954
14955impl<'a, C> common::CallBuilder for ManagementExperimentPatchCall<'a, C> {}
14956
14957impl<'a, C> ManagementExperimentPatchCall<'a, C>
14958where
14959    C: common::Connector,
14960{
14961    /// Perform the operation you have build so far.
14962    pub async fn doit(mut self) -> common::Result<(common::Response, Experiment)> {
14963        use std::borrow::Cow;
14964        use std::io::{Read, Seek};
14965
14966        use common::{url::Params, ToParts};
14967        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14968
14969        let mut dd = common::DefaultDelegate;
14970        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14971        dlg.begin(common::MethodInfo {
14972            id: "analytics.management.experiments.patch",
14973            http_method: hyper::Method::PATCH,
14974        });
14975
14976        for &field in [
14977            "alt",
14978            "accountId",
14979            "webPropertyId",
14980            "profileId",
14981            "experimentId",
14982        ]
14983        .iter()
14984        {
14985            if self._additional_params.contains_key(field) {
14986                dlg.finished(false);
14987                return Err(common::Error::FieldClash(field));
14988            }
14989        }
14990
14991        let mut params = Params::with_capacity(7 + self._additional_params.len());
14992        params.push("accountId", self._account_id);
14993        params.push("webPropertyId", self._web_property_id);
14994        params.push("profileId", self._profile_id);
14995        params.push("experimentId", self._experiment_id);
14996
14997        params.extend(self._additional_params.iter());
14998
14999        params.push("alt", "json");
15000        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}";
15001        if self._scopes.is_empty() {
15002            self._scopes.insert(Scope::Full.as_ref().to_string());
15003        }
15004
15005        #[allow(clippy::single_element_loop)]
15006        for &(find_this, param_name) in [
15007            ("{accountId}", "accountId"),
15008            ("{webPropertyId}", "webPropertyId"),
15009            ("{profileId}", "profileId"),
15010            ("{experimentId}", "experimentId"),
15011        ]
15012        .iter()
15013        {
15014            url = params.uri_replacement(url, param_name, find_this, false);
15015        }
15016        {
15017            let to_remove = ["experimentId", "profileId", "webPropertyId", "accountId"];
15018            params.remove_params(&to_remove);
15019        }
15020
15021        let url = params.parse_with_url(&url);
15022
15023        let mut json_mime_type = mime::APPLICATION_JSON;
15024        let mut request_value_reader = {
15025            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15026            common::remove_json_null_values(&mut value);
15027            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15028            serde_json::to_writer(&mut dst, &value).unwrap();
15029            dst
15030        };
15031        let request_size = request_value_reader
15032            .seek(std::io::SeekFrom::End(0))
15033            .unwrap();
15034        request_value_reader
15035            .seek(std::io::SeekFrom::Start(0))
15036            .unwrap();
15037
15038        loop {
15039            let token = match self
15040                .hub
15041                .auth
15042                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15043                .await
15044            {
15045                Ok(token) => token,
15046                Err(e) => match dlg.token(e) {
15047                    Ok(token) => token,
15048                    Err(e) => {
15049                        dlg.finished(false);
15050                        return Err(common::Error::MissingToken(e));
15051                    }
15052                },
15053            };
15054            request_value_reader
15055                .seek(std::io::SeekFrom::Start(0))
15056                .unwrap();
15057            let mut req_result = {
15058                let client = &self.hub.client;
15059                dlg.pre_request();
15060                let mut req_builder = hyper::Request::builder()
15061                    .method(hyper::Method::PATCH)
15062                    .uri(url.as_str())
15063                    .header(USER_AGENT, self.hub._user_agent.clone());
15064
15065                if let Some(token) = token.as_ref() {
15066                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15067                }
15068
15069                let request = req_builder
15070                    .header(CONTENT_TYPE, json_mime_type.to_string())
15071                    .header(CONTENT_LENGTH, request_size as u64)
15072                    .body(common::to_body(
15073                        request_value_reader.get_ref().clone().into(),
15074                    ));
15075
15076                client.request(request.unwrap()).await
15077            };
15078
15079            match req_result {
15080                Err(err) => {
15081                    if let common::Retry::After(d) = dlg.http_error(&err) {
15082                        sleep(d).await;
15083                        continue;
15084                    }
15085                    dlg.finished(false);
15086                    return Err(common::Error::HttpError(err));
15087                }
15088                Ok(res) => {
15089                    let (mut parts, body) = res.into_parts();
15090                    let mut body = common::Body::new(body);
15091                    if !parts.status.is_success() {
15092                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15093                        let error = serde_json::from_str(&common::to_string(&bytes));
15094                        let response = common::to_response(parts, bytes.into());
15095
15096                        if let common::Retry::After(d) =
15097                            dlg.http_failure(&response, error.as_ref().ok())
15098                        {
15099                            sleep(d).await;
15100                            continue;
15101                        }
15102
15103                        dlg.finished(false);
15104
15105                        return Err(match error {
15106                            Ok(value) => common::Error::BadRequest(value),
15107                            _ => common::Error::Failure(response),
15108                        });
15109                    }
15110                    let response = {
15111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15112                        let encoded = common::to_string(&bytes);
15113                        match serde_json::from_str(&encoded) {
15114                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15115                            Err(error) => {
15116                                dlg.response_json_decode_error(&encoded, &error);
15117                                return Err(common::Error::JsonDecodeError(
15118                                    encoded.to_string(),
15119                                    error,
15120                                ));
15121                            }
15122                        }
15123                    };
15124
15125                    dlg.finished(true);
15126                    return Ok(response);
15127                }
15128            }
15129        }
15130    }
15131
15132    ///
15133    /// Sets the *request* property to the given value.
15134    ///
15135    /// Even though the property as already been set when instantiating this call,
15136    /// we provide this method for API completeness.
15137    pub fn request(mut self, new_value: Experiment) -> ManagementExperimentPatchCall<'a, C> {
15138        self._request = new_value;
15139        self
15140    }
15141    /// Account ID of the experiment to update.
15142    ///
15143    /// Sets the *account id* path property to the given value.
15144    ///
15145    /// Even though the property as already been set when instantiating this call,
15146    /// we provide this method for API completeness.
15147    pub fn account_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C> {
15148        self._account_id = new_value.to_string();
15149        self
15150    }
15151    /// Web property ID of the experiment to update.
15152    ///
15153    /// Sets the *web property id* path property to the given value.
15154    ///
15155    /// Even though the property as already been set when instantiating this call,
15156    /// we provide this method for API completeness.
15157    pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C> {
15158        self._web_property_id = new_value.to_string();
15159        self
15160    }
15161    /// View (Profile) ID of the experiment to update.
15162    ///
15163    /// Sets the *profile id* path property to the given value.
15164    ///
15165    /// Even though the property as already been set when instantiating this call,
15166    /// we provide this method for API completeness.
15167    pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C> {
15168        self._profile_id = new_value.to_string();
15169        self
15170    }
15171    /// Experiment ID of the experiment to update.
15172    ///
15173    /// Sets the *experiment id* path property to the given value.
15174    ///
15175    /// Even though the property as already been set when instantiating this call,
15176    /// we provide this method for API completeness.
15177    pub fn experiment_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C> {
15178        self._experiment_id = new_value.to_string();
15179        self
15180    }
15181    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15182    /// while executing the actual API request.
15183    ///
15184    /// ````text
15185    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15186    /// ````
15187    ///
15188    /// Sets the *delegate* property to the given value.
15189    pub fn delegate(
15190        mut self,
15191        new_value: &'a mut dyn common::Delegate,
15192    ) -> ManagementExperimentPatchCall<'a, C> {
15193        self._delegate = Some(new_value);
15194        self
15195    }
15196
15197    /// Set any additional parameter of the query string used in the request.
15198    /// It should be used to set parameters which are not yet available through their own
15199    /// setters.
15200    ///
15201    /// Please note that this method must not be used to set any of the known parameters
15202    /// which have their own setter method. If done anyway, the request will fail.
15203    ///
15204    /// # Additional Parameters
15205    ///
15206    /// * *alt* (query-string) - Data format for the response.
15207    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15208    /// * *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.
15209    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15210    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15211    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15212    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15213    pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentPatchCall<'a, C>
15214    where
15215        T: AsRef<str>,
15216    {
15217        self._additional_params
15218            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15219        self
15220    }
15221
15222    /// Identifies the authorization scope for the method you are building.
15223    ///
15224    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15225    /// [`Scope::Full`].
15226    ///
15227    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15228    /// tokens for more than one scope.
15229    ///
15230    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15231    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15232    /// sufficient, a read-write scope will do as well.
15233    pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentPatchCall<'a, C>
15234    where
15235        St: AsRef<str>,
15236    {
15237        self._scopes.insert(String::from(scope.as_ref()));
15238        self
15239    }
15240    /// Identifies the authorization scope(s) for the method you are building.
15241    ///
15242    /// See [`Self::add_scope()`] for details.
15243    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentPatchCall<'a, C>
15244    where
15245        I: IntoIterator<Item = St>,
15246        St: AsRef<str>,
15247    {
15248        self._scopes
15249            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15250        self
15251    }
15252
15253    /// Removes all scopes, and no default scope will be used either.
15254    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15255    /// for details).
15256    pub fn clear_scopes(mut self) -> ManagementExperimentPatchCall<'a, C> {
15257        self._scopes.clear();
15258        self
15259    }
15260}
15261
15262/// Update an existing experiment.
15263///
15264/// A builder for the *experiments.update* method supported by a *management* resource.
15265/// It is not used directly, but through a [`ManagementMethods`] instance.
15266///
15267/// # Example
15268///
15269/// Instantiate a resource method builder
15270///
15271/// ```test_harness,no_run
15272/// # extern crate hyper;
15273/// # extern crate hyper_rustls;
15274/// # extern crate google_analytics3 as analytics3;
15275/// use analytics3::api::Experiment;
15276/// # async fn dox() {
15277/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15278///
15279/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15280/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15281/// #     .with_native_roots()
15282/// #     .unwrap()
15283/// #     .https_only()
15284/// #     .enable_http2()
15285/// #     .build();
15286///
15287/// # let executor = hyper_util::rt::TokioExecutor::new();
15288/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15289/// #     secret,
15290/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15291/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15292/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15293/// #     ),
15294/// # ).build().await.unwrap();
15295///
15296/// # let client = hyper_util::client::legacy::Client::builder(
15297/// #     hyper_util::rt::TokioExecutor::new()
15298/// # )
15299/// # .build(
15300/// #     hyper_rustls::HttpsConnectorBuilder::new()
15301/// #         .with_native_roots()
15302/// #         .unwrap()
15303/// #         .https_or_http()
15304/// #         .enable_http2()
15305/// #         .build()
15306/// # );
15307/// # let mut hub = Analytics::new(client, auth);
15308/// // As the method needs a request, you would usually fill it with the desired information
15309/// // into the respective structure. Some of the parts shown here might not be applicable !
15310/// // Values shown here are possibly random and not representative !
15311/// let mut req = Experiment::default();
15312///
15313/// // You can configure optional parameters by calling the respective setters at will, and
15314/// // execute the final call using `doit()`.
15315/// // Values shown here are possibly random and not representative !
15316/// let result = hub.management().experiments_update(req, "accountId", "webPropertyId", "profileId", "experimentId")
15317///              .doit().await;
15318/// # }
15319/// ```
15320pub struct ManagementExperimentUpdateCall<'a, C>
15321where
15322    C: 'a,
15323{
15324    hub: &'a Analytics<C>,
15325    _request: Experiment,
15326    _account_id: String,
15327    _web_property_id: String,
15328    _profile_id: String,
15329    _experiment_id: String,
15330    _delegate: Option<&'a mut dyn common::Delegate>,
15331    _additional_params: HashMap<String, String>,
15332    _scopes: BTreeSet<String>,
15333}
15334
15335impl<'a, C> common::CallBuilder for ManagementExperimentUpdateCall<'a, C> {}
15336
15337impl<'a, C> ManagementExperimentUpdateCall<'a, C>
15338where
15339    C: common::Connector,
15340{
15341    /// Perform the operation you have build so far.
15342    pub async fn doit(mut self) -> common::Result<(common::Response, Experiment)> {
15343        use std::borrow::Cow;
15344        use std::io::{Read, Seek};
15345
15346        use common::{url::Params, ToParts};
15347        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15348
15349        let mut dd = common::DefaultDelegate;
15350        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15351        dlg.begin(common::MethodInfo {
15352            id: "analytics.management.experiments.update",
15353            http_method: hyper::Method::PUT,
15354        });
15355
15356        for &field in [
15357            "alt",
15358            "accountId",
15359            "webPropertyId",
15360            "profileId",
15361            "experimentId",
15362        ]
15363        .iter()
15364        {
15365            if self._additional_params.contains_key(field) {
15366                dlg.finished(false);
15367                return Err(common::Error::FieldClash(field));
15368            }
15369        }
15370
15371        let mut params = Params::with_capacity(7 + self._additional_params.len());
15372        params.push("accountId", self._account_id);
15373        params.push("webPropertyId", self._web_property_id);
15374        params.push("profileId", self._profile_id);
15375        params.push("experimentId", self._experiment_id);
15376
15377        params.extend(self._additional_params.iter());
15378
15379        params.push("alt", "json");
15380        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}";
15381        if self._scopes.is_empty() {
15382            self._scopes.insert(Scope::Full.as_ref().to_string());
15383        }
15384
15385        #[allow(clippy::single_element_loop)]
15386        for &(find_this, param_name) in [
15387            ("{accountId}", "accountId"),
15388            ("{webPropertyId}", "webPropertyId"),
15389            ("{profileId}", "profileId"),
15390            ("{experimentId}", "experimentId"),
15391        ]
15392        .iter()
15393        {
15394            url = params.uri_replacement(url, param_name, find_this, false);
15395        }
15396        {
15397            let to_remove = ["experimentId", "profileId", "webPropertyId", "accountId"];
15398            params.remove_params(&to_remove);
15399        }
15400
15401        let url = params.parse_with_url(&url);
15402
15403        let mut json_mime_type = mime::APPLICATION_JSON;
15404        let mut request_value_reader = {
15405            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15406            common::remove_json_null_values(&mut value);
15407            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15408            serde_json::to_writer(&mut dst, &value).unwrap();
15409            dst
15410        };
15411        let request_size = request_value_reader
15412            .seek(std::io::SeekFrom::End(0))
15413            .unwrap();
15414        request_value_reader
15415            .seek(std::io::SeekFrom::Start(0))
15416            .unwrap();
15417
15418        loop {
15419            let token = match self
15420                .hub
15421                .auth
15422                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15423                .await
15424            {
15425                Ok(token) => token,
15426                Err(e) => match dlg.token(e) {
15427                    Ok(token) => token,
15428                    Err(e) => {
15429                        dlg.finished(false);
15430                        return Err(common::Error::MissingToken(e));
15431                    }
15432                },
15433            };
15434            request_value_reader
15435                .seek(std::io::SeekFrom::Start(0))
15436                .unwrap();
15437            let mut req_result = {
15438                let client = &self.hub.client;
15439                dlg.pre_request();
15440                let mut req_builder = hyper::Request::builder()
15441                    .method(hyper::Method::PUT)
15442                    .uri(url.as_str())
15443                    .header(USER_AGENT, self.hub._user_agent.clone());
15444
15445                if let Some(token) = token.as_ref() {
15446                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15447                }
15448
15449                let request = req_builder
15450                    .header(CONTENT_TYPE, json_mime_type.to_string())
15451                    .header(CONTENT_LENGTH, request_size as u64)
15452                    .body(common::to_body(
15453                        request_value_reader.get_ref().clone().into(),
15454                    ));
15455
15456                client.request(request.unwrap()).await
15457            };
15458
15459            match req_result {
15460                Err(err) => {
15461                    if let common::Retry::After(d) = dlg.http_error(&err) {
15462                        sleep(d).await;
15463                        continue;
15464                    }
15465                    dlg.finished(false);
15466                    return Err(common::Error::HttpError(err));
15467                }
15468                Ok(res) => {
15469                    let (mut parts, body) = res.into_parts();
15470                    let mut body = common::Body::new(body);
15471                    if !parts.status.is_success() {
15472                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15473                        let error = serde_json::from_str(&common::to_string(&bytes));
15474                        let response = common::to_response(parts, bytes.into());
15475
15476                        if let common::Retry::After(d) =
15477                            dlg.http_failure(&response, error.as_ref().ok())
15478                        {
15479                            sleep(d).await;
15480                            continue;
15481                        }
15482
15483                        dlg.finished(false);
15484
15485                        return Err(match error {
15486                            Ok(value) => common::Error::BadRequest(value),
15487                            _ => common::Error::Failure(response),
15488                        });
15489                    }
15490                    let response = {
15491                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15492                        let encoded = common::to_string(&bytes);
15493                        match serde_json::from_str(&encoded) {
15494                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15495                            Err(error) => {
15496                                dlg.response_json_decode_error(&encoded, &error);
15497                                return Err(common::Error::JsonDecodeError(
15498                                    encoded.to_string(),
15499                                    error,
15500                                ));
15501                            }
15502                        }
15503                    };
15504
15505                    dlg.finished(true);
15506                    return Ok(response);
15507                }
15508            }
15509        }
15510    }
15511
15512    ///
15513    /// Sets the *request* property to the given value.
15514    ///
15515    /// Even though the property as already been set when instantiating this call,
15516    /// we provide this method for API completeness.
15517    pub fn request(mut self, new_value: Experiment) -> ManagementExperimentUpdateCall<'a, C> {
15518        self._request = new_value;
15519        self
15520    }
15521    /// Account ID of the experiment to update.
15522    ///
15523    /// Sets the *account id* path property to the given value.
15524    ///
15525    /// Even though the property as already been set when instantiating this call,
15526    /// we provide this method for API completeness.
15527    pub fn account_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C> {
15528        self._account_id = new_value.to_string();
15529        self
15530    }
15531    /// Web property ID of the experiment to update.
15532    ///
15533    /// Sets the *web property id* path property to the given value.
15534    ///
15535    /// Even though the property as already been set when instantiating this call,
15536    /// we provide this method for API completeness.
15537    pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C> {
15538        self._web_property_id = new_value.to_string();
15539        self
15540    }
15541    /// View (Profile) ID of the experiment to update.
15542    ///
15543    /// Sets the *profile id* path property to the given value.
15544    ///
15545    /// Even though the property as already been set when instantiating this call,
15546    /// we provide this method for API completeness.
15547    pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C> {
15548        self._profile_id = new_value.to_string();
15549        self
15550    }
15551    /// Experiment ID of the experiment to update.
15552    ///
15553    /// Sets the *experiment id* path property to the given value.
15554    ///
15555    /// Even though the property as already been set when instantiating this call,
15556    /// we provide this method for API completeness.
15557    pub fn experiment_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C> {
15558        self._experiment_id = new_value.to_string();
15559        self
15560    }
15561    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15562    /// while executing the actual API request.
15563    ///
15564    /// ````text
15565    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15566    /// ````
15567    ///
15568    /// Sets the *delegate* property to the given value.
15569    pub fn delegate(
15570        mut self,
15571        new_value: &'a mut dyn common::Delegate,
15572    ) -> ManagementExperimentUpdateCall<'a, C> {
15573        self._delegate = Some(new_value);
15574        self
15575    }
15576
15577    /// Set any additional parameter of the query string used in the request.
15578    /// It should be used to set parameters which are not yet available through their own
15579    /// setters.
15580    ///
15581    /// Please note that this method must not be used to set any of the known parameters
15582    /// which have their own setter method. If done anyway, the request will fail.
15583    ///
15584    /// # Additional Parameters
15585    ///
15586    /// * *alt* (query-string) - Data format for the response.
15587    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15588    /// * *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.
15589    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15590    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15591    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15592    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15593    pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentUpdateCall<'a, C>
15594    where
15595        T: AsRef<str>,
15596    {
15597        self._additional_params
15598            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15599        self
15600    }
15601
15602    /// Identifies the authorization scope for the method you are building.
15603    ///
15604    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15605    /// [`Scope::Full`].
15606    ///
15607    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15608    /// tokens for more than one scope.
15609    ///
15610    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15611    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15612    /// sufficient, a read-write scope will do as well.
15613    pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentUpdateCall<'a, C>
15614    where
15615        St: AsRef<str>,
15616    {
15617        self._scopes.insert(String::from(scope.as_ref()));
15618        self
15619    }
15620    /// Identifies the authorization scope(s) for the method you are building.
15621    ///
15622    /// See [`Self::add_scope()`] for details.
15623    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentUpdateCall<'a, C>
15624    where
15625        I: IntoIterator<Item = St>,
15626        St: AsRef<str>,
15627    {
15628        self._scopes
15629            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15630        self
15631    }
15632
15633    /// Removes all scopes, and no default scope will be used either.
15634    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15635    /// for details).
15636    pub fn clear_scopes(mut self) -> ManagementExperimentUpdateCall<'a, C> {
15637        self._scopes.clear();
15638        self
15639    }
15640}
15641
15642/// Delete a filter.
15643///
15644/// A builder for the *filters.delete* method supported by a *management* resource.
15645/// It is not used directly, but through a [`ManagementMethods`] instance.
15646///
15647/// # Example
15648///
15649/// Instantiate a resource method builder
15650///
15651/// ```test_harness,no_run
15652/// # extern crate hyper;
15653/// # extern crate hyper_rustls;
15654/// # extern crate google_analytics3 as analytics3;
15655/// # async fn dox() {
15656/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15657///
15658/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15659/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15660/// #     .with_native_roots()
15661/// #     .unwrap()
15662/// #     .https_only()
15663/// #     .enable_http2()
15664/// #     .build();
15665///
15666/// # let executor = hyper_util::rt::TokioExecutor::new();
15667/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15668/// #     secret,
15669/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15670/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15671/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15672/// #     ),
15673/// # ).build().await.unwrap();
15674///
15675/// # let client = hyper_util::client::legacy::Client::builder(
15676/// #     hyper_util::rt::TokioExecutor::new()
15677/// # )
15678/// # .build(
15679/// #     hyper_rustls::HttpsConnectorBuilder::new()
15680/// #         .with_native_roots()
15681/// #         .unwrap()
15682/// #         .https_or_http()
15683/// #         .enable_http2()
15684/// #         .build()
15685/// # );
15686/// # let mut hub = Analytics::new(client, auth);
15687/// // You can configure optional parameters by calling the respective setters at will, and
15688/// // execute the final call using `doit()`.
15689/// // Values shown here are possibly random and not representative !
15690/// let result = hub.management().filters_delete("accountId", "filterId")
15691///              .doit().await;
15692/// # }
15693/// ```
15694pub struct ManagementFilterDeleteCall<'a, C>
15695where
15696    C: 'a,
15697{
15698    hub: &'a Analytics<C>,
15699    _account_id: String,
15700    _filter_id: String,
15701    _delegate: Option<&'a mut dyn common::Delegate>,
15702    _additional_params: HashMap<String, String>,
15703    _scopes: BTreeSet<String>,
15704}
15705
15706impl<'a, C> common::CallBuilder for ManagementFilterDeleteCall<'a, C> {}
15707
15708impl<'a, C> ManagementFilterDeleteCall<'a, C>
15709where
15710    C: common::Connector,
15711{
15712    /// Perform the operation you have build so far.
15713    pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
15714        use std::borrow::Cow;
15715        use std::io::{Read, Seek};
15716
15717        use common::{url::Params, ToParts};
15718        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15719
15720        let mut dd = common::DefaultDelegate;
15721        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15722        dlg.begin(common::MethodInfo {
15723            id: "analytics.management.filters.delete",
15724            http_method: hyper::Method::DELETE,
15725        });
15726
15727        for &field in ["alt", "accountId", "filterId"].iter() {
15728            if self._additional_params.contains_key(field) {
15729                dlg.finished(false);
15730                return Err(common::Error::FieldClash(field));
15731            }
15732        }
15733
15734        let mut params = Params::with_capacity(4 + self._additional_params.len());
15735        params.push("accountId", self._account_id);
15736        params.push("filterId", self._filter_id);
15737
15738        params.extend(self._additional_params.iter());
15739
15740        params.push("alt", "json");
15741        let mut url =
15742            self.hub._base_url.clone() + "management/accounts/{accountId}/filters/{filterId}";
15743        if self._scopes.is_empty() {
15744            self._scopes.insert(Scope::Edit.as_ref().to_string());
15745        }
15746
15747        #[allow(clippy::single_element_loop)]
15748        for &(find_this, param_name) in
15749            [("{accountId}", "accountId"), ("{filterId}", "filterId")].iter()
15750        {
15751            url = params.uri_replacement(url, param_name, find_this, false);
15752        }
15753        {
15754            let to_remove = ["filterId", "accountId"];
15755            params.remove_params(&to_remove);
15756        }
15757
15758        let url = params.parse_with_url(&url);
15759
15760        loop {
15761            let token = match self
15762                .hub
15763                .auth
15764                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15765                .await
15766            {
15767                Ok(token) => token,
15768                Err(e) => match dlg.token(e) {
15769                    Ok(token) => token,
15770                    Err(e) => {
15771                        dlg.finished(false);
15772                        return Err(common::Error::MissingToken(e));
15773                    }
15774                },
15775            };
15776            let mut req_result = {
15777                let client = &self.hub.client;
15778                dlg.pre_request();
15779                let mut req_builder = hyper::Request::builder()
15780                    .method(hyper::Method::DELETE)
15781                    .uri(url.as_str())
15782                    .header(USER_AGENT, self.hub._user_agent.clone());
15783
15784                if let Some(token) = token.as_ref() {
15785                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15786                }
15787
15788                let request = req_builder
15789                    .header(CONTENT_LENGTH, 0_u64)
15790                    .body(common::to_body::<String>(None));
15791
15792                client.request(request.unwrap()).await
15793            };
15794
15795            match req_result {
15796                Err(err) => {
15797                    if let common::Retry::After(d) = dlg.http_error(&err) {
15798                        sleep(d).await;
15799                        continue;
15800                    }
15801                    dlg.finished(false);
15802                    return Err(common::Error::HttpError(err));
15803                }
15804                Ok(res) => {
15805                    let (mut parts, body) = res.into_parts();
15806                    let mut body = common::Body::new(body);
15807                    if !parts.status.is_success() {
15808                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15809                        let error = serde_json::from_str(&common::to_string(&bytes));
15810                        let response = common::to_response(parts, bytes.into());
15811
15812                        if let common::Retry::After(d) =
15813                            dlg.http_failure(&response, error.as_ref().ok())
15814                        {
15815                            sleep(d).await;
15816                            continue;
15817                        }
15818
15819                        dlg.finished(false);
15820
15821                        return Err(match error {
15822                            Ok(value) => common::Error::BadRequest(value),
15823                            _ => common::Error::Failure(response),
15824                        });
15825                    }
15826                    let response = {
15827                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15828                        let encoded = common::to_string(&bytes);
15829                        match serde_json::from_str(&encoded) {
15830                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15831                            Err(error) => {
15832                                dlg.response_json_decode_error(&encoded, &error);
15833                                return Err(common::Error::JsonDecodeError(
15834                                    encoded.to_string(),
15835                                    error,
15836                                ));
15837                            }
15838                        }
15839                    };
15840
15841                    dlg.finished(true);
15842                    return Ok(response);
15843                }
15844            }
15845        }
15846    }
15847
15848    /// Account ID to delete the filter for.
15849    ///
15850    /// Sets the *account id* path property to the given value.
15851    ///
15852    /// Even though the property as already been set when instantiating this call,
15853    /// we provide this method for API completeness.
15854    pub fn account_id(mut self, new_value: &str) -> ManagementFilterDeleteCall<'a, C> {
15855        self._account_id = new_value.to_string();
15856        self
15857    }
15858    /// ID of the filter to be deleted.
15859    ///
15860    /// Sets the *filter id* path property to the given value.
15861    ///
15862    /// Even though the property as already been set when instantiating this call,
15863    /// we provide this method for API completeness.
15864    pub fn filter_id(mut self, new_value: &str) -> ManagementFilterDeleteCall<'a, C> {
15865        self._filter_id = new_value.to_string();
15866        self
15867    }
15868    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15869    /// while executing the actual API request.
15870    ///
15871    /// ````text
15872    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15873    /// ````
15874    ///
15875    /// Sets the *delegate* property to the given value.
15876    pub fn delegate(
15877        mut self,
15878        new_value: &'a mut dyn common::Delegate,
15879    ) -> ManagementFilterDeleteCall<'a, C> {
15880        self._delegate = Some(new_value);
15881        self
15882    }
15883
15884    /// Set any additional parameter of the query string used in the request.
15885    /// It should be used to set parameters which are not yet available through their own
15886    /// setters.
15887    ///
15888    /// Please note that this method must not be used to set any of the known parameters
15889    /// which have their own setter method. If done anyway, the request will fail.
15890    ///
15891    /// # Additional Parameters
15892    ///
15893    /// * *alt* (query-string) - Data format for the response.
15894    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15895    /// * *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.
15896    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15897    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15898    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15899    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15900    pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterDeleteCall<'a, C>
15901    where
15902        T: AsRef<str>,
15903    {
15904        self._additional_params
15905            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15906        self
15907    }
15908
15909    /// Identifies the authorization scope for the method you are building.
15910    ///
15911    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15912    /// [`Scope::Edit`].
15913    ///
15914    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15915    /// tokens for more than one scope.
15916    ///
15917    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15918    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15919    /// sufficient, a read-write scope will do as well.
15920    pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterDeleteCall<'a, C>
15921    where
15922        St: AsRef<str>,
15923    {
15924        self._scopes.insert(String::from(scope.as_ref()));
15925        self
15926    }
15927    /// Identifies the authorization scope(s) for the method you are building.
15928    ///
15929    /// See [`Self::add_scope()`] for details.
15930    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterDeleteCall<'a, C>
15931    where
15932        I: IntoIterator<Item = St>,
15933        St: AsRef<str>,
15934    {
15935        self._scopes
15936            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15937        self
15938    }
15939
15940    /// Removes all scopes, and no default scope will be used either.
15941    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15942    /// for details).
15943    pub fn clear_scopes(mut self) -> ManagementFilterDeleteCall<'a, C> {
15944        self._scopes.clear();
15945        self
15946    }
15947}
15948
15949/// Returns filters to which the user has access.
15950///
15951/// A builder for the *filters.get* method supported by a *management* resource.
15952/// It is not used directly, but through a [`ManagementMethods`] instance.
15953///
15954/// # Example
15955///
15956/// Instantiate a resource method builder
15957///
15958/// ```test_harness,no_run
15959/// # extern crate hyper;
15960/// # extern crate hyper_rustls;
15961/// # extern crate google_analytics3 as analytics3;
15962/// # async fn dox() {
15963/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15964///
15965/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15966/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15967/// #     .with_native_roots()
15968/// #     .unwrap()
15969/// #     .https_only()
15970/// #     .enable_http2()
15971/// #     .build();
15972///
15973/// # let executor = hyper_util::rt::TokioExecutor::new();
15974/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15975/// #     secret,
15976/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15977/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15978/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15979/// #     ),
15980/// # ).build().await.unwrap();
15981///
15982/// # let client = hyper_util::client::legacy::Client::builder(
15983/// #     hyper_util::rt::TokioExecutor::new()
15984/// # )
15985/// # .build(
15986/// #     hyper_rustls::HttpsConnectorBuilder::new()
15987/// #         .with_native_roots()
15988/// #         .unwrap()
15989/// #         .https_or_http()
15990/// #         .enable_http2()
15991/// #         .build()
15992/// # );
15993/// # let mut hub = Analytics::new(client, auth);
15994/// // You can configure optional parameters by calling the respective setters at will, and
15995/// // execute the final call using `doit()`.
15996/// // Values shown here are possibly random and not representative !
15997/// let result = hub.management().filters_get("accountId", "filterId")
15998///              .doit().await;
15999/// # }
16000/// ```
16001pub struct ManagementFilterGetCall<'a, C>
16002where
16003    C: 'a,
16004{
16005    hub: &'a Analytics<C>,
16006    _account_id: String,
16007    _filter_id: String,
16008    _delegate: Option<&'a mut dyn common::Delegate>,
16009    _additional_params: HashMap<String, String>,
16010    _scopes: BTreeSet<String>,
16011}
16012
16013impl<'a, C> common::CallBuilder for ManagementFilterGetCall<'a, C> {}
16014
16015impl<'a, C> ManagementFilterGetCall<'a, C>
16016where
16017    C: common::Connector,
16018{
16019    /// Perform the operation you have build so far.
16020    pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
16021        use std::borrow::Cow;
16022        use std::io::{Read, Seek};
16023
16024        use common::{url::Params, ToParts};
16025        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16026
16027        let mut dd = common::DefaultDelegate;
16028        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16029        dlg.begin(common::MethodInfo {
16030            id: "analytics.management.filters.get",
16031            http_method: hyper::Method::GET,
16032        });
16033
16034        for &field in ["alt", "accountId", "filterId"].iter() {
16035            if self._additional_params.contains_key(field) {
16036                dlg.finished(false);
16037                return Err(common::Error::FieldClash(field));
16038            }
16039        }
16040
16041        let mut params = Params::with_capacity(4 + self._additional_params.len());
16042        params.push("accountId", self._account_id);
16043        params.push("filterId", self._filter_id);
16044
16045        params.extend(self._additional_params.iter());
16046
16047        params.push("alt", "json");
16048        let mut url =
16049            self.hub._base_url.clone() + "management/accounts/{accountId}/filters/{filterId}";
16050        if self._scopes.is_empty() {
16051            self._scopes.insert(Scope::Readonly.as_ref().to_string());
16052        }
16053
16054        #[allow(clippy::single_element_loop)]
16055        for &(find_this, param_name) in
16056            [("{accountId}", "accountId"), ("{filterId}", "filterId")].iter()
16057        {
16058            url = params.uri_replacement(url, param_name, find_this, false);
16059        }
16060        {
16061            let to_remove = ["filterId", "accountId"];
16062            params.remove_params(&to_remove);
16063        }
16064
16065        let url = params.parse_with_url(&url);
16066
16067        loop {
16068            let token = match self
16069                .hub
16070                .auth
16071                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16072                .await
16073            {
16074                Ok(token) => token,
16075                Err(e) => match dlg.token(e) {
16076                    Ok(token) => token,
16077                    Err(e) => {
16078                        dlg.finished(false);
16079                        return Err(common::Error::MissingToken(e));
16080                    }
16081                },
16082            };
16083            let mut req_result = {
16084                let client = &self.hub.client;
16085                dlg.pre_request();
16086                let mut req_builder = hyper::Request::builder()
16087                    .method(hyper::Method::GET)
16088                    .uri(url.as_str())
16089                    .header(USER_AGENT, self.hub._user_agent.clone());
16090
16091                if let Some(token) = token.as_ref() {
16092                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16093                }
16094
16095                let request = req_builder
16096                    .header(CONTENT_LENGTH, 0_u64)
16097                    .body(common::to_body::<String>(None));
16098
16099                client.request(request.unwrap()).await
16100            };
16101
16102            match req_result {
16103                Err(err) => {
16104                    if let common::Retry::After(d) = dlg.http_error(&err) {
16105                        sleep(d).await;
16106                        continue;
16107                    }
16108                    dlg.finished(false);
16109                    return Err(common::Error::HttpError(err));
16110                }
16111                Ok(res) => {
16112                    let (mut parts, body) = res.into_parts();
16113                    let mut body = common::Body::new(body);
16114                    if !parts.status.is_success() {
16115                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16116                        let error = serde_json::from_str(&common::to_string(&bytes));
16117                        let response = common::to_response(parts, bytes.into());
16118
16119                        if let common::Retry::After(d) =
16120                            dlg.http_failure(&response, error.as_ref().ok())
16121                        {
16122                            sleep(d).await;
16123                            continue;
16124                        }
16125
16126                        dlg.finished(false);
16127
16128                        return Err(match error {
16129                            Ok(value) => common::Error::BadRequest(value),
16130                            _ => common::Error::Failure(response),
16131                        });
16132                    }
16133                    let response = {
16134                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16135                        let encoded = common::to_string(&bytes);
16136                        match serde_json::from_str(&encoded) {
16137                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16138                            Err(error) => {
16139                                dlg.response_json_decode_error(&encoded, &error);
16140                                return Err(common::Error::JsonDecodeError(
16141                                    encoded.to_string(),
16142                                    error,
16143                                ));
16144                            }
16145                        }
16146                    };
16147
16148                    dlg.finished(true);
16149                    return Ok(response);
16150                }
16151            }
16152        }
16153    }
16154
16155    /// Account ID to retrieve filters for.
16156    ///
16157    /// Sets the *account id* path property to the given value.
16158    ///
16159    /// Even though the property as already been set when instantiating this call,
16160    /// we provide this method for API completeness.
16161    pub fn account_id(mut self, new_value: &str) -> ManagementFilterGetCall<'a, C> {
16162        self._account_id = new_value.to_string();
16163        self
16164    }
16165    /// Filter ID to retrieve filters for.
16166    ///
16167    /// Sets the *filter id* path property to the given value.
16168    ///
16169    /// Even though the property as already been set when instantiating this call,
16170    /// we provide this method for API completeness.
16171    pub fn filter_id(mut self, new_value: &str) -> ManagementFilterGetCall<'a, C> {
16172        self._filter_id = new_value.to_string();
16173        self
16174    }
16175    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16176    /// while executing the actual API request.
16177    ///
16178    /// ````text
16179    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16180    /// ````
16181    ///
16182    /// Sets the *delegate* property to the given value.
16183    pub fn delegate(
16184        mut self,
16185        new_value: &'a mut dyn common::Delegate,
16186    ) -> ManagementFilterGetCall<'a, C> {
16187        self._delegate = Some(new_value);
16188        self
16189    }
16190
16191    /// Set any additional parameter of the query string used in the request.
16192    /// It should be used to set parameters which are not yet available through their own
16193    /// setters.
16194    ///
16195    /// Please note that this method must not be used to set any of the known parameters
16196    /// which have their own setter method. If done anyway, the request will fail.
16197    ///
16198    /// # Additional Parameters
16199    ///
16200    /// * *alt* (query-string) - Data format for the response.
16201    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16202    /// * *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.
16203    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16204    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16205    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16206    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16207    pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterGetCall<'a, C>
16208    where
16209        T: AsRef<str>,
16210    {
16211        self._additional_params
16212            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16213        self
16214    }
16215
16216    /// Identifies the authorization scope for the method you are building.
16217    ///
16218    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16219    /// [`Scope::Readonly`].
16220    ///
16221    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16222    /// tokens for more than one scope.
16223    ///
16224    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16225    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16226    /// sufficient, a read-write scope will do as well.
16227    pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterGetCall<'a, C>
16228    where
16229        St: AsRef<str>,
16230    {
16231        self._scopes.insert(String::from(scope.as_ref()));
16232        self
16233    }
16234    /// Identifies the authorization scope(s) for the method you are building.
16235    ///
16236    /// See [`Self::add_scope()`] for details.
16237    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterGetCall<'a, C>
16238    where
16239        I: IntoIterator<Item = St>,
16240        St: AsRef<str>,
16241    {
16242        self._scopes
16243            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16244        self
16245    }
16246
16247    /// Removes all scopes, and no default scope will be used either.
16248    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16249    /// for details).
16250    pub fn clear_scopes(mut self) -> ManagementFilterGetCall<'a, C> {
16251        self._scopes.clear();
16252        self
16253    }
16254}
16255
16256/// Create a new filter.
16257///
16258/// A builder for the *filters.insert* method supported by a *management* resource.
16259/// It is not used directly, but through a [`ManagementMethods`] instance.
16260///
16261/// # Example
16262///
16263/// Instantiate a resource method builder
16264///
16265/// ```test_harness,no_run
16266/// # extern crate hyper;
16267/// # extern crate hyper_rustls;
16268/// # extern crate google_analytics3 as analytics3;
16269/// use analytics3::api::Filter;
16270/// # async fn dox() {
16271/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16272///
16273/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16274/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16275/// #     .with_native_roots()
16276/// #     .unwrap()
16277/// #     .https_only()
16278/// #     .enable_http2()
16279/// #     .build();
16280///
16281/// # let executor = hyper_util::rt::TokioExecutor::new();
16282/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16283/// #     secret,
16284/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16285/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16286/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16287/// #     ),
16288/// # ).build().await.unwrap();
16289///
16290/// # let client = hyper_util::client::legacy::Client::builder(
16291/// #     hyper_util::rt::TokioExecutor::new()
16292/// # )
16293/// # .build(
16294/// #     hyper_rustls::HttpsConnectorBuilder::new()
16295/// #         .with_native_roots()
16296/// #         .unwrap()
16297/// #         .https_or_http()
16298/// #         .enable_http2()
16299/// #         .build()
16300/// # );
16301/// # let mut hub = Analytics::new(client, auth);
16302/// // As the method needs a request, you would usually fill it with the desired information
16303/// // into the respective structure. Some of the parts shown here might not be applicable !
16304/// // Values shown here are possibly random and not representative !
16305/// let mut req = Filter::default();
16306///
16307/// // You can configure optional parameters by calling the respective setters at will, and
16308/// // execute the final call using `doit()`.
16309/// // Values shown here are possibly random and not representative !
16310/// let result = hub.management().filters_insert(req, "accountId")
16311///              .doit().await;
16312/// # }
16313/// ```
16314pub struct ManagementFilterInsertCall<'a, C>
16315where
16316    C: 'a,
16317{
16318    hub: &'a Analytics<C>,
16319    _request: Filter,
16320    _account_id: String,
16321    _delegate: Option<&'a mut dyn common::Delegate>,
16322    _additional_params: HashMap<String, String>,
16323    _scopes: BTreeSet<String>,
16324}
16325
16326impl<'a, C> common::CallBuilder for ManagementFilterInsertCall<'a, C> {}
16327
16328impl<'a, C> ManagementFilterInsertCall<'a, C>
16329where
16330    C: common::Connector,
16331{
16332    /// Perform the operation you have build so far.
16333    pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
16334        use std::borrow::Cow;
16335        use std::io::{Read, Seek};
16336
16337        use common::{url::Params, ToParts};
16338        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16339
16340        let mut dd = common::DefaultDelegate;
16341        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16342        dlg.begin(common::MethodInfo {
16343            id: "analytics.management.filters.insert",
16344            http_method: hyper::Method::POST,
16345        });
16346
16347        for &field in ["alt", "accountId"].iter() {
16348            if self._additional_params.contains_key(field) {
16349                dlg.finished(false);
16350                return Err(common::Error::FieldClash(field));
16351            }
16352        }
16353
16354        let mut params = Params::with_capacity(4 + self._additional_params.len());
16355        params.push("accountId", self._account_id);
16356
16357        params.extend(self._additional_params.iter());
16358
16359        params.push("alt", "json");
16360        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/filters";
16361        if self._scopes.is_empty() {
16362            self._scopes.insert(Scope::Edit.as_ref().to_string());
16363        }
16364
16365        #[allow(clippy::single_element_loop)]
16366        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
16367            url = params.uri_replacement(url, param_name, find_this, false);
16368        }
16369        {
16370            let to_remove = ["accountId"];
16371            params.remove_params(&to_remove);
16372        }
16373
16374        let url = params.parse_with_url(&url);
16375
16376        let mut json_mime_type = mime::APPLICATION_JSON;
16377        let mut request_value_reader = {
16378            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16379            common::remove_json_null_values(&mut value);
16380            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16381            serde_json::to_writer(&mut dst, &value).unwrap();
16382            dst
16383        };
16384        let request_size = request_value_reader
16385            .seek(std::io::SeekFrom::End(0))
16386            .unwrap();
16387        request_value_reader
16388            .seek(std::io::SeekFrom::Start(0))
16389            .unwrap();
16390
16391        loop {
16392            let token = match self
16393                .hub
16394                .auth
16395                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16396                .await
16397            {
16398                Ok(token) => token,
16399                Err(e) => match dlg.token(e) {
16400                    Ok(token) => token,
16401                    Err(e) => {
16402                        dlg.finished(false);
16403                        return Err(common::Error::MissingToken(e));
16404                    }
16405                },
16406            };
16407            request_value_reader
16408                .seek(std::io::SeekFrom::Start(0))
16409                .unwrap();
16410            let mut req_result = {
16411                let client = &self.hub.client;
16412                dlg.pre_request();
16413                let mut req_builder = hyper::Request::builder()
16414                    .method(hyper::Method::POST)
16415                    .uri(url.as_str())
16416                    .header(USER_AGENT, self.hub._user_agent.clone());
16417
16418                if let Some(token) = token.as_ref() {
16419                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16420                }
16421
16422                let request = req_builder
16423                    .header(CONTENT_TYPE, json_mime_type.to_string())
16424                    .header(CONTENT_LENGTH, request_size as u64)
16425                    .body(common::to_body(
16426                        request_value_reader.get_ref().clone().into(),
16427                    ));
16428
16429                client.request(request.unwrap()).await
16430            };
16431
16432            match req_result {
16433                Err(err) => {
16434                    if let common::Retry::After(d) = dlg.http_error(&err) {
16435                        sleep(d).await;
16436                        continue;
16437                    }
16438                    dlg.finished(false);
16439                    return Err(common::Error::HttpError(err));
16440                }
16441                Ok(res) => {
16442                    let (mut parts, body) = res.into_parts();
16443                    let mut body = common::Body::new(body);
16444                    if !parts.status.is_success() {
16445                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16446                        let error = serde_json::from_str(&common::to_string(&bytes));
16447                        let response = common::to_response(parts, bytes.into());
16448
16449                        if let common::Retry::After(d) =
16450                            dlg.http_failure(&response, error.as_ref().ok())
16451                        {
16452                            sleep(d).await;
16453                            continue;
16454                        }
16455
16456                        dlg.finished(false);
16457
16458                        return Err(match error {
16459                            Ok(value) => common::Error::BadRequest(value),
16460                            _ => common::Error::Failure(response),
16461                        });
16462                    }
16463                    let response = {
16464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16465                        let encoded = common::to_string(&bytes);
16466                        match serde_json::from_str(&encoded) {
16467                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16468                            Err(error) => {
16469                                dlg.response_json_decode_error(&encoded, &error);
16470                                return Err(common::Error::JsonDecodeError(
16471                                    encoded.to_string(),
16472                                    error,
16473                                ));
16474                            }
16475                        }
16476                    };
16477
16478                    dlg.finished(true);
16479                    return Ok(response);
16480                }
16481            }
16482        }
16483    }
16484
16485    ///
16486    /// Sets the *request* property to the given value.
16487    ///
16488    /// Even though the property as already been set when instantiating this call,
16489    /// we provide this method for API completeness.
16490    pub fn request(mut self, new_value: Filter) -> ManagementFilterInsertCall<'a, C> {
16491        self._request = new_value;
16492        self
16493    }
16494    /// Account ID to create filter for.
16495    ///
16496    /// Sets the *account id* path property to the given value.
16497    ///
16498    /// Even though the property as already been set when instantiating this call,
16499    /// we provide this method for API completeness.
16500    pub fn account_id(mut self, new_value: &str) -> ManagementFilterInsertCall<'a, C> {
16501        self._account_id = new_value.to_string();
16502        self
16503    }
16504    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16505    /// while executing the actual API request.
16506    ///
16507    /// ````text
16508    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16509    /// ````
16510    ///
16511    /// Sets the *delegate* property to the given value.
16512    pub fn delegate(
16513        mut self,
16514        new_value: &'a mut dyn common::Delegate,
16515    ) -> ManagementFilterInsertCall<'a, C> {
16516        self._delegate = Some(new_value);
16517        self
16518    }
16519
16520    /// Set any additional parameter of the query string used in the request.
16521    /// It should be used to set parameters which are not yet available through their own
16522    /// setters.
16523    ///
16524    /// Please note that this method must not be used to set any of the known parameters
16525    /// which have their own setter method. If done anyway, the request will fail.
16526    ///
16527    /// # Additional Parameters
16528    ///
16529    /// * *alt* (query-string) - Data format for the response.
16530    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16531    /// * *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.
16532    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16533    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16534    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16535    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16536    pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterInsertCall<'a, C>
16537    where
16538        T: AsRef<str>,
16539    {
16540        self._additional_params
16541            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16542        self
16543    }
16544
16545    /// Identifies the authorization scope for the method you are building.
16546    ///
16547    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16548    /// [`Scope::Edit`].
16549    ///
16550    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16551    /// tokens for more than one scope.
16552    ///
16553    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16554    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16555    /// sufficient, a read-write scope will do as well.
16556    pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterInsertCall<'a, C>
16557    where
16558        St: AsRef<str>,
16559    {
16560        self._scopes.insert(String::from(scope.as_ref()));
16561        self
16562    }
16563    /// Identifies the authorization scope(s) for the method you are building.
16564    ///
16565    /// See [`Self::add_scope()`] for details.
16566    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterInsertCall<'a, C>
16567    where
16568        I: IntoIterator<Item = St>,
16569        St: AsRef<str>,
16570    {
16571        self._scopes
16572            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16573        self
16574    }
16575
16576    /// Removes all scopes, and no default scope will be used either.
16577    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16578    /// for details).
16579    pub fn clear_scopes(mut self) -> ManagementFilterInsertCall<'a, C> {
16580        self._scopes.clear();
16581        self
16582    }
16583}
16584
16585/// Lists all filters for an account
16586///
16587/// A builder for the *filters.list* method supported by a *management* resource.
16588/// It is not used directly, but through a [`ManagementMethods`] instance.
16589///
16590/// # Example
16591///
16592/// Instantiate a resource method builder
16593///
16594/// ```test_harness,no_run
16595/// # extern crate hyper;
16596/// # extern crate hyper_rustls;
16597/// # extern crate google_analytics3 as analytics3;
16598/// # async fn dox() {
16599/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16600///
16601/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16602/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16603/// #     .with_native_roots()
16604/// #     .unwrap()
16605/// #     .https_only()
16606/// #     .enable_http2()
16607/// #     .build();
16608///
16609/// # let executor = hyper_util::rt::TokioExecutor::new();
16610/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16611/// #     secret,
16612/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16613/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16614/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16615/// #     ),
16616/// # ).build().await.unwrap();
16617///
16618/// # let client = hyper_util::client::legacy::Client::builder(
16619/// #     hyper_util::rt::TokioExecutor::new()
16620/// # )
16621/// # .build(
16622/// #     hyper_rustls::HttpsConnectorBuilder::new()
16623/// #         .with_native_roots()
16624/// #         .unwrap()
16625/// #         .https_or_http()
16626/// #         .enable_http2()
16627/// #         .build()
16628/// # );
16629/// # let mut hub = Analytics::new(client, auth);
16630/// // You can configure optional parameters by calling the respective setters at will, and
16631/// // execute the final call using `doit()`.
16632/// // Values shown here are possibly random and not representative !
16633/// let result = hub.management().filters_list("accountId")
16634///              .start_index(-77)
16635///              .max_results(-45)
16636///              .doit().await;
16637/// # }
16638/// ```
16639pub struct ManagementFilterListCall<'a, C>
16640where
16641    C: 'a,
16642{
16643    hub: &'a Analytics<C>,
16644    _account_id: String,
16645    _start_index: Option<i32>,
16646    _max_results: Option<i32>,
16647    _delegate: Option<&'a mut dyn common::Delegate>,
16648    _additional_params: HashMap<String, String>,
16649    _scopes: BTreeSet<String>,
16650}
16651
16652impl<'a, C> common::CallBuilder for ManagementFilterListCall<'a, C> {}
16653
16654impl<'a, C> ManagementFilterListCall<'a, C>
16655where
16656    C: common::Connector,
16657{
16658    /// Perform the operation you have build so far.
16659    pub async fn doit(mut self) -> common::Result<(common::Response, Filters)> {
16660        use std::borrow::Cow;
16661        use std::io::{Read, Seek};
16662
16663        use common::{url::Params, ToParts};
16664        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16665
16666        let mut dd = common::DefaultDelegate;
16667        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16668        dlg.begin(common::MethodInfo {
16669            id: "analytics.management.filters.list",
16670            http_method: hyper::Method::GET,
16671        });
16672
16673        for &field in ["alt", "accountId", "start-index", "max-results"].iter() {
16674            if self._additional_params.contains_key(field) {
16675                dlg.finished(false);
16676                return Err(common::Error::FieldClash(field));
16677            }
16678        }
16679
16680        let mut params = Params::with_capacity(5 + self._additional_params.len());
16681        params.push("accountId", self._account_id);
16682        if let Some(value) = self._start_index.as_ref() {
16683            params.push("start-index", value.to_string());
16684        }
16685        if let Some(value) = self._max_results.as_ref() {
16686            params.push("max-results", value.to_string());
16687        }
16688
16689        params.extend(self._additional_params.iter());
16690
16691        params.push("alt", "json");
16692        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/filters";
16693        if self._scopes.is_empty() {
16694            self._scopes.insert(Scope::Readonly.as_ref().to_string());
16695        }
16696
16697        #[allow(clippy::single_element_loop)]
16698        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
16699            url = params.uri_replacement(url, param_name, find_this, false);
16700        }
16701        {
16702            let to_remove = ["accountId"];
16703            params.remove_params(&to_remove);
16704        }
16705
16706        let url = params.parse_with_url(&url);
16707
16708        loop {
16709            let token = match self
16710                .hub
16711                .auth
16712                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16713                .await
16714            {
16715                Ok(token) => token,
16716                Err(e) => match dlg.token(e) {
16717                    Ok(token) => token,
16718                    Err(e) => {
16719                        dlg.finished(false);
16720                        return Err(common::Error::MissingToken(e));
16721                    }
16722                },
16723            };
16724            let mut req_result = {
16725                let client = &self.hub.client;
16726                dlg.pre_request();
16727                let mut req_builder = hyper::Request::builder()
16728                    .method(hyper::Method::GET)
16729                    .uri(url.as_str())
16730                    .header(USER_AGENT, self.hub._user_agent.clone());
16731
16732                if let Some(token) = token.as_ref() {
16733                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16734                }
16735
16736                let request = req_builder
16737                    .header(CONTENT_LENGTH, 0_u64)
16738                    .body(common::to_body::<String>(None));
16739
16740                client.request(request.unwrap()).await
16741            };
16742
16743            match req_result {
16744                Err(err) => {
16745                    if let common::Retry::After(d) = dlg.http_error(&err) {
16746                        sleep(d).await;
16747                        continue;
16748                    }
16749                    dlg.finished(false);
16750                    return Err(common::Error::HttpError(err));
16751                }
16752                Ok(res) => {
16753                    let (mut parts, body) = res.into_parts();
16754                    let mut body = common::Body::new(body);
16755                    if !parts.status.is_success() {
16756                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16757                        let error = serde_json::from_str(&common::to_string(&bytes));
16758                        let response = common::to_response(parts, bytes.into());
16759
16760                        if let common::Retry::After(d) =
16761                            dlg.http_failure(&response, error.as_ref().ok())
16762                        {
16763                            sleep(d).await;
16764                            continue;
16765                        }
16766
16767                        dlg.finished(false);
16768
16769                        return Err(match error {
16770                            Ok(value) => common::Error::BadRequest(value),
16771                            _ => common::Error::Failure(response),
16772                        });
16773                    }
16774                    let response = {
16775                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16776                        let encoded = common::to_string(&bytes);
16777                        match serde_json::from_str(&encoded) {
16778                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16779                            Err(error) => {
16780                                dlg.response_json_decode_error(&encoded, &error);
16781                                return Err(common::Error::JsonDecodeError(
16782                                    encoded.to_string(),
16783                                    error,
16784                                ));
16785                            }
16786                        }
16787                    };
16788
16789                    dlg.finished(true);
16790                    return Ok(response);
16791                }
16792            }
16793        }
16794    }
16795
16796    /// Account ID to retrieve filters for.
16797    ///
16798    /// Sets the *account id* path property to the given value.
16799    ///
16800    /// Even though the property as already been set when instantiating this call,
16801    /// we provide this method for API completeness.
16802    pub fn account_id(mut self, new_value: &str) -> ManagementFilterListCall<'a, C> {
16803        self._account_id = new_value.to_string();
16804        self
16805    }
16806    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
16807    ///
16808    /// Sets the *start-index* query property to the given value.
16809    pub fn start_index(mut self, new_value: i32) -> ManagementFilterListCall<'a, C> {
16810        self._start_index = Some(new_value);
16811        self
16812    }
16813    /// The maximum number of filters to include in this response.
16814    ///
16815    /// Sets the *max-results* query property to the given value.
16816    pub fn max_results(mut self, new_value: i32) -> ManagementFilterListCall<'a, C> {
16817        self._max_results = Some(new_value);
16818        self
16819    }
16820    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16821    /// while executing the actual API request.
16822    ///
16823    /// ````text
16824    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16825    /// ````
16826    ///
16827    /// Sets the *delegate* property to the given value.
16828    pub fn delegate(
16829        mut self,
16830        new_value: &'a mut dyn common::Delegate,
16831    ) -> ManagementFilterListCall<'a, C> {
16832        self._delegate = Some(new_value);
16833        self
16834    }
16835
16836    /// Set any additional parameter of the query string used in the request.
16837    /// It should be used to set parameters which are not yet available through their own
16838    /// setters.
16839    ///
16840    /// Please note that this method must not be used to set any of the known parameters
16841    /// which have their own setter method. If done anyway, the request will fail.
16842    ///
16843    /// # Additional Parameters
16844    ///
16845    /// * *alt* (query-string) - Data format for the response.
16846    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16847    /// * *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.
16848    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16849    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16850    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16851    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16852    pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterListCall<'a, C>
16853    where
16854        T: AsRef<str>,
16855    {
16856        self._additional_params
16857            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16858        self
16859    }
16860
16861    /// Identifies the authorization scope for the method you are building.
16862    ///
16863    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16864    /// [`Scope::Readonly`].
16865    ///
16866    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16867    /// tokens for more than one scope.
16868    ///
16869    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16870    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16871    /// sufficient, a read-write scope will do as well.
16872    pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterListCall<'a, C>
16873    where
16874        St: AsRef<str>,
16875    {
16876        self._scopes.insert(String::from(scope.as_ref()));
16877        self
16878    }
16879    /// Identifies the authorization scope(s) for the method you are building.
16880    ///
16881    /// See [`Self::add_scope()`] for details.
16882    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterListCall<'a, C>
16883    where
16884        I: IntoIterator<Item = St>,
16885        St: AsRef<str>,
16886    {
16887        self._scopes
16888            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16889        self
16890    }
16891
16892    /// Removes all scopes, and no default scope will be used either.
16893    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16894    /// for details).
16895    pub fn clear_scopes(mut self) -> ManagementFilterListCall<'a, C> {
16896        self._scopes.clear();
16897        self
16898    }
16899}
16900
16901/// Updates an existing filter. This method supports patch semantics.
16902///
16903/// A builder for the *filters.patch* method supported by a *management* resource.
16904/// It is not used directly, but through a [`ManagementMethods`] instance.
16905///
16906/// # Example
16907///
16908/// Instantiate a resource method builder
16909///
16910/// ```test_harness,no_run
16911/// # extern crate hyper;
16912/// # extern crate hyper_rustls;
16913/// # extern crate google_analytics3 as analytics3;
16914/// use analytics3::api::Filter;
16915/// # async fn dox() {
16916/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16917///
16918/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16919/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16920/// #     .with_native_roots()
16921/// #     .unwrap()
16922/// #     .https_only()
16923/// #     .enable_http2()
16924/// #     .build();
16925///
16926/// # let executor = hyper_util::rt::TokioExecutor::new();
16927/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16928/// #     secret,
16929/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16930/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16931/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16932/// #     ),
16933/// # ).build().await.unwrap();
16934///
16935/// # let client = hyper_util::client::legacy::Client::builder(
16936/// #     hyper_util::rt::TokioExecutor::new()
16937/// # )
16938/// # .build(
16939/// #     hyper_rustls::HttpsConnectorBuilder::new()
16940/// #         .with_native_roots()
16941/// #         .unwrap()
16942/// #         .https_or_http()
16943/// #         .enable_http2()
16944/// #         .build()
16945/// # );
16946/// # let mut hub = Analytics::new(client, auth);
16947/// // As the method needs a request, you would usually fill it with the desired information
16948/// // into the respective structure. Some of the parts shown here might not be applicable !
16949/// // Values shown here are possibly random and not representative !
16950/// let mut req = Filter::default();
16951///
16952/// // You can configure optional parameters by calling the respective setters at will, and
16953/// // execute the final call using `doit()`.
16954/// // Values shown here are possibly random and not representative !
16955/// let result = hub.management().filters_patch(req, "accountId", "filterId")
16956///              .doit().await;
16957/// # }
16958/// ```
16959pub struct ManagementFilterPatchCall<'a, C>
16960where
16961    C: 'a,
16962{
16963    hub: &'a Analytics<C>,
16964    _request: Filter,
16965    _account_id: String,
16966    _filter_id: String,
16967    _delegate: Option<&'a mut dyn common::Delegate>,
16968    _additional_params: HashMap<String, String>,
16969    _scopes: BTreeSet<String>,
16970}
16971
16972impl<'a, C> common::CallBuilder for ManagementFilterPatchCall<'a, C> {}
16973
16974impl<'a, C> ManagementFilterPatchCall<'a, C>
16975where
16976    C: common::Connector,
16977{
16978    /// Perform the operation you have build so far.
16979    pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
16980        use std::borrow::Cow;
16981        use std::io::{Read, Seek};
16982
16983        use common::{url::Params, ToParts};
16984        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16985
16986        let mut dd = common::DefaultDelegate;
16987        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16988        dlg.begin(common::MethodInfo {
16989            id: "analytics.management.filters.patch",
16990            http_method: hyper::Method::PATCH,
16991        });
16992
16993        for &field in ["alt", "accountId", "filterId"].iter() {
16994            if self._additional_params.contains_key(field) {
16995                dlg.finished(false);
16996                return Err(common::Error::FieldClash(field));
16997            }
16998        }
16999
17000        let mut params = Params::with_capacity(5 + self._additional_params.len());
17001        params.push("accountId", self._account_id);
17002        params.push("filterId", self._filter_id);
17003
17004        params.extend(self._additional_params.iter());
17005
17006        params.push("alt", "json");
17007        let mut url =
17008            self.hub._base_url.clone() + "management/accounts/{accountId}/filters/{filterId}";
17009        if self._scopes.is_empty() {
17010            self._scopes.insert(Scope::Edit.as_ref().to_string());
17011        }
17012
17013        #[allow(clippy::single_element_loop)]
17014        for &(find_this, param_name) in
17015            [("{accountId}", "accountId"), ("{filterId}", "filterId")].iter()
17016        {
17017            url = params.uri_replacement(url, param_name, find_this, false);
17018        }
17019        {
17020            let to_remove = ["filterId", "accountId"];
17021            params.remove_params(&to_remove);
17022        }
17023
17024        let url = params.parse_with_url(&url);
17025
17026        let mut json_mime_type = mime::APPLICATION_JSON;
17027        let mut request_value_reader = {
17028            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17029            common::remove_json_null_values(&mut value);
17030            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17031            serde_json::to_writer(&mut dst, &value).unwrap();
17032            dst
17033        };
17034        let request_size = request_value_reader
17035            .seek(std::io::SeekFrom::End(0))
17036            .unwrap();
17037        request_value_reader
17038            .seek(std::io::SeekFrom::Start(0))
17039            .unwrap();
17040
17041        loop {
17042            let token = match self
17043                .hub
17044                .auth
17045                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17046                .await
17047            {
17048                Ok(token) => token,
17049                Err(e) => match dlg.token(e) {
17050                    Ok(token) => token,
17051                    Err(e) => {
17052                        dlg.finished(false);
17053                        return Err(common::Error::MissingToken(e));
17054                    }
17055                },
17056            };
17057            request_value_reader
17058                .seek(std::io::SeekFrom::Start(0))
17059                .unwrap();
17060            let mut req_result = {
17061                let client = &self.hub.client;
17062                dlg.pre_request();
17063                let mut req_builder = hyper::Request::builder()
17064                    .method(hyper::Method::PATCH)
17065                    .uri(url.as_str())
17066                    .header(USER_AGENT, self.hub._user_agent.clone());
17067
17068                if let Some(token) = token.as_ref() {
17069                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17070                }
17071
17072                let request = req_builder
17073                    .header(CONTENT_TYPE, json_mime_type.to_string())
17074                    .header(CONTENT_LENGTH, request_size as u64)
17075                    .body(common::to_body(
17076                        request_value_reader.get_ref().clone().into(),
17077                    ));
17078
17079                client.request(request.unwrap()).await
17080            };
17081
17082            match req_result {
17083                Err(err) => {
17084                    if let common::Retry::After(d) = dlg.http_error(&err) {
17085                        sleep(d).await;
17086                        continue;
17087                    }
17088                    dlg.finished(false);
17089                    return Err(common::Error::HttpError(err));
17090                }
17091                Ok(res) => {
17092                    let (mut parts, body) = res.into_parts();
17093                    let mut body = common::Body::new(body);
17094                    if !parts.status.is_success() {
17095                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17096                        let error = serde_json::from_str(&common::to_string(&bytes));
17097                        let response = common::to_response(parts, bytes.into());
17098
17099                        if let common::Retry::After(d) =
17100                            dlg.http_failure(&response, error.as_ref().ok())
17101                        {
17102                            sleep(d).await;
17103                            continue;
17104                        }
17105
17106                        dlg.finished(false);
17107
17108                        return Err(match error {
17109                            Ok(value) => common::Error::BadRequest(value),
17110                            _ => common::Error::Failure(response),
17111                        });
17112                    }
17113                    let response = {
17114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17115                        let encoded = common::to_string(&bytes);
17116                        match serde_json::from_str(&encoded) {
17117                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17118                            Err(error) => {
17119                                dlg.response_json_decode_error(&encoded, &error);
17120                                return Err(common::Error::JsonDecodeError(
17121                                    encoded.to_string(),
17122                                    error,
17123                                ));
17124                            }
17125                        }
17126                    };
17127
17128                    dlg.finished(true);
17129                    return Ok(response);
17130                }
17131            }
17132        }
17133    }
17134
17135    ///
17136    /// Sets the *request* property to the given value.
17137    ///
17138    /// Even though the property as already been set when instantiating this call,
17139    /// we provide this method for API completeness.
17140    pub fn request(mut self, new_value: Filter) -> ManagementFilterPatchCall<'a, C> {
17141        self._request = new_value;
17142        self
17143    }
17144    /// Account ID to which the filter belongs.
17145    ///
17146    /// Sets the *account id* path property to the given value.
17147    ///
17148    /// Even though the property as already been set when instantiating this call,
17149    /// we provide this method for API completeness.
17150    pub fn account_id(mut self, new_value: &str) -> ManagementFilterPatchCall<'a, C> {
17151        self._account_id = new_value.to_string();
17152        self
17153    }
17154    /// ID of the filter to be updated.
17155    ///
17156    /// Sets the *filter id* path property to the given value.
17157    ///
17158    /// Even though the property as already been set when instantiating this call,
17159    /// we provide this method for API completeness.
17160    pub fn filter_id(mut self, new_value: &str) -> ManagementFilterPatchCall<'a, C> {
17161        self._filter_id = new_value.to_string();
17162        self
17163    }
17164    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17165    /// while executing the actual API request.
17166    ///
17167    /// ````text
17168    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17169    /// ````
17170    ///
17171    /// Sets the *delegate* property to the given value.
17172    pub fn delegate(
17173        mut self,
17174        new_value: &'a mut dyn common::Delegate,
17175    ) -> ManagementFilterPatchCall<'a, C> {
17176        self._delegate = Some(new_value);
17177        self
17178    }
17179
17180    /// Set any additional parameter of the query string used in the request.
17181    /// It should be used to set parameters which are not yet available through their own
17182    /// setters.
17183    ///
17184    /// Please note that this method must not be used to set any of the known parameters
17185    /// which have their own setter method. If done anyway, the request will fail.
17186    ///
17187    /// # Additional Parameters
17188    ///
17189    /// * *alt* (query-string) - Data format for the response.
17190    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17191    /// * *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.
17192    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17193    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17194    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17195    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17196    pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterPatchCall<'a, C>
17197    where
17198        T: AsRef<str>,
17199    {
17200        self._additional_params
17201            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17202        self
17203    }
17204
17205    /// Identifies the authorization scope for the method you are building.
17206    ///
17207    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17208    /// [`Scope::Edit`].
17209    ///
17210    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17211    /// tokens for more than one scope.
17212    ///
17213    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17214    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17215    /// sufficient, a read-write scope will do as well.
17216    pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterPatchCall<'a, C>
17217    where
17218        St: AsRef<str>,
17219    {
17220        self._scopes.insert(String::from(scope.as_ref()));
17221        self
17222    }
17223    /// Identifies the authorization scope(s) for the method you are building.
17224    ///
17225    /// See [`Self::add_scope()`] for details.
17226    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterPatchCall<'a, C>
17227    where
17228        I: IntoIterator<Item = St>,
17229        St: AsRef<str>,
17230    {
17231        self._scopes
17232            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17233        self
17234    }
17235
17236    /// Removes all scopes, and no default scope will be used either.
17237    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17238    /// for details).
17239    pub fn clear_scopes(mut self) -> ManagementFilterPatchCall<'a, C> {
17240        self._scopes.clear();
17241        self
17242    }
17243}
17244
17245/// Updates an existing filter.
17246///
17247/// A builder for the *filters.update* method supported by a *management* resource.
17248/// It is not used directly, but through a [`ManagementMethods`] instance.
17249///
17250/// # Example
17251///
17252/// Instantiate a resource method builder
17253///
17254/// ```test_harness,no_run
17255/// # extern crate hyper;
17256/// # extern crate hyper_rustls;
17257/// # extern crate google_analytics3 as analytics3;
17258/// use analytics3::api::Filter;
17259/// # async fn dox() {
17260/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17261///
17262/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17263/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17264/// #     .with_native_roots()
17265/// #     .unwrap()
17266/// #     .https_only()
17267/// #     .enable_http2()
17268/// #     .build();
17269///
17270/// # let executor = hyper_util::rt::TokioExecutor::new();
17271/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17272/// #     secret,
17273/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17274/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17275/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17276/// #     ),
17277/// # ).build().await.unwrap();
17278///
17279/// # let client = hyper_util::client::legacy::Client::builder(
17280/// #     hyper_util::rt::TokioExecutor::new()
17281/// # )
17282/// # .build(
17283/// #     hyper_rustls::HttpsConnectorBuilder::new()
17284/// #         .with_native_roots()
17285/// #         .unwrap()
17286/// #         .https_or_http()
17287/// #         .enable_http2()
17288/// #         .build()
17289/// # );
17290/// # let mut hub = Analytics::new(client, auth);
17291/// // As the method needs a request, you would usually fill it with the desired information
17292/// // into the respective structure. Some of the parts shown here might not be applicable !
17293/// // Values shown here are possibly random and not representative !
17294/// let mut req = Filter::default();
17295///
17296/// // You can configure optional parameters by calling the respective setters at will, and
17297/// // execute the final call using `doit()`.
17298/// // Values shown here are possibly random and not representative !
17299/// let result = hub.management().filters_update(req, "accountId", "filterId")
17300///              .doit().await;
17301/// # }
17302/// ```
17303pub struct ManagementFilterUpdateCall<'a, C>
17304where
17305    C: 'a,
17306{
17307    hub: &'a Analytics<C>,
17308    _request: Filter,
17309    _account_id: String,
17310    _filter_id: String,
17311    _delegate: Option<&'a mut dyn common::Delegate>,
17312    _additional_params: HashMap<String, String>,
17313    _scopes: BTreeSet<String>,
17314}
17315
17316impl<'a, C> common::CallBuilder for ManagementFilterUpdateCall<'a, C> {}
17317
17318impl<'a, C> ManagementFilterUpdateCall<'a, C>
17319where
17320    C: common::Connector,
17321{
17322    /// Perform the operation you have build so far.
17323    pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
17324        use std::borrow::Cow;
17325        use std::io::{Read, Seek};
17326
17327        use common::{url::Params, ToParts};
17328        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17329
17330        let mut dd = common::DefaultDelegate;
17331        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17332        dlg.begin(common::MethodInfo {
17333            id: "analytics.management.filters.update",
17334            http_method: hyper::Method::PUT,
17335        });
17336
17337        for &field in ["alt", "accountId", "filterId"].iter() {
17338            if self._additional_params.contains_key(field) {
17339                dlg.finished(false);
17340                return Err(common::Error::FieldClash(field));
17341            }
17342        }
17343
17344        let mut params = Params::with_capacity(5 + self._additional_params.len());
17345        params.push("accountId", self._account_id);
17346        params.push("filterId", self._filter_id);
17347
17348        params.extend(self._additional_params.iter());
17349
17350        params.push("alt", "json");
17351        let mut url =
17352            self.hub._base_url.clone() + "management/accounts/{accountId}/filters/{filterId}";
17353        if self._scopes.is_empty() {
17354            self._scopes.insert(Scope::Edit.as_ref().to_string());
17355        }
17356
17357        #[allow(clippy::single_element_loop)]
17358        for &(find_this, param_name) in
17359            [("{accountId}", "accountId"), ("{filterId}", "filterId")].iter()
17360        {
17361            url = params.uri_replacement(url, param_name, find_this, false);
17362        }
17363        {
17364            let to_remove = ["filterId", "accountId"];
17365            params.remove_params(&to_remove);
17366        }
17367
17368        let url = params.parse_with_url(&url);
17369
17370        let mut json_mime_type = mime::APPLICATION_JSON;
17371        let mut request_value_reader = {
17372            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17373            common::remove_json_null_values(&mut value);
17374            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17375            serde_json::to_writer(&mut dst, &value).unwrap();
17376            dst
17377        };
17378        let request_size = request_value_reader
17379            .seek(std::io::SeekFrom::End(0))
17380            .unwrap();
17381        request_value_reader
17382            .seek(std::io::SeekFrom::Start(0))
17383            .unwrap();
17384
17385        loop {
17386            let token = match self
17387                .hub
17388                .auth
17389                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17390                .await
17391            {
17392                Ok(token) => token,
17393                Err(e) => match dlg.token(e) {
17394                    Ok(token) => token,
17395                    Err(e) => {
17396                        dlg.finished(false);
17397                        return Err(common::Error::MissingToken(e));
17398                    }
17399                },
17400            };
17401            request_value_reader
17402                .seek(std::io::SeekFrom::Start(0))
17403                .unwrap();
17404            let mut req_result = {
17405                let client = &self.hub.client;
17406                dlg.pre_request();
17407                let mut req_builder = hyper::Request::builder()
17408                    .method(hyper::Method::PUT)
17409                    .uri(url.as_str())
17410                    .header(USER_AGENT, self.hub._user_agent.clone());
17411
17412                if let Some(token) = token.as_ref() {
17413                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17414                }
17415
17416                let request = req_builder
17417                    .header(CONTENT_TYPE, json_mime_type.to_string())
17418                    .header(CONTENT_LENGTH, request_size as u64)
17419                    .body(common::to_body(
17420                        request_value_reader.get_ref().clone().into(),
17421                    ));
17422
17423                client.request(request.unwrap()).await
17424            };
17425
17426            match req_result {
17427                Err(err) => {
17428                    if let common::Retry::After(d) = dlg.http_error(&err) {
17429                        sleep(d).await;
17430                        continue;
17431                    }
17432                    dlg.finished(false);
17433                    return Err(common::Error::HttpError(err));
17434                }
17435                Ok(res) => {
17436                    let (mut parts, body) = res.into_parts();
17437                    let mut body = common::Body::new(body);
17438                    if !parts.status.is_success() {
17439                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17440                        let error = serde_json::from_str(&common::to_string(&bytes));
17441                        let response = common::to_response(parts, bytes.into());
17442
17443                        if let common::Retry::After(d) =
17444                            dlg.http_failure(&response, error.as_ref().ok())
17445                        {
17446                            sleep(d).await;
17447                            continue;
17448                        }
17449
17450                        dlg.finished(false);
17451
17452                        return Err(match error {
17453                            Ok(value) => common::Error::BadRequest(value),
17454                            _ => common::Error::Failure(response),
17455                        });
17456                    }
17457                    let response = {
17458                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17459                        let encoded = common::to_string(&bytes);
17460                        match serde_json::from_str(&encoded) {
17461                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17462                            Err(error) => {
17463                                dlg.response_json_decode_error(&encoded, &error);
17464                                return Err(common::Error::JsonDecodeError(
17465                                    encoded.to_string(),
17466                                    error,
17467                                ));
17468                            }
17469                        }
17470                    };
17471
17472                    dlg.finished(true);
17473                    return Ok(response);
17474                }
17475            }
17476        }
17477    }
17478
17479    ///
17480    /// Sets the *request* property to the given value.
17481    ///
17482    /// Even though the property as already been set when instantiating this call,
17483    /// we provide this method for API completeness.
17484    pub fn request(mut self, new_value: Filter) -> ManagementFilterUpdateCall<'a, C> {
17485        self._request = new_value;
17486        self
17487    }
17488    /// Account ID to which the filter belongs.
17489    ///
17490    /// Sets the *account id* path property to the given value.
17491    ///
17492    /// Even though the property as already been set when instantiating this call,
17493    /// we provide this method for API completeness.
17494    pub fn account_id(mut self, new_value: &str) -> ManagementFilterUpdateCall<'a, C> {
17495        self._account_id = new_value.to_string();
17496        self
17497    }
17498    /// ID of the filter to be updated.
17499    ///
17500    /// Sets the *filter id* path property to the given value.
17501    ///
17502    /// Even though the property as already been set when instantiating this call,
17503    /// we provide this method for API completeness.
17504    pub fn filter_id(mut self, new_value: &str) -> ManagementFilterUpdateCall<'a, C> {
17505        self._filter_id = new_value.to_string();
17506        self
17507    }
17508    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17509    /// while executing the actual API request.
17510    ///
17511    /// ````text
17512    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17513    /// ````
17514    ///
17515    /// Sets the *delegate* property to the given value.
17516    pub fn delegate(
17517        mut self,
17518        new_value: &'a mut dyn common::Delegate,
17519    ) -> ManagementFilterUpdateCall<'a, C> {
17520        self._delegate = Some(new_value);
17521        self
17522    }
17523
17524    /// Set any additional parameter of the query string used in the request.
17525    /// It should be used to set parameters which are not yet available through their own
17526    /// setters.
17527    ///
17528    /// Please note that this method must not be used to set any of the known parameters
17529    /// which have their own setter method. If done anyway, the request will fail.
17530    ///
17531    /// # Additional Parameters
17532    ///
17533    /// * *alt* (query-string) - Data format for the response.
17534    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17535    /// * *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.
17536    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17537    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17538    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17539    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17540    pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterUpdateCall<'a, C>
17541    where
17542        T: AsRef<str>,
17543    {
17544        self._additional_params
17545            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17546        self
17547    }
17548
17549    /// Identifies the authorization scope for the method you are building.
17550    ///
17551    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17552    /// [`Scope::Edit`].
17553    ///
17554    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17555    /// tokens for more than one scope.
17556    ///
17557    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17558    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17559    /// sufficient, a read-write scope will do as well.
17560    pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterUpdateCall<'a, C>
17561    where
17562        St: AsRef<str>,
17563    {
17564        self._scopes.insert(String::from(scope.as_ref()));
17565        self
17566    }
17567    /// Identifies the authorization scope(s) for the method you are building.
17568    ///
17569    /// See [`Self::add_scope()`] for details.
17570    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterUpdateCall<'a, C>
17571    where
17572        I: IntoIterator<Item = St>,
17573        St: AsRef<str>,
17574    {
17575        self._scopes
17576            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17577        self
17578    }
17579
17580    /// Removes all scopes, and no default scope will be used either.
17581    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17582    /// for details).
17583    pub fn clear_scopes(mut self) -> ManagementFilterUpdateCall<'a, C> {
17584        self._scopes.clear();
17585        self
17586    }
17587}
17588
17589/// Gets a goal to which the user has access.
17590///
17591/// A builder for the *goals.get* method supported by a *management* resource.
17592/// It is not used directly, but through a [`ManagementMethods`] instance.
17593///
17594/// # Example
17595///
17596/// Instantiate a resource method builder
17597///
17598/// ```test_harness,no_run
17599/// # extern crate hyper;
17600/// # extern crate hyper_rustls;
17601/// # extern crate google_analytics3 as analytics3;
17602/// # async fn dox() {
17603/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17604///
17605/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17606/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17607/// #     .with_native_roots()
17608/// #     .unwrap()
17609/// #     .https_only()
17610/// #     .enable_http2()
17611/// #     .build();
17612///
17613/// # let executor = hyper_util::rt::TokioExecutor::new();
17614/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17615/// #     secret,
17616/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17617/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17618/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17619/// #     ),
17620/// # ).build().await.unwrap();
17621///
17622/// # let client = hyper_util::client::legacy::Client::builder(
17623/// #     hyper_util::rt::TokioExecutor::new()
17624/// # )
17625/// # .build(
17626/// #     hyper_rustls::HttpsConnectorBuilder::new()
17627/// #         .with_native_roots()
17628/// #         .unwrap()
17629/// #         .https_or_http()
17630/// #         .enable_http2()
17631/// #         .build()
17632/// # );
17633/// # let mut hub = Analytics::new(client, auth);
17634/// // You can configure optional parameters by calling the respective setters at will, and
17635/// // execute the final call using `doit()`.
17636/// // Values shown here are possibly random and not representative !
17637/// let result = hub.management().goals_get("accountId", "webPropertyId", "profileId", "goalId")
17638///              .doit().await;
17639/// # }
17640/// ```
17641pub struct ManagementGoalGetCall<'a, C>
17642where
17643    C: 'a,
17644{
17645    hub: &'a Analytics<C>,
17646    _account_id: String,
17647    _web_property_id: String,
17648    _profile_id: String,
17649    _goal_id: String,
17650    _delegate: Option<&'a mut dyn common::Delegate>,
17651    _additional_params: HashMap<String, String>,
17652    _scopes: BTreeSet<String>,
17653}
17654
17655impl<'a, C> common::CallBuilder for ManagementGoalGetCall<'a, C> {}
17656
17657impl<'a, C> ManagementGoalGetCall<'a, C>
17658where
17659    C: common::Connector,
17660{
17661    /// Perform the operation you have build so far.
17662    pub async fn doit(mut self) -> common::Result<(common::Response, Goal)> {
17663        use std::borrow::Cow;
17664        use std::io::{Read, Seek};
17665
17666        use common::{url::Params, ToParts};
17667        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17668
17669        let mut dd = common::DefaultDelegate;
17670        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17671        dlg.begin(common::MethodInfo {
17672            id: "analytics.management.goals.get",
17673            http_method: hyper::Method::GET,
17674        });
17675
17676        for &field in ["alt", "accountId", "webPropertyId", "profileId", "goalId"].iter() {
17677            if self._additional_params.contains_key(field) {
17678                dlg.finished(false);
17679                return Err(common::Error::FieldClash(field));
17680            }
17681        }
17682
17683        let mut params = Params::with_capacity(6 + self._additional_params.len());
17684        params.push("accountId", self._account_id);
17685        params.push("webPropertyId", self._web_property_id);
17686        params.push("profileId", self._profile_id);
17687        params.push("goalId", self._goal_id);
17688
17689        params.extend(self._additional_params.iter());
17690
17691        params.push("alt", "json");
17692        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}";
17693        if self._scopes.is_empty() {
17694            self._scopes.insert(Scope::Readonly.as_ref().to_string());
17695        }
17696
17697        #[allow(clippy::single_element_loop)]
17698        for &(find_this, param_name) in [
17699            ("{accountId}", "accountId"),
17700            ("{webPropertyId}", "webPropertyId"),
17701            ("{profileId}", "profileId"),
17702            ("{goalId}", "goalId"),
17703        ]
17704        .iter()
17705        {
17706            url = params.uri_replacement(url, param_name, find_this, false);
17707        }
17708        {
17709            let to_remove = ["goalId", "profileId", "webPropertyId", "accountId"];
17710            params.remove_params(&to_remove);
17711        }
17712
17713        let url = params.parse_with_url(&url);
17714
17715        loop {
17716            let token = match self
17717                .hub
17718                .auth
17719                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17720                .await
17721            {
17722                Ok(token) => token,
17723                Err(e) => match dlg.token(e) {
17724                    Ok(token) => token,
17725                    Err(e) => {
17726                        dlg.finished(false);
17727                        return Err(common::Error::MissingToken(e));
17728                    }
17729                },
17730            };
17731            let mut req_result = {
17732                let client = &self.hub.client;
17733                dlg.pre_request();
17734                let mut req_builder = hyper::Request::builder()
17735                    .method(hyper::Method::GET)
17736                    .uri(url.as_str())
17737                    .header(USER_AGENT, self.hub._user_agent.clone());
17738
17739                if let Some(token) = token.as_ref() {
17740                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17741                }
17742
17743                let request = req_builder
17744                    .header(CONTENT_LENGTH, 0_u64)
17745                    .body(common::to_body::<String>(None));
17746
17747                client.request(request.unwrap()).await
17748            };
17749
17750            match req_result {
17751                Err(err) => {
17752                    if let common::Retry::After(d) = dlg.http_error(&err) {
17753                        sleep(d).await;
17754                        continue;
17755                    }
17756                    dlg.finished(false);
17757                    return Err(common::Error::HttpError(err));
17758                }
17759                Ok(res) => {
17760                    let (mut parts, body) = res.into_parts();
17761                    let mut body = common::Body::new(body);
17762                    if !parts.status.is_success() {
17763                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17764                        let error = serde_json::from_str(&common::to_string(&bytes));
17765                        let response = common::to_response(parts, bytes.into());
17766
17767                        if let common::Retry::After(d) =
17768                            dlg.http_failure(&response, error.as_ref().ok())
17769                        {
17770                            sleep(d).await;
17771                            continue;
17772                        }
17773
17774                        dlg.finished(false);
17775
17776                        return Err(match error {
17777                            Ok(value) => common::Error::BadRequest(value),
17778                            _ => common::Error::Failure(response),
17779                        });
17780                    }
17781                    let response = {
17782                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17783                        let encoded = common::to_string(&bytes);
17784                        match serde_json::from_str(&encoded) {
17785                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17786                            Err(error) => {
17787                                dlg.response_json_decode_error(&encoded, &error);
17788                                return Err(common::Error::JsonDecodeError(
17789                                    encoded.to_string(),
17790                                    error,
17791                                ));
17792                            }
17793                        }
17794                    };
17795
17796                    dlg.finished(true);
17797                    return Ok(response);
17798                }
17799            }
17800        }
17801    }
17802
17803    /// Account ID to retrieve the goal for.
17804    ///
17805    /// Sets the *account id* path property to the given value.
17806    ///
17807    /// Even though the property as already been set when instantiating this call,
17808    /// we provide this method for API completeness.
17809    pub fn account_id(mut self, new_value: &str) -> ManagementGoalGetCall<'a, C> {
17810        self._account_id = new_value.to_string();
17811        self
17812    }
17813    /// Web property ID to retrieve the goal for.
17814    ///
17815    /// Sets the *web property id* path property to the given value.
17816    ///
17817    /// Even though the property as already been set when instantiating this call,
17818    /// we provide this method for API completeness.
17819    pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalGetCall<'a, C> {
17820        self._web_property_id = new_value.to_string();
17821        self
17822    }
17823    /// View (Profile) ID to retrieve the goal for.
17824    ///
17825    /// Sets the *profile id* path property to the given value.
17826    ///
17827    /// Even though the property as already been set when instantiating this call,
17828    /// we provide this method for API completeness.
17829    pub fn profile_id(mut self, new_value: &str) -> ManagementGoalGetCall<'a, C> {
17830        self._profile_id = new_value.to_string();
17831        self
17832    }
17833    /// Goal ID to retrieve the goal for.
17834    ///
17835    /// Sets the *goal id* path property to the given value.
17836    ///
17837    /// Even though the property as already been set when instantiating this call,
17838    /// we provide this method for API completeness.
17839    pub fn goal_id(mut self, new_value: &str) -> ManagementGoalGetCall<'a, C> {
17840        self._goal_id = new_value.to_string();
17841        self
17842    }
17843    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17844    /// while executing the actual API request.
17845    ///
17846    /// ````text
17847    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17848    /// ````
17849    ///
17850    /// Sets the *delegate* property to the given value.
17851    pub fn delegate(
17852        mut self,
17853        new_value: &'a mut dyn common::Delegate,
17854    ) -> ManagementGoalGetCall<'a, C> {
17855        self._delegate = Some(new_value);
17856        self
17857    }
17858
17859    /// Set any additional parameter of the query string used in the request.
17860    /// It should be used to set parameters which are not yet available through their own
17861    /// setters.
17862    ///
17863    /// Please note that this method must not be used to set any of the known parameters
17864    /// which have their own setter method. If done anyway, the request will fail.
17865    ///
17866    /// # Additional Parameters
17867    ///
17868    /// * *alt* (query-string) - Data format for the response.
17869    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17870    /// * *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.
17871    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17872    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17873    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17874    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17875    pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalGetCall<'a, C>
17876    where
17877        T: AsRef<str>,
17878    {
17879        self._additional_params
17880            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17881        self
17882    }
17883
17884    /// Identifies the authorization scope for the method you are building.
17885    ///
17886    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17887    /// [`Scope::Readonly`].
17888    ///
17889    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17890    /// tokens for more than one scope.
17891    ///
17892    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17893    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17894    /// sufficient, a read-write scope will do as well.
17895    pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalGetCall<'a, C>
17896    where
17897        St: AsRef<str>,
17898    {
17899        self._scopes.insert(String::from(scope.as_ref()));
17900        self
17901    }
17902    /// Identifies the authorization scope(s) for the method you are building.
17903    ///
17904    /// See [`Self::add_scope()`] for details.
17905    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalGetCall<'a, C>
17906    where
17907        I: IntoIterator<Item = St>,
17908        St: AsRef<str>,
17909    {
17910        self._scopes
17911            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17912        self
17913    }
17914
17915    /// Removes all scopes, and no default scope will be used either.
17916    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17917    /// for details).
17918    pub fn clear_scopes(mut self) -> ManagementGoalGetCall<'a, C> {
17919        self._scopes.clear();
17920        self
17921    }
17922}
17923
17924/// Create a new goal.
17925///
17926/// A builder for the *goals.insert* method supported by a *management* resource.
17927/// It is not used directly, but through a [`ManagementMethods`] instance.
17928///
17929/// # Example
17930///
17931/// Instantiate a resource method builder
17932///
17933/// ```test_harness,no_run
17934/// # extern crate hyper;
17935/// # extern crate hyper_rustls;
17936/// # extern crate google_analytics3 as analytics3;
17937/// use analytics3::api::Goal;
17938/// # async fn dox() {
17939/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17940///
17941/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17942/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17943/// #     .with_native_roots()
17944/// #     .unwrap()
17945/// #     .https_only()
17946/// #     .enable_http2()
17947/// #     .build();
17948///
17949/// # let executor = hyper_util::rt::TokioExecutor::new();
17950/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17951/// #     secret,
17952/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17953/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17954/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17955/// #     ),
17956/// # ).build().await.unwrap();
17957///
17958/// # let client = hyper_util::client::legacy::Client::builder(
17959/// #     hyper_util::rt::TokioExecutor::new()
17960/// # )
17961/// # .build(
17962/// #     hyper_rustls::HttpsConnectorBuilder::new()
17963/// #         .with_native_roots()
17964/// #         .unwrap()
17965/// #         .https_or_http()
17966/// #         .enable_http2()
17967/// #         .build()
17968/// # );
17969/// # let mut hub = Analytics::new(client, auth);
17970/// // As the method needs a request, you would usually fill it with the desired information
17971/// // into the respective structure. Some of the parts shown here might not be applicable !
17972/// // Values shown here are possibly random and not representative !
17973/// let mut req = Goal::default();
17974///
17975/// // You can configure optional parameters by calling the respective setters at will, and
17976/// // execute the final call using `doit()`.
17977/// // Values shown here are possibly random and not representative !
17978/// let result = hub.management().goals_insert(req, "accountId", "webPropertyId", "profileId")
17979///              .doit().await;
17980/// # }
17981/// ```
17982pub struct ManagementGoalInsertCall<'a, C>
17983where
17984    C: 'a,
17985{
17986    hub: &'a Analytics<C>,
17987    _request: Goal,
17988    _account_id: String,
17989    _web_property_id: String,
17990    _profile_id: String,
17991    _delegate: Option<&'a mut dyn common::Delegate>,
17992    _additional_params: HashMap<String, String>,
17993    _scopes: BTreeSet<String>,
17994}
17995
17996impl<'a, C> common::CallBuilder for ManagementGoalInsertCall<'a, C> {}
17997
17998impl<'a, C> ManagementGoalInsertCall<'a, C>
17999where
18000    C: common::Connector,
18001{
18002    /// Perform the operation you have build so far.
18003    pub async fn doit(mut self) -> common::Result<(common::Response, Goal)> {
18004        use std::borrow::Cow;
18005        use std::io::{Read, Seek};
18006
18007        use common::{url::Params, ToParts};
18008        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18009
18010        let mut dd = common::DefaultDelegate;
18011        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18012        dlg.begin(common::MethodInfo {
18013            id: "analytics.management.goals.insert",
18014            http_method: hyper::Method::POST,
18015        });
18016
18017        for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
18018            if self._additional_params.contains_key(field) {
18019                dlg.finished(false);
18020                return Err(common::Error::FieldClash(field));
18021            }
18022        }
18023
18024        let mut params = Params::with_capacity(6 + self._additional_params.len());
18025        params.push("accountId", self._account_id);
18026        params.push("webPropertyId", self._web_property_id);
18027        params.push("profileId", self._profile_id);
18028
18029        params.extend(self._additional_params.iter());
18030
18031        params.push("alt", "json");
18032        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals";
18033        if self._scopes.is_empty() {
18034            self._scopes.insert(Scope::Edit.as_ref().to_string());
18035        }
18036
18037        #[allow(clippy::single_element_loop)]
18038        for &(find_this, param_name) in [
18039            ("{accountId}", "accountId"),
18040            ("{webPropertyId}", "webPropertyId"),
18041            ("{profileId}", "profileId"),
18042        ]
18043        .iter()
18044        {
18045            url = params.uri_replacement(url, param_name, find_this, false);
18046        }
18047        {
18048            let to_remove = ["profileId", "webPropertyId", "accountId"];
18049            params.remove_params(&to_remove);
18050        }
18051
18052        let url = params.parse_with_url(&url);
18053
18054        let mut json_mime_type = mime::APPLICATION_JSON;
18055        let mut request_value_reader = {
18056            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18057            common::remove_json_null_values(&mut value);
18058            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18059            serde_json::to_writer(&mut dst, &value).unwrap();
18060            dst
18061        };
18062        let request_size = request_value_reader
18063            .seek(std::io::SeekFrom::End(0))
18064            .unwrap();
18065        request_value_reader
18066            .seek(std::io::SeekFrom::Start(0))
18067            .unwrap();
18068
18069        loop {
18070            let token = match self
18071                .hub
18072                .auth
18073                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18074                .await
18075            {
18076                Ok(token) => token,
18077                Err(e) => match dlg.token(e) {
18078                    Ok(token) => token,
18079                    Err(e) => {
18080                        dlg.finished(false);
18081                        return Err(common::Error::MissingToken(e));
18082                    }
18083                },
18084            };
18085            request_value_reader
18086                .seek(std::io::SeekFrom::Start(0))
18087                .unwrap();
18088            let mut req_result = {
18089                let client = &self.hub.client;
18090                dlg.pre_request();
18091                let mut req_builder = hyper::Request::builder()
18092                    .method(hyper::Method::POST)
18093                    .uri(url.as_str())
18094                    .header(USER_AGENT, self.hub._user_agent.clone());
18095
18096                if let Some(token) = token.as_ref() {
18097                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18098                }
18099
18100                let request = req_builder
18101                    .header(CONTENT_TYPE, json_mime_type.to_string())
18102                    .header(CONTENT_LENGTH, request_size as u64)
18103                    .body(common::to_body(
18104                        request_value_reader.get_ref().clone().into(),
18105                    ));
18106
18107                client.request(request.unwrap()).await
18108            };
18109
18110            match req_result {
18111                Err(err) => {
18112                    if let common::Retry::After(d) = dlg.http_error(&err) {
18113                        sleep(d).await;
18114                        continue;
18115                    }
18116                    dlg.finished(false);
18117                    return Err(common::Error::HttpError(err));
18118                }
18119                Ok(res) => {
18120                    let (mut parts, body) = res.into_parts();
18121                    let mut body = common::Body::new(body);
18122                    if !parts.status.is_success() {
18123                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18124                        let error = serde_json::from_str(&common::to_string(&bytes));
18125                        let response = common::to_response(parts, bytes.into());
18126
18127                        if let common::Retry::After(d) =
18128                            dlg.http_failure(&response, error.as_ref().ok())
18129                        {
18130                            sleep(d).await;
18131                            continue;
18132                        }
18133
18134                        dlg.finished(false);
18135
18136                        return Err(match error {
18137                            Ok(value) => common::Error::BadRequest(value),
18138                            _ => common::Error::Failure(response),
18139                        });
18140                    }
18141                    let response = {
18142                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18143                        let encoded = common::to_string(&bytes);
18144                        match serde_json::from_str(&encoded) {
18145                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18146                            Err(error) => {
18147                                dlg.response_json_decode_error(&encoded, &error);
18148                                return Err(common::Error::JsonDecodeError(
18149                                    encoded.to_string(),
18150                                    error,
18151                                ));
18152                            }
18153                        }
18154                    };
18155
18156                    dlg.finished(true);
18157                    return Ok(response);
18158                }
18159            }
18160        }
18161    }
18162
18163    ///
18164    /// Sets the *request* property to the given value.
18165    ///
18166    /// Even though the property as already been set when instantiating this call,
18167    /// we provide this method for API completeness.
18168    pub fn request(mut self, new_value: Goal) -> ManagementGoalInsertCall<'a, C> {
18169        self._request = new_value;
18170        self
18171    }
18172    /// Account ID to create the goal for.
18173    ///
18174    /// Sets the *account id* path property to the given value.
18175    ///
18176    /// Even though the property as already been set when instantiating this call,
18177    /// we provide this method for API completeness.
18178    pub fn account_id(mut self, new_value: &str) -> ManagementGoalInsertCall<'a, C> {
18179        self._account_id = new_value.to_string();
18180        self
18181    }
18182    /// Web property ID to create the goal for.
18183    ///
18184    /// Sets the *web property id* path property to the given value.
18185    ///
18186    /// Even though the property as already been set when instantiating this call,
18187    /// we provide this method for API completeness.
18188    pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalInsertCall<'a, C> {
18189        self._web_property_id = new_value.to_string();
18190        self
18191    }
18192    /// View (Profile) ID to create the goal for.
18193    ///
18194    /// Sets the *profile id* path property to the given value.
18195    ///
18196    /// Even though the property as already been set when instantiating this call,
18197    /// we provide this method for API completeness.
18198    pub fn profile_id(mut self, new_value: &str) -> ManagementGoalInsertCall<'a, C> {
18199        self._profile_id = new_value.to_string();
18200        self
18201    }
18202    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18203    /// while executing the actual API request.
18204    ///
18205    /// ````text
18206    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18207    /// ````
18208    ///
18209    /// Sets the *delegate* property to the given value.
18210    pub fn delegate(
18211        mut self,
18212        new_value: &'a mut dyn common::Delegate,
18213    ) -> ManagementGoalInsertCall<'a, C> {
18214        self._delegate = Some(new_value);
18215        self
18216    }
18217
18218    /// Set any additional parameter of the query string used in the request.
18219    /// It should be used to set parameters which are not yet available through their own
18220    /// setters.
18221    ///
18222    /// Please note that this method must not be used to set any of the known parameters
18223    /// which have their own setter method. If done anyway, the request will fail.
18224    ///
18225    /// # Additional Parameters
18226    ///
18227    /// * *alt* (query-string) - Data format for the response.
18228    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18229    /// * *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.
18230    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18231    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18232    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18233    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18234    pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalInsertCall<'a, C>
18235    where
18236        T: AsRef<str>,
18237    {
18238        self._additional_params
18239            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18240        self
18241    }
18242
18243    /// Identifies the authorization scope for the method you are building.
18244    ///
18245    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18246    /// [`Scope::Edit`].
18247    ///
18248    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18249    /// tokens for more than one scope.
18250    ///
18251    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18252    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18253    /// sufficient, a read-write scope will do as well.
18254    pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalInsertCall<'a, C>
18255    where
18256        St: AsRef<str>,
18257    {
18258        self._scopes.insert(String::from(scope.as_ref()));
18259        self
18260    }
18261    /// Identifies the authorization scope(s) for the method you are building.
18262    ///
18263    /// See [`Self::add_scope()`] for details.
18264    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalInsertCall<'a, C>
18265    where
18266        I: IntoIterator<Item = St>,
18267        St: AsRef<str>,
18268    {
18269        self._scopes
18270            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18271        self
18272    }
18273
18274    /// Removes all scopes, and no default scope will be used either.
18275    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18276    /// for details).
18277    pub fn clear_scopes(mut self) -> ManagementGoalInsertCall<'a, C> {
18278        self._scopes.clear();
18279        self
18280    }
18281}
18282
18283/// Lists goals to which the user has access.
18284///
18285/// A builder for the *goals.list* method supported by a *management* resource.
18286/// It is not used directly, but through a [`ManagementMethods`] instance.
18287///
18288/// # Example
18289///
18290/// Instantiate a resource method builder
18291///
18292/// ```test_harness,no_run
18293/// # extern crate hyper;
18294/// # extern crate hyper_rustls;
18295/// # extern crate google_analytics3 as analytics3;
18296/// # async fn dox() {
18297/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18298///
18299/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18300/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18301/// #     .with_native_roots()
18302/// #     .unwrap()
18303/// #     .https_only()
18304/// #     .enable_http2()
18305/// #     .build();
18306///
18307/// # let executor = hyper_util::rt::TokioExecutor::new();
18308/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18309/// #     secret,
18310/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18311/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18312/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18313/// #     ),
18314/// # ).build().await.unwrap();
18315///
18316/// # let client = hyper_util::client::legacy::Client::builder(
18317/// #     hyper_util::rt::TokioExecutor::new()
18318/// # )
18319/// # .build(
18320/// #     hyper_rustls::HttpsConnectorBuilder::new()
18321/// #         .with_native_roots()
18322/// #         .unwrap()
18323/// #         .https_or_http()
18324/// #         .enable_http2()
18325/// #         .build()
18326/// # );
18327/// # let mut hub = Analytics::new(client, auth);
18328/// // You can configure optional parameters by calling the respective setters at will, and
18329/// // execute the final call using `doit()`.
18330/// // Values shown here are possibly random and not representative !
18331/// let result = hub.management().goals_list("accountId", "webPropertyId", "profileId")
18332///              .start_index(-94)
18333///              .max_results(-20)
18334///              .doit().await;
18335/// # }
18336/// ```
18337pub struct ManagementGoalListCall<'a, C>
18338where
18339    C: 'a,
18340{
18341    hub: &'a Analytics<C>,
18342    _account_id: String,
18343    _web_property_id: String,
18344    _profile_id: String,
18345    _start_index: Option<i32>,
18346    _max_results: Option<i32>,
18347    _delegate: Option<&'a mut dyn common::Delegate>,
18348    _additional_params: HashMap<String, String>,
18349    _scopes: BTreeSet<String>,
18350}
18351
18352impl<'a, C> common::CallBuilder for ManagementGoalListCall<'a, C> {}
18353
18354impl<'a, C> ManagementGoalListCall<'a, C>
18355where
18356    C: common::Connector,
18357{
18358    /// Perform the operation you have build so far.
18359    pub async fn doit(mut self) -> common::Result<(common::Response, Goals)> {
18360        use std::borrow::Cow;
18361        use std::io::{Read, Seek};
18362
18363        use common::{url::Params, ToParts};
18364        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18365
18366        let mut dd = common::DefaultDelegate;
18367        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18368        dlg.begin(common::MethodInfo {
18369            id: "analytics.management.goals.list",
18370            http_method: hyper::Method::GET,
18371        });
18372
18373        for &field in [
18374            "alt",
18375            "accountId",
18376            "webPropertyId",
18377            "profileId",
18378            "start-index",
18379            "max-results",
18380        ]
18381        .iter()
18382        {
18383            if self._additional_params.contains_key(field) {
18384                dlg.finished(false);
18385                return Err(common::Error::FieldClash(field));
18386            }
18387        }
18388
18389        let mut params = Params::with_capacity(7 + self._additional_params.len());
18390        params.push("accountId", self._account_id);
18391        params.push("webPropertyId", self._web_property_id);
18392        params.push("profileId", self._profile_id);
18393        if let Some(value) = self._start_index.as_ref() {
18394            params.push("start-index", value.to_string());
18395        }
18396        if let Some(value) = self._max_results.as_ref() {
18397            params.push("max-results", value.to_string());
18398        }
18399
18400        params.extend(self._additional_params.iter());
18401
18402        params.push("alt", "json");
18403        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals";
18404        if self._scopes.is_empty() {
18405            self._scopes.insert(Scope::Readonly.as_ref().to_string());
18406        }
18407
18408        #[allow(clippy::single_element_loop)]
18409        for &(find_this, param_name) in [
18410            ("{accountId}", "accountId"),
18411            ("{webPropertyId}", "webPropertyId"),
18412            ("{profileId}", "profileId"),
18413        ]
18414        .iter()
18415        {
18416            url = params.uri_replacement(url, param_name, find_this, false);
18417        }
18418        {
18419            let to_remove = ["profileId", "webPropertyId", "accountId"];
18420            params.remove_params(&to_remove);
18421        }
18422
18423        let url = params.parse_with_url(&url);
18424
18425        loop {
18426            let token = match self
18427                .hub
18428                .auth
18429                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18430                .await
18431            {
18432                Ok(token) => token,
18433                Err(e) => match dlg.token(e) {
18434                    Ok(token) => token,
18435                    Err(e) => {
18436                        dlg.finished(false);
18437                        return Err(common::Error::MissingToken(e));
18438                    }
18439                },
18440            };
18441            let mut req_result = {
18442                let client = &self.hub.client;
18443                dlg.pre_request();
18444                let mut req_builder = hyper::Request::builder()
18445                    .method(hyper::Method::GET)
18446                    .uri(url.as_str())
18447                    .header(USER_AGENT, self.hub._user_agent.clone());
18448
18449                if let Some(token) = token.as_ref() {
18450                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18451                }
18452
18453                let request = req_builder
18454                    .header(CONTENT_LENGTH, 0_u64)
18455                    .body(common::to_body::<String>(None));
18456
18457                client.request(request.unwrap()).await
18458            };
18459
18460            match req_result {
18461                Err(err) => {
18462                    if let common::Retry::After(d) = dlg.http_error(&err) {
18463                        sleep(d).await;
18464                        continue;
18465                    }
18466                    dlg.finished(false);
18467                    return Err(common::Error::HttpError(err));
18468                }
18469                Ok(res) => {
18470                    let (mut parts, body) = res.into_parts();
18471                    let mut body = common::Body::new(body);
18472                    if !parts.status.is_success() {
18473                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18474                        let error = serde_json::from_str(&common::to_string(&bytes));
18475                        let response = common::to_response(parts, bytes.into());
18476
18477                        if let common::Retry::After(d) =
18478                            dlg.http_failure(&response, error.as_ref().ok())
18479                        {
18480                            sleep(d).await;
18481                            continue;
18482                        }
18483
18484                        dlg.finished(false);
18485
18486                        return Err(match error {
18487                            Ok(value) => common::Error::BadRequest(value),
18488                            _ => common::Error::Failure(response),
18489                        });
18490                    }
18491                    let response = {
18492                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18493                        let encoded = common::to_string(&bytes);
18494                        match serde_json::from_str(&encoded) {
18495                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18496                            Err(error) => {
18497                                dlg.response_json_decode_error(&encoded, &error);
18498                                return Err(common::Error::JsonDecodeError(
18499                                    encoded.to_string(),
18500                                    error,
18501                                ));
18502                            }
18503                        }
18504                    };
18505
18506                    dlg.finished(true);
18507                    return Ok(response);
18508                }
18509            }
18510        }
18511    }
18512
18513    /// Account ID to retrieve goals for. Can either be a specific account ID or '~all', which refers to all the accounts that user has access to.
18514    ///
18515    /// Sets the *account id* path property to the given value.
18516    ///
18517    /// Even though the property as already been set when instantiating this call,
18518    /// we provide this method for API completeness.
18519    pub fn account_id(mut self, new_value: &str) -> ManagementGoalListCall<'a, C> {
18520        self._account_id = new_value.to_string();
18521        self
18522    }
18523    /// Web property ID to retrieve goals for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
18524    ///
18525    /// Sets the *web property id* path property to the given value.
18526    ///
18527    /// Even though the property as already been set when instantiating this call,
18528    /// we provide this method for API completeness.
18529    pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalListCall<'a, C> {
18530        self._web_property_id = new_value.to_string();
18531        self
18532    }
18533    /// View (Profile) ID to retrieve goals for. Can either be a specific view (profile) ID or '~all', which refers to all the views (profiles) that user has access to.
18534    ///
18535    /// Sets the *profile id* path property to the given value.
18536    ///
18537    /// Even though the property as already been set when instantiating this call,
18538    /// we provide this method for API completeness.
18539    pub fn profile_id(mut self, new_value: &str) -> ManagementGoalListCall<'a, C> {
18540        self._profile_id = new_value.to_string();
18541        self
18542    }
18543    /// An index of the first goal to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
18544    ///
18545    /// Sets the *start-index* query property to the given value.
18546    pub fn start_index(mut self, new_value: i32) -> ManagementGoalListCall<'a, C> {
18547        self._start_index = Some(new_value);
18548        self
18549    }
18550    /// The maximum number of goals to include in this response.
18551    ///
18552    /// Sets the *max-results* query property to the given value.
18553    pub fn max_results(mut self, new_value: i32) -> ManagementGoalListCall<'a, C> {
18554        self._max_results = Some(new_value);
18555        self
18556    }
18557    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18558    /// while executing the actual API request.
18559    ///
18560    /// ````text
18561    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18562    /// ````
18563    ///
18564    /// Sets the *delegate* property to the given value.
18565    pub fn delegate(
18566        mut self,
18567        new_value: &'a mut dyn common::Delegate,
18568    ) -> ManagementGoalListCall<'a, C> {
18569        self._delegate = Some(new_value);
18570        self
18571    }
18572
18573    /// Set any additional parameter of the query string used in the request.
18574    /// It should be used to set parameters which are not yet available through their own
18575    /// setters.
18576    ///
18577    /// Please note that this method must not be used to set any of the known parameters
18578    /// which have their own setter method. If done anyway, the request will fail.
18579    ///
18580    /// # Additional Parameters
18581    ///
18582    /// * *alt* (query-string) - Data format for the response.
18583    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18584    /// * *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.
18585    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18586    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18587    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18588    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18589    pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalListCall<'a, C>
18590    where
18591        T: AsRef<str>,
18592    {
18593        self._additional_params
18594            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18595        self
18596    }
18597
18598    /// Identifies the authorization scope for the method you are building.
18599    ///
18600    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18601    /// [`Scope::Readonly`].
18602    ///
18603    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18604    /// tokens for more than one scope.
18605    ///
18606    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18607    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18608    /// sufficient, a read-write scope will do as well.
18609    pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalListCall<'a, C>
18610    where
18611        St: AsRef<str>,
18612    {
18613        self._scopes.insert(String::from(scope.as_ref()));
18614        self
18615    }
18616    /// Identifies the authorization scope(s) for the method you are building.
18617    ///
18618    /// See [`Self::add_scope()`] for details.
18619    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalListCall<'a, C>
18620    where
18621        I: IntoIterator<Item = St>,
18622        St: AsRef<str>,
18623    {
18624        self._scopes
18625            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18626        self
18627    }
18628
18629    /// Removes all scopes, and no default scope will be used either.
18630    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18631    /// for details).
18632    pub fn clear_scopes(mut self) -> ManagementGoalListCall<'a, C> {
18633        self._scopes.clear();
18634        self
18635    }
18636}
18637
18638/// Updates an existing goal. This method supports patch semantics.
18639///
18640/// A builder for the *goals.patch* method supported by a *management* resource.
18641/// It is not used directly, but through a [`ManagementMethods`] instance.
18642///
18643/// # Example
18644///
18645/// Instantiate a resource method builder
18646///
18647/// ```test_harness,no_run
18648/// # extern crate hyper;
18649/// # extern crate hyper_rustls;
18650/// # extern crate google_analytics3 as analytics3;
18651/// use analytics3::api::Goal;
18652/// # async fn dox() {
18653/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18654///
18655/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18656/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18657/// #     .with_native_roots()
18658/// #     .unwrap()
18659/// #     .https_only()
18660/// #     .enable_http2()
18661/// #     .build();
18662///
18663/// # let executor = hyper_util::rt::TokioExecutor::new();
18664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18665/// #     secret,
18666/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18667/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18668/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18669/// #     ),
18670/// # ).build().await.unwrap();
18671///
18672/// # let client = hyper_util::client::legacy::Client::builder(
18673/// #     hyper_util::rt::TokioExecutor::new()
18674/// # )
18675/// # .build(
18676/// #     hyper_rustls::HttpsConnectorBuilder::new()
18677/// #         .with_native_roots()
18678/// #         .unwrap()
18679/// #         .https_or_http()
18680/// #         .enable_http2()
18681/// #         .build()
18682/// # );
18683/// # let mut hub = Analytics::new(client, auth);
18684/// // As the method needs a request, you would usually fill it with the desired information
18685/// // into the respective structure. Some of the parts shown here might not be applicable !
18686/// // Values shown here are possibly random and not representative !
18687/// let mut req = Goal::default();
18688///
18689/// // You can configure optional parameters by calling the respective setters at will, and
18690/// // execute the final call using `doit()`.
18691/// // Values shown here are possibly random and not representative !
18692/// let result = hub.management().goals_patch(req, "accountId", "webPropertyId", "profileId", "goalId")
18693///              .doit().await;
18694/// # }
18695/// ```
18696pub struct ManagementGoalPatchCall<'a, C>
18697where
18698    C: 'a,
18699{
18700    hub: &'a Analytics<C>,
18701    _request: Goal,
18702    _account_id: String,
18703    _web_property_id: String,
18704    _profile_id: String,
18705    _goal_id: String,
18706    _delegate: Option<&'a mut dyn common::Delegate>,
18707    _additional_params: HashMap<String, String>,
18708    _scopes: BTreeSet<String>,
18709}
18710
18711impl<'a, C> common::CallBuilder for ManagementGoalPatchCall<'a, C> {}
18712
18713impl<'a, C> ManagementGoalPatchCall<'a, C>
18714where
18715    C: common::Connector,
18716{
18717    /// Perform the operation you have build so far.
18718    pub async fn doit(mut self) -> common::Result<(common::Response, Goal)> {
18719        use std::borrow::Cow;
18720        use std::io::{Read, Seek};
18721
18722        use common::{url::Params, ToParts};
18723        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18724
18725        let mut dd = common::DefaultDelegate;
18726        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18727        dlg.begin(common::MethodInfo {
18728            id: "analytics.management.goals.patch",
18729            http_method: hyper::Method::PATCH,
18730        });
18731
18732        for &field in ["alt", "accountId", "webPropertyId", "profileId", "goalId"].iter() {
18733            if self._additional_params.contains_key(field) {
18734                dlg.finished(false);
18735                return Err(common::Error::FieldClash(field));
18736            }
18737        }
18738
18739        let mut params = Params::with_capacity(7 + self._additional_params.len());
18740        params.push("accountId", self._account_id);
18741        params.push("webPropertyId", self._web_property_id);
18742        params.push("profileId", self._profile_id);
18743        params.push("goalId", self._goal_id);
18744
18745        params.extend(self._additional_params.iter());
18746
18747        params.push("alt", "json");
18748        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}";
18749        if self._scopes.is_empty() {
18750            self._scopes.insert(Scope::Edit.as_ref().to_string());
18751        }
18752
18753        #[allow(clippy::single_element_loop)]
18754        for &(find_this, param_name) in [
18755            ("{accountId}", "accountId"),
18756            ("{webPropertyId}", "webPropertyId"),
18757            ("{profileId}", "profileId"),
18758            ("{goalId}", "goalId"),
18759        ]
18760        .iter()
18761        {
18762            url = params.uri_replacement(url, param_name, find_this, false);
18763        }
18764        {
18765            let to_remove = ["goalId", "profileId", "webPropertyId", "accountId"];
18766            params.remove_params(&to_remove);
18767        }
18768
18769        let url = params.parse_with_url(&url);
18770
18771        let mut json_mime_type = mime::APPLICATION_JSON;
18772        let mut request_value_reader = {
18773            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18774            common::remove_json_null_values(&mut value);
18775            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18776            serde_json::to_writer(&mut dst, &value).unwrap();
18777            dst
18778        };
18779        let request_size = request_value_reader
18780            .seek(std::io::SeekFrom::End(0))
18781            .unwrap();
18782        request_value_reader
18783            .seek(std::io::SeekFrom::Start(0))
18784            .unwrap();
18785
18786        loop {
18787            let token = match self
18788                .hub
18789                .auth
18790                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18791                .await
18792            {
18793                Ok(token) => token,
18794                Err(e) => match dlg.token(e) {
18795                    Ok(token) => token,
18796                    Err(e) => {
18797                        dlg.finished(false);
18798                        return Err(common::Error::MissingToken(e));
18799                    }
18800                },
18801            };
18802            request_value_reader
18803                .seek(std::io::SeekFrom::Start(0))
18804                .unwrap();
18805            let mut req_result = {
18806                let client = &self.hub.client;
18807                dlg.pre_request();
18808                let mut req_builder = hyper::Request::builder()
18809                    .method(hyper::Method::PATCH)
18810                    .uri(url.as_str())
18811                    .header(USER_AGENT, self.hub._user_agent.clone());
18812
18813                if let Some(token) = token.as_ref() {
18814                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18815                }
18816
18817                let request = req_builder
18818                    .header(CONTENT_TYPE, json_mime_type.to_string())
18819                    .header(CONTENT_LENGTH, request_size as u64)
18820                    .body(common::to_body(
18821                        request_value_reader.get_ref().clone().into(),
18822                    ));
18823
18824                client.request(request.unwrap()).await
18825            };
18826
18827            match req_result {
18828                Err(err) => {
18829                    if let common::Retry::After(d) = dlg.http_error(&err) {
18830                        sleep(d).await;
18831                        continue;
18832                    }
18833                    dlg.finished(false);
18834                    return Err(common::Error::HttpError(err));
18835                }
18836                Ok(res) => {
18837                    let (mut parts, body) = res.into_parts();
18838                    let mut body = common::Body::new(body);
18839                    if !parts.status.is_success() {
18840                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18841                        let error = serde_json::from_str(&common::to_string(&bytes));
18842                        let response = common::to_response(parts, bytes.into());
18843
18844                        if let common::Retry::After(d) =
18845                            dlg.http_failure(&response, error.as_ref().ok())
18846                        {
18847                            sleep(d).await;
18848                            continue;
18849                        }
18850
18851                        dlg.finished(false);
18852
18853                        return Err(match error {
18854                            Ok(value) => common::Error::BadRequest(value),
18855                            _ => common::Error::Failure(response),
18856                        });
18857                    }
18858                    let response = {
18859                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18860                        let encoded = common::to_string(&bytes);
18861                        match serde_json::from_str(&encoded) {
18862                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18863                            Err(error) => {
18864                                dlg.response_json_decode_error(&encoded, &error);
18865                                return Err(common::Error::JsonDecodeError(
18866                                    encoded.to_string(),
18867                                    error,
18868                                ));
18869                            }
18870                        }
18871                    };
18872
18873                    dlg.finished(true);
18874                    return Ok(response);
18875                }
18876            }
18877        }
18878    }
18879
18880    ///
18881    /// Sets the *request* property to the given value.
18882    ///
18883    /// Even though the property as already been set when instantiating this call,
18884    /// we provide this method for API completeness.
18885    pub fn request(mut self, new_value: Goal) -> ManagementGoalPatchCall<'a, C> {
18886        self._request = new_value;
18887        self
18888    }
18889    /// Account ID to update the goal.
18890    ///
18891    /// Sets the *account id* path property to the given value.
18892    ///
18893    /// Even though the property as already been set when instantiating this call,
18894    /// we provide this method for API completeness.
18895    pub fn account_id(mut self, new_value: &str) -> ManagementGoalPatchCall<'a, C> {
18896        self._account_id = new_value.to_string();
18897        self
18898    }
18899    /// Web property ID to update the goal.
18900    ///
18901    /// Sets the *web property id* path property to the given value.
18902    ///
18903    /// Even though the property as already been set when instantiating this call,
18904    /// we provide this method for API completeness.
18905    pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalPatchCall<'a, C> {
18906        self._web_property_id = new_value.to_string();
18907        self
18908    }
18909    /// View (Profile) ID to update the goal.
18910    ///
18911    /// Sets the *profile id* path property to the given value.
18912    ///
18913    /// Even though the property as already been set when instantiating this call,
18914    /// we provide this method for API completeness.
18915    pub fn profile_id(mut self, new_value: &str) -> ManagementGoalPatchCall<'a, C> {
18916        self._profile_id = new_value.to_string();
18917        self
18918    }
18919    /// Index of the goal to be updated.
18920    ///
18921    /// Sets the *goal id* path property to the given value.
18922    ///
18923    /// Even though the property as already been set when instantiating this call,
18924    /// we provide this method for API completeness.
18925    pub fn goal_id(mut self, new_value: &str) -> ManagementGoalPatchCall<'a, C> {
18926        self._goal_id = new_value.to_string();
18927        self
18928    }
18929    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18930    /// while executing the actual API request.
18931    ///
18932    /// ````text
18933    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18934    /// ````
18935    ///
18936    /// Sets the *delegate* property to the given value.
18937    pub fn delegate(
18938        mut self,
18939        new_value: &'a mut dyn common::Delegate,
18940    ) -> ManagementGoalPatchCall<'a, C> {
18941        self._delegate = Some(new_value);
18942        self
18943    }
18944
18945    /// Set any additional parameter of the query string used in the request.
18946    /// It should be used to set parameters which are not yet available through their own
18947    /// setters.
18948    ///
18949    /// Please note that this method must not be used to set any of the known parameters
18950    /// which have their own setter method. If done anyway, the request will fail.
18951    ///
18952    /// # Additional Parameters
18953    ///
18954    /// * *alt* (query-string) - Data format for the response.
18955    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18956    /// * *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.
18957    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18958    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18959    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18960    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18961    pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalPatchCall<'a, C>
18962    where
18963        T: AsRef<str>,
18964    {
18965        self._additional_params
18966            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18967        self
18968    }
18969
18970    /// Identifies the authorization scope for the method you are building.
18971    ///
18972    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18973    /// [`Scope::Edit`].
18974    ///
18975    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18976    /// tokens for more than one scope.
18977    ///
18978    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18979    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18980    /// sufficient, a read-write scope will do as well.
18981    pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalPatchCall<'a, C>
18982    where
18983        St: AsRef<str>,
18984    {
18985        self._scopes.insert(String::from(scope.as_ref()));
18986        self
18987    }
18988    /// Identifies the authorization scope(s) for the method you are building.
18989    ///
18990    /// See [`Self::add_scope()`] for details.
18991    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalPatchCall<'a, C>
18992    where
18993        I: IntoIterator<Item = St>,
18994        St: AsRef<str>,
18995    {
18996        self._scopes
18997            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18998        self
18999    }
19000
19001    /// Removes all scopes, and no default scope will be used either.
19002    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19003    /// for details).
19004    pub fn clear_scopes(mut self) -> ManagementGoalPatchCall<'a, C> {
19005        self._scopes.clear();
19006        self
19007    }
19008}
19009
19010/// Updates an existing goal.
19011///
19012/// A builder for the *goals.update* method supported by a *management* resource.
19013/// It is not used directly, but through a [`ManagementMethods`] instance.
19014///
19015/// # Example
19016///
19017/// Instantiate a resource method builder
19018///
19019/// ```test_harness,no_run
19020/// # extern crate hyper;
19021/// # extern crate hyper_rustls;
19022/// # extern crate google_analytics3 as analytics3;
19023/// use analytics3::api::Goal;
19024/// # async fn dox() {
19025/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19026///
19027/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19028/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19029/// #     .with_native_roots()
19030/// #     .unwrap()
19031/// #     .https_only()
19032/// #     .enable_http2()
19033/// #     .build();
19034///
19035/// # let executor = hyper_util::rt::TokioExecutor::new();
19036/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19037/// #     secret,
19038/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19039/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19040/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19041/// #     ),
19042/// # ).build().await.unwrap();
19043///
19044/// # let client = hyper_util::client::legacy::Client::builder(
19045/// #     hyper_util::rt::TokioExecutor::new()
19046/// # )
19047/// # .build(
19048/// #     hyper_rustls::HttpsConnectorBuilder::new()
19049/// #         .with_native_roots()
19050/// #         .unwrap()
19051/// #         .https_or_http()
19052/// #         .enable_http2()
19053/// #         .build()
19054/// # );
19055/// # let mut hub = Analytics::new(client, auth);
19056/// // As the method needs a request, you would usually fill it with the desired information
19057/// // into the respective structure. Some of the parts shown here might not be applicable !
19058/// // Values shown here are possibly random and not representative !
19059/// let mut req = Goal::default();
19060///
19061/// // You can configure optional parameters by calling the respective setters at will, and
19062/// // execute the final call using `doit()`.
19063/// // Values shown here are possibly random and not representative !
19064/// let result = hub.management().goals_update(req, "accountId", "webPropertyId", "profileId", "goalId")
19065///              .doit().await;
19066/// # }
19067/// ```
19068pub struct ManagementGoalUpdateCall<'a, C>
19069where
19070    C: 'a,
19071{
19072    hub: &'a Analytics<C>,
19073    _request: Goal,
19074    _account_id: String,
19075    _web_property_id: String,
19076    _profile_id: String,
19077    _goal_id: String,
19078    _delegate: Option<&'a mut dyn common::Delegate>,
19079    _additional_params: HashMap<String, String>,
19080    _scopes: BTreeSet<String>,
19081}
19082
19083impl<'a, C> common::CallBuilder for ManagementGoalUpdateCall<'a, C> {}
19084
19085impl<'a, C> ManagementGoalUpdateCall<'a, C>
19086where
19087    C: common::Connector,
19088{
19089    /// Perform the operation you have build so far.
19090    pub async fn doit(mut self) -> common::Result<(common::Response, Goal)> {
19091        use std::borrow::Cow;
19092        use std::io::{Read, Seek};
19093
19094        use common::{url::Params, ToParts};
19095        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19096
19097        let mut dd = common::DefaultDelegate;
19098        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19099        dlg.begin(common::MethodInfo {
19100            id: "analytics.management.goals.update",
19101            http_method: hyper::Method::PUT,
19102        });
19103
19104        for &field in ["alt", "accountId", "webPropertyId", "profileId", "goalId"].iter() {
19105            if self._additional_params.contains_key(field) {
19106                dlg.finished(false);
19107                return Err(common::Error::FieldClash(field));
19108            }
19109        }
19110
19111        let mut params = Params::with_capacity(7 + self._additional_params.len());
19112        params.push("accountId", self._account_id);
19113        params.push("webPropertyId", self._web_property_id);
19114        params.push("profileId", self._profile_id);
19115        params.push("goalId", self._goal_id);
19116
19117        params.extend(self._additional_params.iter());
19118
19119        params.push("alt", "json");
19120        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}";
19121        if self._scopes.is_empty() {
19122            self._scopes.insert(Scope::Edit.as_ref().to_string());
19123        }
19124
19125        #[allow(clippy::single_element_loop)]
19126        for &(find_this, param_name) in [
19127            ("{accountId}", "accountId"),
19128            ("{webPropertyId}", "webPropertyId"),
19129            ("{profileId}", "profileId"),
19130            ("{goalId}", "goalId"),
19131        ]
19132        .iter()
19133        {
19134            url = params.uri_replacement(url, param_name, find_this, false);
19135        }
19136        {
19137            let to_remove = ["goalId", "profileId", "webPropertyId", "accountId"];
19138            params.remove_params(&to_remove);
19139        }
19140
19141        let url = params.parse_with_url(&url);
19142
19143        let mut json_mime_type = mime::APPLICATION_JSON;
19144        let mut request_value_reader = {
19145            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19146            common::remove_json_null_values(&mut value);
19147            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19148            serde_json::to_writer(&mut dst, &value).unwrap();
19149            dst
19150        };
19151        let request_size = request_value_reader
19152            .seek(std::io::SeekFrom::End(0))
19153            .unwrap();
19154        request_value_reader
19155            .seek(std::io::SeekFrom::Start(0))
19156            .unwrap();
19157
19158        loop {
19159            let token = match self
19160                .hub
19161                .auth
19162                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19163                .await
19164            {
19165                Ok(token) => token,
19166                Err(e) => match dlg.token(e) {
19167                    Ok(token) => token,
19168                    Err(e) => {
19169                        dlg.finished(false);
19170                        return Err(common::Error::MissingToken(e));
19171                    }
19172                },
19173            };
19174            request_value_reader
19175                .seek(std::io::SeekFrom::Start(0))
19176                .unwrap();
19177            let mut req_result = {
19178                let client = &self.hub.client;
19179                dlg.pre_request();
19180                let mut req_builder = hyper::Request::builder()
19181                    .method(hyper::Method::PUT)
19182                    .uri(url.as_str())
19183                    .header(USER_AGENT, self.hub._user_agent.clone());
19184
19185                if let Some(token) = token.as_ref() {
19186                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19187                }
19188
19189                let request = req_builder
19190                    .header(CONTENT_TYPE, json_mime_type.to_string())
19191                    .header(CONTENT_LENGTH, request_size as u64)
19192                    .body(common::to_body(
19193                        request_value_reader.get_ref().clone().into(),
19194                    ));
19195
19196                client.request(request.unwrap()).await
19197            };
19198
19199            match req_result {
19200                Err(err) => {
19201                    if let common::Retry::After(d) = dlg.http_error(&err) {
19202                        sleep(d).await;
19203                        continue;
19204                    }
19205                    dlg.finished(false);
19206                    return Err(common::Error::HttpError(err));
19207                }
19208                Ok(res) => {
19209                    let (mut parts, body) = res.into_parts();
19210                    let mut body = common::Body::new(body);
19211                    if !parts.status.is_success() {
19212                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19213                        let error = serde_json::from_str(&common::to_string(&bytes));
19214                        let response = common::to_response(parts, bytes.into());
19215
19216                        if let common::Retry::After(d) =
19217                            dlg.http_failure(&response, error.as_ref().ok())
19218                        {
19219                            sleep(d).await;
19220                            continue;
19221                        }
19222
19223                        dlg.finished(false);
19224
19225                        return Err(match error {
19226                            Ok(value) => common::Error::BadRequest(value),
19227                            _ => common::Error::Failure(response),
19228                        });
19229                    }
19230                    let response = {
19231                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19232                        let encoded = common::to_string(&bytes);
19233                        match serde_json::from_str(&encoded) {
19234                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19235                            Err(error) => {
19236                                dlg.response_json_decode_error(&encoded, &error);
19237                                return Err(common::Error::JsonDecodeError(
19238                                    encoded.to_string(),
19239                                    error,
19240                                ));
19241                            }
19242                        }
19243                    };
19244
19245                    dlg.finished(true);
19246                    return Ok(response);
19247                }
19248            }
19249        }
19250    }
19251
19252    ///
19253    /// Sets the *request* property to the given value.
19254    ///
19255    /// Even though the property as already been set when instantiating this call,
19256    /// we provide this method for API completeness.
19257    pub fn request(mut self, new_value: Goal) -> ManagementGoalUpdateCall<'a, C> {
19258        self._request = new_value;
19259        self
19260    }
19261    /// Account ID to update the goal.
19262    ///
19263    /// Sets the *account id* path property to the given value.
19264    ///
19265    /// Even though the property as already been set when instantiating this call,
19266    /// we provide this method for API completeness.
19267    pub fn account_id(mut self, new_value: &str) -> ManagementGoalUpdateCall<'a, C> {
19268        self._account_id = new_value.to_string();
19269        self
19270    }
19271    /// Web property ID to update the goal.
19272    ///
19273    /// Sets the *web property id* path property to the given value.
19274    ///
19275    /// Even though the property as already been set when instantiating this call,
19276    /// we provide this method for API completeness.
19277    pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalUpdateCall<'a, C> {
19278        self._web_property_id = new_value.to_string();
19279        self
19280    }
19281    /// View (Profile) ID to update the goal.
19282    ///
19283    /// Sets the *profile id* path property to the given value.
19284    ///
19285    /// Even though the property as already been set when instantiating this call,
19286    /// we provide this method for API completeness.
19287    pub fn profile_id(mut self, new_value: &str) -> ManagementGoalUpdateCall<'a, C> {
19288        self._profile_id = new_value.to_string();
19289        self
19290    }
19291    /// Index of the goal to be updated.
19292    ///
19293    /// Sets the *goal id* path property to the given value.
19294    ///
19295    /// Even though the property as already been set when instantiating this call,
19296    /// we provide this method for API completeness.
19297    pub fn goal_id(mut self, new_value: &str) -> ManagementGoalUpdateCall<'a, C> {
19298        self._goal_id = new_value.to_string();
19299        self
19300    }
19301    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19302    /// while executing the actual API request.
19303    ///
19304    /// ````text
19305    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19306    /// ````
19307    ///
19308    /// Sets the *delegate* property to the given value.
19309    pub fn delegate(
19310        mut self,
19311        new_value: &'a mut dyn common::Delegate,
19312    ) -> ManagementGoalUpdateCall<'a, C> {
19313        self._delegate = Some(new_value);
19314        self
19315    }
19316
19317    /// Set any additional parameter of the query string used in the request.
19318    /// It should be used to set parameters which are not yet available through their own
19319    /// setters.
19320    ///
19321    /// Please note that this method must not be used to set any of the known parameters
19322    /// which have their own setter method. If done anyway, the request will fail.
19323    ///
19324    /// # Additional Parameters
19325    ///
19326    /// * *alt* (query-string) - Data format for the response.
19327    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19328    /// * *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.
19329    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19330    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19331    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19332    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19333    pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalUpdateCall<'a, C>
19334    where
19335        T: AsRef<str>,
19336    {
19337        self._additional_params
19338            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19339        self
19340    }
19341
19342    /// Identifies the authorization scope for the method you are building.
19343    ///
19344    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19345    /// [`Scope::Edit`].
19346    ///
19347    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19348    /// tokens for more than one scope.
19349    ///
19350    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19351    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19352    /// sufficient, a read-write scope will do as well.
19353    pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalUpdateCall<'a, C>
19354    where
19355        St: AsRef<str>,
19356    {
19357        self._scopes.insert(String::from(scope.as_ref()));
19358        self
19359    }
19360    /// Identifies the authorization scope(s) for the method you are building.
19361    ///
19362    /// See [`Self::add_scope()`] for details.
19363    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalUpdateCall<'a, C>
19364    where
19365        I: IntoIterator<Item = St>,
19366        St: AsRef<str>,
19367    {
19368        self._scopes
19369            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19370        self
19371    }
19372
19373    /// Removes all scopes, and no default scope will be used either.
19374    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19375    /// for details).
19376    pub fn clear_scopes(mut self) -> ManagementGoalUpdateCall<'a, C> {
19377        self._scopes.clear();
19378        self
19379    }
19380}
19381
19382/// Delete a profile filter link.
19383///
19384/// A builder for the *profileFilterLinks.delete* method supported by a *management* resource.
19385/// It is not used directly, but through a [`ManagementMethods`] instance.
19386///
19387/// # Example
19388///
19389/// Instantiate a resource method builder
19390///
19391/// ```test_harness,no_run
19392/// # extern crate hyper;
19393/// # extern crate hyper_rustls;
19394/// # extern crate google_analytics3 as analytics3;
19395/// # async fn dox() {
19396/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19397///
19398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19399/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19400/// #     .with_native_roots()
19401/// #     .unwrap()
19402/// #     .https_only()
19403/// #     .enable_http2()
19404/// #     .build();
19405///
19406/// # let executor = hyper_util::rt::TokioExecutor::new();
19407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19408/// #     secret,
19409/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19410/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19411/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19412/// #     ),
19413/// # ).build().await.unwrap();
19414///
19415/// # let client = hyper_util::client::legacy::Client::builder(
19416/// #     hyper_util::rt::TokioExecutor::new()
19417/// # )
19418/// # .build(
19419/// #     hyper_rustls::HttpsConnectorBuilder::new()
19420/// #         .with_native_roots()
19421/// #         .unwrap()
19422/// #         .https_or_http()
19423/// #         .enable_http2()
19424/// #         .build()
19425/// # );
19426/// # let mut hub = Analytics::new(client, auth);
19427/// // You can configure optional parameters by calling the respective setters at will, and
19428/// // execute the final call using `doit()`.
19429/// // Values shown here are possibly random and not representative !
19430/// let result = hub.management().profile_filter_links_delete("accountId", "webPropertyId", "profileId", "linkId")
19431///              .doit().await;
19432/// # }
19433/// ```
19434pub struct ManagementProfileFilterLinkDeleteCall<'a, C>
19435where
19436    C: 'a,
19437{
19438    hub: &'a Analytics<C>,
19439    _account_id: String,
19440    _web_property_id: String,
19441    _profile_id: String,
19442    _link_id: String,
19443    _delegate: Option<&'a mut dyn common::Delegate>,
19444    _additional_params: HashMap<String, String>,
19445    _scopes: BTreeSet<String>,
19446}
19447
19448impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkDeleteCall<'a, C> {}
19449
19450impl<'a, C> ManagementProfileFilterLinkDeleteCall<'a, C>
19451where
19452    C: common::Connector,
19453{
19454    /// Perform the operation you have build so far.
19455    pub async fn doit(mut self) -> common::Result<common::Response> {
19456        use std::borrow::Cow;
19457        use std::io::{Read, Seek};
19458
19459        use common::{url::Params, ToParts};
19460        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19461
19462        let mut dd = common::DefaultDelegate;
19463        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19464        dlg.begin(common::MethodInfo {
19465            id: "analytics.management.profileFilterLinks.delete",
19466            http_method: hyper::Method::DELETE,
19467        });
19468
19469        for &field in ["accountId", "webPropertyId", "profileId", "linkId"].iter() {
19470            if self._additional_params.contains_key(field) {
19471                dlg.finished(false);
19472                return Err(common::Error::FieldClash(field));
19473            }
19474        }
19475
19476        let mut params = Params::with_capacity(5 + self._additional_params.len());
19477        params.push("accountId", self._account_id);
19478        params.push("webPropertyId", self._web_property_id);
19479        params.push("profileId", self._profile_id);
19480        params.push("linkId", self._link_id);
19481
19482        params.extend(self._additional_params.iter());
19483
19484        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}";
19485        if self._scopes.is_empty() {
19486            self._scopes.insert(Scope::Edit.as_ref().to_string());
19487        }
19488
19489        #[allow(clippy::single_element_loop)]
19490        for &(find_this, param_name) in [
19491            ("{accountId}", "accountId"),
19492            ("{webPropertyId}", "webPropertyId"),
19493            ("{profileId}", "profileId"),
19494            ("{linkId}", "linkId"),
19495        ]
19496        .iter()
19497        {
19498            url = params.uri_replacement(url, param_name, find_this, false);
19499        }
19500        {
19501            let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
19502            params.remove_params(&to_remove);
19503        }
19504
19505        let url = params.parse_with_url(&url);
19506
19507        loop {
19508            let token = match self
19509                .hub
19510                .auth
19511                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19512                .await
19513            {
19514                Ok(token) => token,
19515                Err(e) => match dlg.token(e) {
19516                    Ok(token) => token,
19517                    Err(e) => {
19518                        dlg.finished(false);
19519                        return Err(common::Error::MissingToken(e));
19520                    }
19521                },
19522            };
19523            let mut req_result = {
19524                let client = &self.hub.client;
19525                dlg.pre_request();
19526                let mut req_builder = hyper::Request::builder()
19527                    .method(hyper::Method::DELETE)
19528                    .uri(url.as_str())
19529                    .header(USER_AGENT, self.hub._user_agent.clone());
19530
19531                if let Some(token) = token.as_ref() {
19532                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19533                }
19534
19535                let request = req_builder
19536                    .header(CONTENT_LENGTH, 0_u64)
19537                    .body(common::to_body::<String>(None));
19538
19539                client.request(request.unwrap()).await
19540            };
19541
19542            match req_result {
19543                Err(err) => {
19544                    if let common::Retry::After(d) = dlg.http_error(&err) {
19545                        sleep(d).await;
19546                        continue;
19547                    }
19548                    dlg.finished(false);
19549                    return Err(common::Error::HttpError(err));
19550                }
19551                Ok(res) => {
19552                    let (mut parts, body) = res.into_parts();
19553                    let mut body = common::Body::new(body);
19554                    if !parts.status.is_success() {
19555                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19556                        let error = serde_json::from_str(&common::to_string(&bytes));
19557                        let response = common::to_response(parts, bytes.into());
19558
19559                        if let common::Retry::After(d) =
19560                            dlg.http_failure(&response, error.as_ref().ok())
19561                        {
19562                            sleep(d).await;
19563                            continue;
19564                        }
19565
19566                        dlg.finished(false);
19567
19568                        return Err(match error {
19569                            Ok(value) => common::Error::BadRequest(value),
19570                            _ => common::Error::Failure(response),
19571                        });
19572                    }
19573                    let response = common::Response::from_parts(parts, body);
19574
19575                    dlg.finished(true);
19576                    return Ok(response);
19577                }
19578            }
19579        }
19580    }
19581
19582    /// Account ID to which the profile filter link belongs.
19583    ///
19584    /// Sets the *account id* path property to the given value.
19585    ///
19586    /// Even though the property as already been set when instantiating this call,
19587    /// we provide this method for API completeness.
19588    pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19589        self._account_id = new_value.to_string();
19590        self
19591    }
19592    /// Web property Id to which the profile filter link belongs.
19593    ///
19594    /// Sets the *web property id* path property to the given value.
19595    ///
19596    /// Even though the property as already been set when instantiating this call,
19597    /// we provide this method for API completeness.
19598    pub fn web_property_id(
19599        mut self,
19600        new_value: &str,
19601    ) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19602        self._web_property_id = new_value.to_string();
19603        self
19604    }
19605    /// Profile ID to which the filter link belongs.
19606    ///
19607    /// Sets the *profile id* path property to the given value.
19608    ///
19609    /// Even though the property as already been set when instantiating this call,
19610    /// we provide this method for API completeness.
19611    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19612        self._profile_id = new_value.to_string();
19613        self
19614    }
19615    /// ID of the profile filter link to delete.
19616    ///
19617    /// Sets the *link id* path property to the given value.
19618    ///
19619    /// Even though the property as already been set when instantiating this call,
19620    /// we provide this method for API completeness.
19621    pub fn link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19622        self._link_id = new_value.to_string();
19623        self
19624    }
19625    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19626    /// while executing the actual API request.
19627    ///
19628    /// ````text
19629    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19630    /// ````
19631    ///
19632    /// Sets the *delegate* property to the given value.
19633    pub fn delegate(
19634        mut self,
19635        new_value: &'a mut dyn common::Delegate,
19636    ) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19637        self._delegate = Some(new_value);
19638        self
19639    }
19640
19641    /// Set any additional parameter of the query string used in the request.
19642    /// It should be used to set parameters which are not yet available through their own
19643    /// setters.
19644    ///
19645    /// Please note that this method must not be used to set any of the known parameters
19646    /// which have their own setter method. If done anyway, the request will fail.
19647    ///
19648    /// # Additional Parameters
19649    ///
19650    /// * *alt* (query-string) - Data format for the response.
19651    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19652    /// * *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.
19653    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19654    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19655    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19656    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19657    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkDeleteCall<'a, C>
19658    where
19659        T: AsRef<str>,
19660    {
19661        self._additional_params
19662            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19663        self
19664    }
19665
19666    /// Identifies the authorization scope for the method you are building.
19667    ///
19668    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19669    /// [`Scope::Edit`].
19670    ///
19671    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19672    /// tokens for more than one scope.
19673    ///
19674    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19675    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19676    /// sufficient, a read-write scope will do as well.
19677    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkDeleteCall<'a, C>
19678    where
19679        St: AsRef<str>,
19680    {
19681        self._scopes.insert(String::from(scope.as_ref()));
19682        self
19683    }
19684    /// Identifies the authorization scope(s) for the method you are building.
19685    ///
19686    /// See [`Self::add_scope()`] for details.
19687    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkDeleteCall<'a, C>
19688    where
19689        I: IntoIterator<Item = St>,
19690        St: AsRef<str>,
19691    {
19692        self._scopes
19693            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19694        self
19695    }
19696
19697    /// Removes all scopes, and no default scope will be used either.
19698    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19699    /// for details).
19700    pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19701        self._scopes.clear();
19702        self
19703    }
19704}
19705
19706/// Returns a single profile filter link.
19707///
19708/// A builder for the *profileFilterLinks.get* method supported by a *management* resource.
19709/// It is not used directly, but through a [`ManagementMethods`] instance.
19710///
19711/// # Example
19712///
19713/// Instantiate a resource method builder
19714///
19715/// ```test_harness,no_run
19716/// # extern crate hyper;
19717/// # extern crate hyper_rustls;
19718/// # extern crate google_analytics3 as analytics3;
19719/// # async fn dox() {
19720/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19721///
19722/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19723/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19724/// #     .with_native_roots()
19725/// #     .unwrap()
19726/// #     .https_only()
19727/// #     .enable_http2()
19728/// #     .build();
19729///
19730/// # let executor = hyper_util::rt::TokioExecutor::new();
19731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19732/// #     secret,
19733/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19734/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19735/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19736/// #     ),
19737/// # ).build().await.unwrap();
19738///
19739/// # let client = hyper_util::client::legacy::Client::builder(
19740/// #     hyper_util::rt::TokioExecutor::new()
19741/// # )
19742/// # .build(
19743/// #     hyper_rustls::HttpsConnectorBuilder::new()
19744/// #         .with_native_roots()
19745/// #         .unwrap()
19746/// #         .https_or_http()
19747/// #         .enable_http2()
19748/// #         .build()
19749/// # );
19750/// # let mut hub = Analytics::new(client, auth);
19751/// // You can configure optional parameters by calling the respective setters at will, and
19752/// // execute the final call using `doit()`.
19753/// // Values shown here are possibly random and not representative !
19754/// let result = hub.management().profile_filter_links_get("accountId", "webPropertyId", "profileId", "linkId")
19755///              .doit().await;
19756/// # }
19757/// ```
19758pub struct ManagementProfileFilterLinkGetCall<'a, C>
19759where
19760    C: 'a,
19761{
19762    hub: &'a Analytics<C>,
19763    _account_id: String,
19764    _web_property_id: String,
19765    _profile_id: String,
19766    _link_id: String,
19767    _delegate: Option<&'a mut dyn common::Delegate>,
19768    _additional_params: HashMap<String, String>,
19769    _scopes: BTreeSet<String>,
19770}
19771
19772impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkGetCall<'a, C> {}
19773
19774impl<'a, C> ManagementProfileFilterLinkGetCall<'a, C>
19775where
19776    C: common::Connector,
19777{
19778    /// Perform the operation you have build so far.
19779    pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLink)> {
19780        use std::borrow::Cow;
19781        use std::io::{Read, Seek};
19782
19783        use common::{url::Params, ToParts};
19784        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19785
19786        let mut dd = common::DefaultDelegate;
19787        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19788        dlg.begin(common::MethodInfo {
19789            id: "analytics.management.profileFilterLinks.get",
19790            http_method: hyper::Method::GET,
19791        });
19792
19793        for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() {
19794            if self._additional_params.contains_key(field) {
19795                dlg.finished(false);
19796                return Err(common::Error::FieldClash(field));
19797            }
19798        }
19799
19800        let mut params = Params::with_capacity(6 + self._additional_params.len());
19801        params.push("accountId", self._account_id);
19802        params.push("webPropertyId", self._web_property_id);
19803        params.push("profileId", self._profile_id);
19804        params.push("linkId", self._link_id);
19805
19806        params.extend(self._additional_params.iter());
19807
19808        params.push("alt", "json");
19809        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}";
19810        if self._scopes.is_empty() {
19811            self._scopes.insert(Scope::Readonly.as_ref().to_string());
19812        }
19813
19814        #[allow(clippy::single_element_loop)]
19815        for &(find_this, param_name) in [
19816            ("{accountId}", "accountId"),
19817            ("{webPropertyId}", "webPropertyId"),
19818            ("{profileId}", "profileId"),
19819            ("{linkId}", "linkId"),
19820        ]
19821        .iter()
19822        {
19823            url = params.uri_replacement(url, param_name, find_this, false);
19824        }
19825        {
19826            let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
19827            params.remove_params(&to_remove);
19828        }
19829
19830        let url = params.parse_with_url(&url);
19831
19832        loop {
19833            let token = match self
19834                .hub
19835                .auth
19836                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19837                .await
19838            {
19839                Ok(token) => token,
19840                Err(e) => match dlg.token(e) {
19841                    Ok(token) => token,
19842                    Err(e) => {
19843                        dlg.finished(false);
19844                        return Err(common::Error::MissingToken(e));
19845                    }
19846                },
19847            };
19848            let mut req_result = {
19849                let client = &self.hub.client;
19850                dlg.pre_request();
19851                let mut req_builder = hyper::Request::builder()
19852                    .method(hyper::Method::GET)
19853                    .uri(url.as_str())
19854                    .header(USER_AGENT, self.hub._user_agent.clone());
19855
19856                if let Some(token) = token.as_ref() {
19857                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19858                }
19859
19860                let request = req_builder
19861                    .header(CONTENT_LENGTH, 0_u64)
19862                    .body(common::to_body::<String>(None));
19863
19864                client.request(request.unwrap()).await
19865            };
19866
19867            match req_result {
19868                Err(err) => {
19869                    if let common::Retry::After(d) = dlg.http_error(&err) {
19870                        sleep(d).await;
19871                        continue;
19872                    }
19873                    dlg.finished(false);
19874                    return Err(common::Error::HttpError(err));
19875                }
19876                Ok(res) => {
19877                    let (mut parts, body) = res.into_parts();
19878                    let mut body = common::Body::new(body);
19879                    if !parts.status.is_success() {
19880                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19881                        let error = serde_json::from_str(&common::to_string(&bytes));
19882                        let response = common::to_response(parts, bytes.into());
19883
19884                        if let common::Retry::After(d) =
19885                            dlg.http_failure(&response, error.as_ref().ok())
19886                        {
19887                            sleep(d).await;
19888                            continue;
19889                        }
19890
19891                        dlg.finished(false);
19892
19893                        return Err(match error {
19894                            Ok(value) => common::Error::BadRequest(value),
19895                            _ => common::Error::Failure(response),
19896                        });
19897                    }
19898                    let response = {
19899                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19900                        let encoded = common::to_string(&bytes);
19901                        match serde_json::from_str(&encoded) {
19902                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19903                            Err(error) => {
19904                                dlg.response_json_decode_error(&encoded, &error);
19905                                return Err(common::Error::JsonDecodeError(
19906                                    encoded.to_string(),
19907                                    error,
19908                                ));
19909                            }
19910                        }
19911                    };
19912
19913                    dlg.finished(true);
19914                    return Ok(response);
19915                }
19916            }
19917        }
19918    }
19919
19920    /// Account ID to retrieve profile filter link for.
19921    ///
19922    /// Sets the *account id* path property to the given value.
19923    ///
19924    /// Even though the property as already been set when instantiating this call,
19925    /// we provide this method for API completeness.
19926    pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C> {
19927        self._account_id = new_value.to_string();
19928        self
19929    }
19930    /// Web property Id to retrieve profile filter link for.
19931    ///
19932    /// Sets the *web property id* path property to the given value.
19933    ///
19934    /// Even though the property as already been set when instantiating this call,
19935    /// we provide this method for API completeness.
19936    pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C> {
19937        self._web_property_id = new_value.to_string();
19938        self
19939    }
19940    /// Profile ID to retrieve filter link for.
19941    ///
19942    /// Sets the *profile id* path property to the given value.
19943    ///
19944    /// Even though the property as already been set when instantiating this call,
19945    /// we provide this method for API completeness.
19946    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C> {
19947        self._profile_id = new_value.to_string();
19948        self
19949    }
19950    /// ID of the profile filter link.
19951    ///
19952    /// Sets the *link id* path property to the given value.
19953    ///
19954    /// Even though the property as already been set when instantiating this call,
19955    /// we provide this method for API completeness.
19956    pub fn link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C> {
19957        self._link_id = new_value.to_string();
19958        self
19959    }
19960    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19961    /// while executing the actual API request.
19962    ///
19963    /// ````text
19964    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19965    /// ````
19966    ///
19967    /// Sets the *delegate* property to the given value.
19968    pub fn delegate(
19969        mut self,
19970        new_value: &'a mut dyn common::Delegate,
19971    ) -> ManagementProfileFilterLinkGetCall<'a, C> {
19972        self._delegate = Some(new_value);
19973        self
19974    }
19975
19976    /// Set any additional parameter of the query string used in the request.
19977    /// It should be used to set parameters which are not yet available through their own
19978    /// setters.
19979    ///
19980    /// Please note that this method must not be used to set any of the known parameters
19981    /// which have their own setter method. If done anyway, the request will fail.
19982    ///
19983    /// # Additional Parameters
19984    ///
19985    /// * *alt* (query-string) - Data format for the response.
19986    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19987    /// * *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.
19988    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19989    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19990    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19991    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19992    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkGetCall<'a, C>
19993    where
19994        T: AsRef<str>,
19995    {
19996        self._additional_params
19997            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19998        self
19999    }
20000
20001    /// Identifies the authorization scope for the method you are building.
20002    ///
20003    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20004    /// [`Scope::Readonly`].
20005    ///
20006    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20007    /// tokens for more than one scope.
20008    ///
20009    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20010    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20011    /// sufficient, a read-write scope will do as well.
20012    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkGetCall<'a, C>
20013    where
20014        St: AsRef<str>,
20015    {
20016        self._scopes.insert(String::from(scope.as_ref()));
20017        self
20018    }
20019    /// Identifies the authorization scope(s) for the method you are building.
20020    ///
20021    /// See [`Self::add_scope()`] for details.
20022    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkGetCall<'a, C>
20023    where
20024        I: IntoIterator<Item = St>,
20025        St: AsRef<str>,
20026    {
20027        self._scopes
20028            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20029        self
20030    }
20031
20032    /// Removes all scopes, and no default scope will be used either.
20033    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20034    /// for details).
20035    pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkGetCall<'a, C> {
20036        self._scopes.clear();
20037        self
20038    }
20039}
20040
20041/// Create a new profile filter link.
20042///
20043/// A builder for the *profileFilterLinks.insert* method supported by a *management* resource.
20044/// It is not used directly, but through a [`ManagementMethods`] instance.
20045///
20046/// # Example
20047///
20048/// Instantiate a resource method builder
20049///
20050/// ```test_harness,no_run
20051/// # extern crate hyper;
20052/// # extern crate hyper_rustls;
20053/// # extern crate google_analytics3 as analytics3;
20054/// use analytics3::api::ProfileFilterLink;
20055/// # async fn dox() {
20056/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20057///
20058/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20059/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20060/// #     .with_native_roots()
20061/// #     .unwrap()
20062/// #     .https_only()
20063/// #     .enable_http2()
20064/// #     .build();
20065///
20066/// # let executor = hyper_util::rt::TokioExecutor::new();
20067/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20068/// #     secret,
20069/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20070/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20071/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20072/// #     ),
20073/// # ).build().await.unwrap();
20074///
20075/// # let client = hyper_util::client::legacy::Client::builder(
20076/// #     hyper_util::rt::TokioExecutor::new()
20077/// # )
20078/// # .build(
20079/// #     hyper_rustls::HttpsConnectorBuilder::new()
20080/// #         .with_native_roots()
20081/// #         .unwrap()
20082/// #         .https_or_http()
20083/// #         .enable_http2()
20084/// #         .build()
20085/// # );
20086/// # let mut hub = Analytics::new(client, auth);
20087/// // As the method needs a request, you would usually fill it with the desired information
20088/// // into the respective structure. Some of the parts shown here might not be applicable !
20089/// // Values shown here are possibly random and not representative !
20090/// let mut req = ProfileFilterLink::default();
20091///
20092/// // You can configure optional parameters by calling the respective setters at will, and
20093/// // execute the final call using `doit()`.
20094/// // Values shown here are possibly random and not representative !
20095/// let result = hub.management().profile_filter_links_insert(req, "accountId", "webPropertyId", "profileId")
20096///              .doit().await;
20097/// # }
20098/// ```
20099pub struct ManagementProfileFilterLinkInsertCall<'a, C>
20100where
20101    C: 'a,
20102{
20103    hub: &'a Analytics<C>,
20104    _request: ProfileFilterLink,
20105    _account_id: String,
20106    _web_property_id: String,
20107    _profile_id: String,
20108    _delegate: Option<&'a mut dyn common::Delegate>,
20109    _additional_params: HashMap<String, String>,
20110    _scopes: BTreeSet<String>,
20111}
20112
20113impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkInsertCall<'a, C> {}
20114
20115impl<'a, C> ManagementProfileFilterLinkInsertCall<'a, C>
20116where
20117    C: common::Connector,
20118{
20119    /// Perform the operation you have build so far.
20120    pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLink)> {
20121        use std::borrow::Cow;
20122        use std::io::{Read, Seek};
20123
20124        use common::{url::Params, ToParts};
20125        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20126
20127        let mut dd = common::DefaultDelegate;
20128        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20129        dlg.begin(common::MethodInfo {
20130            id: "analytics.management.profileFilterLinks.insert",
20131            http_method: hyper::Method::POST,
20132        });
20133
20134        for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
20135            if self._additional_params.contains_key(field) {
20136                dlg.finished(false);
20137                return Err(common::Error::FieldClash(field));
20138            }
20139        }
20140
20141        let mut params = Params::with_capacity(6 + self._additional_params.len());
20142        params.push("accountId", self._account_id);
20143        params.push("webPropertyId", self._web_property_id);
20144        params.push("profileId", self._profile_id);
20145
20146        params.extend(self._additional_params.iter());
20147
20148        params.push("alt", "json");
20149        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks";
20150        if self._scopes.is_empty() {
20151            self._scopes.insert(Scope::Edit.as_ref().to_string());
20152        }
20153
20154        #[allow(clippy::single_element_loop)]
20155        for &(find_this, param_name) in [
20156            ("{accountId}", "accountId"),
20157            ("{webPropertyId}", "webPropertyId"),
20158            ("{profileId}", "profileId"),
20159        ]
20160        .iter()
20161        {
20162            url = params.uri_replacement(url, param_name, find_this, false);
20163        }
20164        {
20165            let to_remove = ["profileId", "webPropertyId", "accountId"];
20166            params.remove_params(&to_remove);
20167        }
20168
20169        let url = params.parse_with_url(&url);
20170
20171        let mut json_mime_type = mime::APPLICATION_JSON;
20172        let mut request_value_reader = {
20173            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20174            common::remove_json_null_values(&mut value);
20175            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20176            serde_json::to_writer(&mut dst, &value).unwrap();
20177            dst
20178        };
20179        let request_size = request_value_reader
20180            .seek(std::io::SeekFrom::End(0))
20181            .unwrap();
20182        request_value_reader
20183            .seek(std::io::SeekFrom::Start(0))
20184            .unwrap();
20185
20186        loop {
20187            let token = match self
20188                .hub
20189                .auth
20190                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20191                .await
20192            {
20193                Ok(token) => token,
20194                Err(e) => match dlg.token(e) {
20195                    Ok(token) => token,
20196                    Err(e) => {
20197                        dlg.finished(false);
20198                        return Err(common::Error::MissingToken(e));
20199                    }
20200                },
20201            };
20202            request_value_reader
20203                .seek(std::io::SeekFrom::Start(0))
20204                .unwrap();
20205            let mut req_result = {
20206                let client = &self.hub.client;
20207                dlg.pre_request();
20208                let mut req_builder = hyper::Request::builder()
20209                    .method(hyper::Method::POST)
20210                    .uri(url.as_str())
20211                    .header(USER_AGENT, self.hub._user_agent.clone());
20212
20213                if let Some(token) = token.as_ref() {
20214                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20215                }
20216
20217                let request = req_builder
20218                    .header(CONTENT_TYPE, json_mime_type.to_string())
20219                    .header(CONTENT_LENGTH, request_size as u64)
20220                    .body(common::to_body(
20221                        request_value_reader.get_ref().clone().into(),
20222                    ));
20223
20224                client.request(request.unwrap()).await
20225            };
20226
20227            match req_result {
20228                Err(err) => {
20229                    if let common::Retry::After(d) = dlg.http_error(&err) {
20230                        sleep(d).await;
20231                        continue;
20232                    }
20233                    dlg.finished(false);
20234                    return Err(common::Error::HttpError(err));
20235                }
20236                Ok(res) => {
20237                    let (mut parts, body) = res.into_parts();
20238                    let mut body = common::Body::new(body);
20239                    if !parts.status.is_success() {
20240                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20241                        let error = serde_json::from_str(&common::to_string(&bytes));
20242                        let response = common::to_response(parts, bytes.into());
20243
20244                        if let common::Retry::After(d) =
20245                            dlg.http_failure(&response, error.as_ref().ok())
20246                        {
20247                            sleep(d).await;
20248                            continue;
20249                        }
20250
20251                        dlg.finished(false);
20252
20253                        return Err(match error {
20254                            Ok(value) => common::Error::BadRequest(value),
20255                            _ => common::Error::Failure(response),
20256                        });
20257                    }
20258                    let response = {
20259                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20260                        let encoded = common::to_string(&bytes);
20261                        match serde_json::from_str(&encoded) {
20262                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20263                            Err(error) => {
20264                                dlg.response_json_decode_error(&encoded, &error);
20265                                return Err(common::Error::JsonDecodeError(
20266                                    encoded.to_string(),
20267                                    error,
20268                                ));
20269                            }
20270                        }
20271                    };
20272
20273                    dlg.finished(true);
20274                    return Ok(response);
20275                }
20276            }
20277        }
20278    }
20279
20280    ///
20281    /// Sets the *request* property to the given value.
20282    ///
20283    /// Even though the property as already been set when instantiating this call,
20284    /// we provide this method for API completeness.
20285    pub fn request(
20286        mut self,
20287        new_value: ProfileFilterLink,
20288    ) -> ManagementProfileFilterLinkInsertCall<'a, C> {
20289        self._request = new_value;
20290        self
20291    }
20292    /// Account ID to create profile filter link for.
20293    ///
20294    /// Sets the *account id* path property to the given value.
20295    ///
20296    /// Even though the property as already been set when instantiating this call,
20297    /// we provide this method for API completeness.
20298    pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkInsertCall<'a, C> {
20299        self._account_id = new_value.to_string();
20300        self
20301    }
20302    /// Web property Id to create profile filter link for.
20303    ///
20304    /// Sets the *web property id* path property to the given value.
20305    ///
20306    /// Even though the property as already been set when instantiating this call,
20307    /// we provide this method for API completeness.
20308    pub fn web_property_id(
20309        mut self,
20310        new_value: &str,
20311    ) -> ManagementProfileFilterLinkInsertCall<'a, C> {
20312        self._web_property_id = new_value.to_string();
20313        self
20314    }
20315    /// Profile ID to create filter link for.
20316    ///
20317    /// Sets the *profile id* path property to the given value.
20318    ///
20319    /// Even though the property as already been set when instantiating this call,
20320    /// we provide this method for API completeness.
20321    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkInsertCall<'a, C> {
20322        self._profile_id = new_value.to_string();
20323        self
20324    }
20325    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20326    /// while executing the actual API request.
20327    ///
20328    /// ````text
20329    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20330    /// ````
20331    ///
20332    /// Sets the *delegate* property to the given value.
20333    pub fn delegate(
20334        mut self,
20335        new_value: &'a mut dyn common::Delegate,
20336    ) -> ManagementProfileFilterLinkInsertCall<'a, C> {
20337        self._delegate = Some(new_value);
20338        self
20339    }
20340
20341    /// Set any additional parameter of the query string used in the request.
20342    /// It should be used to set parameters which are not yet available through their own
20343    /// setters.
20344    ///
20345    /// Please note that this method must not be used to set any of the known parameters
20346    /// which have their own setter method. If done anyway, the request will fail.
20347    ///
20348    /// # Additional Parameters
20349    ///
20350    /// * *alt* (query-string) - Data format for the response.
20351    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20352    /// * *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.
20353    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20354    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20355    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20356    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20357    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkInsertCall<'a, C>
20358    where
20359        T: AsRef<str>,
20360    {
20361        self._additional_params
20362            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20363        self
20364    }
20365
20366    /// Identifies the authorization scope for the method you are building.
20367    ///
20368    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20369    /// [`Scope::Edit`].
20370    ///
20371    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20372    /// tokens for more than one scope.
20373    ///
20374    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20375    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20376    /// sufficient, a read-write scope will do as well.
20377    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkInsertCall<'a, C>
20378    where
20379        St: AsRef<str>,
20380    {
20381        self._scopes.insert(String::from(scope.as_ref()));
20382        self
20383    }
20384    /// Identifies the authorization scope(s) for the method you are building.
20385    ///
20386    /// See [`Self::add_scope()`] for details.
20387    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkInsertCall<'a, C>
20388    where
20389        I: IntoIterator<Item = St>,
20390        St: AsRef<str>,
20391    {
20392        self._scopes
20393            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20394        self
20395    }
20396
20397    /// Removes all scopes, and no default scope will be used either.
20398    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20399    /// for details).
20400    pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkInsertCall<'a, C> {
20401        self._scopes.clear();
20402        self
20403    }
20404}
20405
20406/// Lists all profile filter links for a profile.
20407///
20408/// A builder for the *profileFilterLinks.list* method supported by a *management* resource.
20409/// It is not used directly, but through a [`ManagementMethods`] instance.
20410///
20411/// # Example
20412///
20413/// Instantiate a resource method builder
20414///
20415/// ```test_harness,no_run
20416/// # extern crate hyper;
20417/// # extern crate hyper_rustls;
20418/// # extern crate google_analytics3 as analytics3;
20419/// # async fn dox() {
20420/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20421///
20422/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20423/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20424/// #     .with_native_roots()
20425/// #     .unwrap()
20426/// #     .https_only()
20427/// #     .enable_http2()
20428/// #     .build();
20429///
20430/// # let executor = hyper_util::rt::TokioExecutor::new();
20431/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20432/// #     secret,
20433/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20434/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20435/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20436/// #     ),
20437/// # ).build().await.unwrap();
20438///
20439/// # let client = hyper_util::client::legacy::Client::builder(
20440/// #     hyper_util::rt::TokioExecutor::new()
20441/// # )
20442/// # .build(
20443/// #     hyper_rustls::HttpsConnectorBuilder::new()
20444/// #         .with_native_roots()
20445/// #         .unwrap()
20446/// #         .https_or_http()
20447/// #         .enable_http2()
20448/// #         .build()
20449/// # );
20450/// # let mut hub = Analytics::new(client, auth);
20451/// // You can configure optional parameters by calling the respective setters at will, and
20452/// // execute the final call using `doit()`.
20453/// // Values shown here are possibly random and not representative !
20454/// let result = hub.management().profile_filter_links_list("accountId", "webPropertyId", "profileId")
20455///              .start_index(-73)
20456///              .max_results(-10)
20457///              .doit().await;
20458/// # }
20459/// ```
20460pub struct ManagementProfileFilterLinkListCall<'a, C>
20461where
20462    C: 'a,
20463{
20464    hub: &'a Analytics<C>,
20465    _account_id: String,
20466    _web_property_id: String,
20467    _profile_id: String,
20468    _start_index: Option<i32>,
20469    _max_results: Option<i32>,
20470    _delegate: Option<&'a mut dyn common::Delegate>,
20471    _additional_params: HashMap<String, String>,
20472    _scopes: BTreeSet<String>,
20473}
20474
20475impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkListCall<'a, C> {}
20476
20477impl<'a, C> ManagementProfileFilterLinkListCall<'a, C>
20478where
20479    C: common::Connector,
20480{
20481    /// Perform the operation you have build so far.
20482    pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLinks)> {
20483        use std::borrow::Cow;
20484        use std::io::{Read, Seek};
20485
20486        use common::{url::Params, ToParts};
20487        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20488
20489        let mut dd = common::DefaultDelegate;
20490        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20491        dlg.begin(common::MethodInfo {
20492            id: "analytics.management.profileFilterLinks.list",
20493            http_method: hyper::Method::GET,
20494        });
20495
20496        for &field in [
20497            "alt",
20498            "accountId",
20499            "webPropertyId",
20500            "profileId",
20501            "start-index",
20502            "max-results",
20503        ]
20504        .iter()
20505        {
20506            if self._additional_params.contains_key(field) {
20507                dlg.finished(false);
20508                return Err(common::Error::FieldClash(field));
20509            }
20510        }
20511
20512        let mut params = Params::with_capacity(7 + self._additional_params.len());
20513        params.push("accountId", self._account_id);
20514        params.push("webPropertyId", self._web_property_id);
20515        params.push("profileId", self._profile_id);
20516        if let Some(value) = self._start_index.as_ref() {
20517            params.push("start-index", value.to_string());
20518        }
20519        if let Some(value) = self._max_results.as_ref() {
20520            params.push("max-results", value.to_string());
20521        }
20522
20523        params.extend(self._additional_params.iter());
20524
20525        params.push("alt", "json");
20526        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks";
20527        if self._scopes.is_empty() {
20528            self._scopes.insert(Scope::Readonly.as_ref().to_string());
20529        }
20530
20531        #[allow(clippy::single_element_loop)]
20532        for &(find_this, param_name) in [
20533            ("{accountId}", "accountId"),
20534            ("{webPropertyId}", "webPropertyId"),
20535            ("{profileId}", "profileId"),
20536        ]
20537        .iter()
20538        {
20539            url = params.uri_replacement(url, param_name, find_this, false);
20540        }
20541        {
20542            let to_remove = ["profileId", "webPropertyId", "accountId"];
20543            params.remove_params(&to_remove);
20544        }
20545
20546        let url = params.parse_with_url(&url);
20547
20548        loop {
20549            let token = match self
20550                .hub
20551                .auth
20552                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20553                .await
20554            {
20555                Ok(token) => token,
20556                Err(e) => match dlg.token(e) {
20557                    Ok(token) => token,
20558                    Err(e) => {
20559                        dlg.finished(false);
20560                        return Err(common::Error::MissingToken(e));
20561                    }
20562                },
20563            };
20564            let mut req_result = {
20565                let client = &self.hub.client;
20566                dlg.pre_request();
20567                let mut req_builder = hyper::Request::builder()
20568                    .method(hyper::Method::GET)
20569                    .uri(url.as_str())
20570                    .header(USER_AGENT, self.hub._user_agent.clone());
20571
20572                if let Some(token) = token.as_ref() {
20573                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20574                }
20575
20576                let request = req_builder
20577                    .header(CONTENT_LENGTH, 0_u64)
20578                    .body(common::to_body::<String>(None));
20579
20580                client.request(request.unwrap()).await
20581            };
20582
20583            match req_result {
20584                Err(err) => {
20585                    if let common::Retry::After(d) = dlg.http_error(&err) {
20586                        sleep(d).await;
20587                        continue;
20588                    }
20589                    dlg.finished(false);
20590                    return Err(common::Error::HttpError(err));
20591                }
20592                Ok(res) => {
20593                    let (mut parts, body) = res.into_parts();
20594                    let mut body = common::Body::new(body);
20595                    if !parts.status.is_success() {
20596                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20597                        let error = serde_json::from_str(&common::to_string(&bytes));
20598                        let response = common::to_response(parts, bytes.into());
20599
20600                        if let common::Retry::After(d) =
20601                            dlg.http_failure(&response, error.as_ref().ok())
20602                        {
20603                            sleep(d).await;
20604                            continue;
20605                        }
20606
20607                        dlg.finished(false);
20608
20609                        return Err(match error {
20610                            Ok(value) => common::Error::BadRequest(value),
20611                            _ => common::Error::Failure(response),
20612                        });
20613                    }
20614                    let response = {
20615                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20616                        let encoded = common::to_string(&bytes);
20617                        match serde_json::from_str(&encoded) {
20618                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20619                            Err(error) => {
20620                                dlg.response_json_decode_error(&encoded, &error);
20621                                return Err(common::Error::JsonDecodeError(
20622                                    encoded.to_string(),
20623                                    error,
20624                                ));
20625                            }
20626                        }
20627                    };
20628
20629                    dlg.finished(true);
20630                    return Ok(response);
20631                }
20632            }
20633        }
20634    }
20635
20636    /// Account ID to retrieve profile filter links for.
20637    ///
20638    /// Sets the *account id* path property to the given value.
20639    ///
20640    /// Even though the property as already been set when instantiating this call,
20641    /// we provide this method for API completeness.
20642    pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C> {
20643        self._account_id = new_value.to_string();
20644        self
20645    }
20646    /// Web property Id for profile filter links for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
20647    ///
20648    /// Sets the *web property id* path property to the given value.
20649    ///
20650    /// Even though the property as already been set when instantiating this call,
20651    /// we provide this method for API completeness.
20652    pub fn web_property_id(
20653        mut self,
20654        new_value: &str,
20655    ) -> ManagementProfileFilterLinkListCall<'a, C> {
20656        self._web_property_id = new_value.to_string();
20657        self
20658    }
20659    /// Profile ID to retrieve filter links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to.
20660    ///
20661    /// Sets the *profile id* path property to the given value.
20662    ///
20663    /// Even though the property as already been set when instantiating this call,
20664    /// we provide this method for API completeness.
20665    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C> {
20666        self._profile_id = new_value.to_string();
20667        self
20668    }
20669    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
20670    ///
20671    /// Sets the *start-index* query property to the given value.
20672    pub fn start_index(mut self, new_value: i32) -> ManagementProfileFilterLinkListCall<'a, C> {
20673        self._start_index = Some(new_value);
20674        self
20675    }
20676    /// The maximum number of profile filter links to include in this response.
20677    ///
20678    /// Sets the *max-results* query property to the given value.
20679    pub fn max_results(mut self, new_value: i32) -> ManagementProfileFilterLinkListCall<'a, C> {
20680        self._max_results = Some(new_value);
20681        self
20682    }
20683    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20684    /// while executing the actual API request.
20685    ///
20686    /// ````text
20687    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20688    /// ````
20689    ///
20690    /// Sets the *delegate* property to the given value.
20691    pub fn delegate(
20692        mut self,
20693        new_value: &'a mut dyn common::Delegate,
20694    ) -> ManagementProfileFilterLinkListCall<'a, C> {
20695        self._delegate = Some(new_value);
20696        self
20697    }
20698
20699    /// Set any additional parameter of the query string used in the request.
20700    /// It should be used to set parameters which are not yet available through their own
20701    /// setters.
20702    ///
20703    /// Please note that this method must not be used to set any of the known parameters
20704    /// which have their own setter method. If done anyway, the request will fail.
20705    ///
20706    /// # Additional Parameters
20707    ///
20708    /// * *alt* (query-string) - Data format for the response.
20709    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20710    /// * *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.
20711    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20712    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20713    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20714    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20715    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkListCall<'a, C>
20716    where
20717        T: AsRef<str>,
20718    {
20719        self._additional_params
20720            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20721        self
20722    }
20723
20724    /// Identifies the authorization scope for the method you are building.
20725    ///
20726    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20727    /// [`Scope::Readonly`].
20728    ///
20729    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20730    /// tokens for more than one scope.
20731    ///
20732    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20733    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20734    /// sufficient, a read-write scope will do as well.
20735    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkListCall<'a, C>
20736    where
20737        St: AsRef<str>,
20738    {
20739        self._scopes.insert(String::from(scope.as_ref()));
20740        self
20741    }
20742    /// Identifies the authorization scope(s) for the method you are building.
20743    ///
20744    /// See [`Self::add_scope()`] for details.
20745    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkListCall<'a, C>
20746    where
20747        I: IntoIterator<Item = St>,
20748        St: AsRef<str>,
20749    {
20750        self._scopes
20751            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20752        self
20753    }
20754
20755    /// Removes all scopes, and no default scope will be used either.
20756    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20757    /// for details).
20758    pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkListCall<'a, C> {
20759        self._scopes.clear();
20760        self
20761    }
20762}
20763
20764/// Update an existing profile filter link. This method supports patch semantics.
20765///
20766/// A builder for the *profileFilterLinks.patch* method supported by a *management* resource.
20767/// It is not used directly, but through a [`ManagementMethods`] instance.
20768///
20769/// # Example
20770///
20771/// Instantiate a resource method builder
20772///
20773/// ```test_harness,no_run
20774/// # extern crate hyper;
20775/// # extern crate hyper_rustls;
20776/// # extern crate google_analytics3 as analytics3;
20777/// use analytics3::api::ProfileFilterLink;
20778/// # async fn dox() {
20779/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20780///
20781/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20782/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20783/// #     .with_native_roots()
20784/// #     .unwrap()
20785/// #     .https_only()
20786/// #     .enable_http2()
20787/// #     .build();
20788///
20789/// # let executor = hyper_util::rt::TokioExecutor::new();
20790/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20791/// #     secret,
20792/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20793/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20794/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20795/// #     ),
20796/// # ).build().await.unwrap();
20797///
20798/// # let client = hyper_util::client::legacy::Client::builder(
20799/// #     hyper_util::rt::TokioExecutor::new()
20800/// # )
20801/// # .build(
20802/// #     hyper_rustls::HttpsConnectorBuilder::new()
20803/// #         .with_native_roots()
20804/// #         .unwrap()
20805/// #         .https_or_http()
20806/// #         .enable_http2()
20807/// #         .build()
20808/// # );
20809/// # let mut hub = Analytics::new(client, auth);
20810/// // As the method needs a request, you would usually fill it with the desired information
20811/// // into the respective structure. Some of the parts shown here might not be applicable !
20812/// // Values shown here are possibly random and not representative !
20813/// let mut req = ProfileFilterLink::default();
20814///
20815/// // You can configure optional parameters by calling the respective setters at will, and
20816/// // execute the final call using `doit()`.
20817/// // Values shown here are possibly random and not representative !
20818/// let result = hub.management().profile_filter_links_patch(req, "accountId", "webPropertyId", "profileId", "linkId")
20819///              .doit().await;
20820/// # }
20821/// ```
20822pub struct ManagementProfileFilterLinkPatchCall<'a, C>
20823where
20824    C: 'a,
20825{
20826    hub: &'a Analytics<C>,
20827    _request: ProfileFilterLink,
20828    _account_id: String,
20829    _web_property_id: String,
20830    _profile_id: String,
20831    _link_id: String,
20832    _delegate: Option<&'a mut dyn common::Delegate>,
20833    _additional_params: HashMap<String, String>,
20834    _scopes: BTreeSet<String>,
20835}
20836
20837impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkPatchCall<'a, C> {}
20838
20839impl<'a, C> ManagementProfileFilterLinkPatchCall<'a, C>
20840where
20841    C: common::Connector,
20842{
20843    /// Perform the operation you have build so far.
20844    pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLink)> {
20845        use std::borrow::Cow;
20846        use std::io::{Read, Seek};
20847
20848        use common::{url::Params, ToParts};
20849        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20850
20851        let mut dd = common::DefaultDelegate;
20852        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20853        dlg.begin(common::MethodInfo {
20854            id: "analytics.management.profileFilterLinks.patch",
20855            http_method: hyper::Method::PATCH,
20856        });
20857
20858        for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() {
20859            if self._additional_params.contains_key(field) {
20860                dlg.finished(false);
20861                return Err(common::Error::FieldClash(field));
20862            }
20863        }
20864
20865        let mut params = Params::with_capacity(7 + self._additional_params.len());
20866        params.push("accountId", self._account_id);
20867        params.push("webPropertyId", self._web_property_id);
20868        params.push("profileId", self._profile_id);
20869        params.push("linkId", self._link_id);
20870
20871        params.extend(self._additional_params.iter());
20872
20873        params.push("alt", "json");
20874        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}";
20875        if self._scopes.is_empty() {
20876            self._scopes.insert(Scope::Edit.as_ref().to_string());
20877        }
20878
20879        #[allow(clippy::single_element_loop)]
20880        for &(find_this, param_name) in [
20881            ("{accountId}", "accountId"),
20882            ("{webPropertyId}", "webPropertyId"),
20883            ("{profileId}", "profileId"),
20884            ("{linkId}", "linkId"),
20885        ]
20886        .iter()
20887        {
20888            url = params.uri_replacement(url, param_name, find_this, false);
20889        }
20890        {
20891            let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
20892            params.remove_params(&to_remove);
20893        }
20894
20895        let url = params.parse_with_url(&url);
20896
20897        let mut json_mime_type = mime::APPLICATION_JSON;
20898        let mut request_value_reader = {
20899            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20900            common::remove_json_null_values(&mut value);
20901            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20902            serde_json::to_writer(&mut dst, &value).unwrap();
20903            dst
20904        };
20905        let request_size = request_value_reader
20906            .seek(std::io::SeekFrom::End(0))
20907            .unwrap();
20908        request_value_reader
20909            .seek(std::io::SeekFrom::Start(0))
20910            .unwrap();
20911
20912        loop {
20913            let token = match self
20914                .hub
20915                .auth
20916                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20917                .await
20918            {
20919                Ok(token) => token,
20920                Err(e) => match dlg.token(e) {
20921                    Ok(token) => token,
20922                    Err(e) => {
20923                        dlg.finished(false);
20924                        return Err(common::Error::MissingToken(e));
20925                    }
20926                },
20927            };
20928            request_value_reader
20929                .seek(std::io::SeekFrom::Start(0))
20930                .unwrap();
20931            let mut req_result = {
20932                let client = &self.hub.client;
20933                dlg.pre_request();
20934                let mut req_builder = hyper::Request::builder()
20935                    .method(hyper::Method::PATCH)
20936                    .uri(url.as_str())
20937                    .header(USER_AGENT, self.hub._user_agent.clone());
20938
20939                if let Some(token) = token.as_ref() {
20940                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20941                }
20942
20943                let request = req_builder
20944                    .header(CONTENT_TYPE, json_mime_type.to_string())
20945                    .header(CONTENT_LENGTH, request_size as u64)
20946                    .body(common::to_body(
20947                        request_value_reader.get_ref().clone().into(),
20948                    ));
20949
20950                client.request(request.unwrap()).await
20951            };
20952
20953            match req_result {
20954                Err(err) => {
20955                    if let common::Retry::After(d) = dlg.http_error(&err) {
20956                        sleep(d).await;
20957                        continue;
20958                    }
20959                    dlg.finished(false);
20960                    return Err(common::Error::HttpError(err));
20961                }
20962                Ok(res) => {
20963                    let (mut parts, body) = res.into_parts();
20964                    let mut body = common::Body::new(body);
20965                    if !parts.status.is_success() {
20966                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20967                        let error = serde_json::from_str(&common::to_string(&bytes));
20968                        let response = common::to_response(parts, bytes.into());
20969
20970                        if let common::Retry::After(d) =
20971                            dlg.http_failure(&response, error.as_ref().ok())
20972                        {
20973                            sleep(d).await;
20974                            continue;
20975                        }
20976
20977                        dlg.finished(false);
20978
20979                        return Err(match error {
20980                            Ok(value) => common::Error::BadRequest(value),
20981                            _ => common::Error::Failure(response),
20982                        });
20983                    }
20984                    let response = {
20985                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20986                        let encoded = common::to_string(&bytes);
20987                        match serde_json::from_str(&encoded) {
20988                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20989                            Err(error) => {
20990                                dlg.response_json_decode_error(&encoded, &error);
20991                                return Err(common::Error::JsonDecodeError(
20992                                    encoded.to_string(),
20993                                    error,
20994                                ));
20995                            }
20996                        }
20997                    };
20998
20999                    dlg.finished(true);
21000                    return Ok(response);
21001                }
21002            }
21003        }
21004    }
21005
21006    ///
21007    /// Sets the *request* property to the given value.
21008    ///
21009    /// Even though the property as already been set when instantiating this call,
21010    /// we provide this method for API completeness.
21011    pub fn request(
21012        mut self,
21013        new_value: ProfileFilterLink,
21014    ) -> ManagementProfileFilterLinkPatchCall<'a, C> {
21015        self._request = new_value;
21016        self
21017    }
21018    /// Account ID to which profile filter link belongs.
21019    ///
21020    /// Sets the *account id* path property to the given value.
21021    ///
21022    /// Even though the property as already been set when instantiating this call,
21023    /// we provide this method for API completeness.
21024    pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkPatchCall<'a, C> {
21025        self._account_id = new_value.to_string();
21026        self
21027    }
21028    /// Web property Id to which profile filter link belongs
21029    ///
21030    /// Sets the *web property id* path property to the given value.
21031    ///
21032    /// Even though the property as already been set when instantiating this call,
21033    /// we provide this method for API completeness.
21034    pub fn web_property_id(
21035        mut self,
21036        new_value: &str,
21037    ) -> ManagementProfileFilterLinkPatchCall<'a, C> {
21038        self._web_property_id = new_value.to_string();
21039        self
21040    }
21041    /// Profile ID to which filter link belongs
21042    ///
21043    /// Sets the *profile id* path property to the given value.
21044    ///
21045    /// Even though the property as already been set when instantiating this call,
21046    /// we provide this method for API completeness.
21047    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkPatchCall<'a, C> {
21048        self._profile_id = new_value.to_string();
21049        self
21050    }
21051    /// ID of the profile filter link to be updated.
21052    ///
21053    /// Sets the *link id* path property to the given value.
21054    ///
21055    /// Even though the property as already been set when instantiating this call,
21056    /// we provide this method for API completeness.
21057    pub fn link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkPatchCall<'a, C> {
21058        self._link_id = new_value.to_string();
21059        self
21060    }
21061    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21062    /// while executing the actual API request.
21063    ///
21064    /// ````text
21065    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21066    /// ````
21067    ///
21068    /// Sets the *delegate* property to the given value.
21069    pub fn delegate(
21070        mut self,
21071        new_value: &'a mut dyn common::Delegate,
21072    ) -> ManagementProfileFilterLinkPatchCall<'a, C> {
21073        self._delegate = Some(new_value);
21074        self
21075    }
21076
21077    /// Set any additional parameter of the query string used in the request.
21078    /// It should be used to set parameters which are not yet available through their own
21079    /// setters.
21080    ///
21081    /// Please note that this method must not be used to set any of the known parameters
21082    /// which have their own setter method. If done anyway, the request will fail.
21083    ///
21084    /// # Additional Parameters
21085    ///
21086    /// * *alt* (query-string) - Data format for the response.
21087    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21088    /// * *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.
21089    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21090    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21091    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21092    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21093    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkPatchCall<'a, C>
21094    where
21095        T: AsRef<str>,
21096    {
21097        self._additional_params
21098            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21099        self
21100    }
21101
21102    /// Identifies the authorization scope for the method you are building.
21103    ///
21104    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21105    /// [`Scope::Edit`].
21106    ///
21107    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21108    /// tokens for more than one scope.
21109    ///
21110    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21111    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21112    /// sufficient, a read-write scope will do as well.
21113    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkPatchCall<'a, C>
21114    where
21115        St: AsRef<str>,
21116    {
21117        self._scopes.insert(String::from(scope.as_ref()));
21118        self
21119    }
21120    /// Identifies the authorization scope(s) for the method you are building.
21121    ///
21122    /// See [`Self::add_scope()`] for details.
21123    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkPatchCall<'a, C>
21124    where
21125        I: IntoIterator<Item = St>,
21126        St: AsRef<str>,
21127    {
21128        self._scopes
21129            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21130        self
21131    }
21132
21133    /// Removes all scopes, and no default scope will be used either.
21134    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21135    /// for details).
21136    pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkPatchCall<'a, C> {
21137        self._scopes.clear();
21138        self
21139    }
21140}
21141
21142/// Update an existing profile filter link.
21143///
21144/// A builder for the *profileFilterLinks.update* method supported by a *management* resource.
21145/// It is not used directly, but through a [`ManagementMethods`] instance.
21146///
21147/// # Example
21148///
21149/// Instantiate a resource method builder
21150///
21151/// ```test_harness,no_run
21152/// # extern crate hyper;
21153/// # extern crate hyper_rustls;
21154/// # extern crate google_analytics3 as analytics3;
21155/// use analytics3::api::ProfileFilterLink;
21156/// # async fn dox() {
21157/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21158///
21159/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21160/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21161/// #     .with_native_roots()
21162/// #     .unwrap()
21163/// #     .https_only()
21164/// #     .enable_http2()
21165/// #     .build();
21166///
21167/// # let executor = hyper_util::rt::TokioExecutor::new();
21168/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21169/// #     secret,
21170/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21171/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21172/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21173/// #     ),
21174/// # ).build().await.unwrap();
21175///
21176/// # let client = hyper_util::client::legacy::Client::builder(
21177/// #     hyper_util::rt::TokioExecutor::new()
21178/// # )
21179/// # .build(
21180/// #     hyper_rustls::HttpsConnectorBuilder::new()
21181/// #         .with_native_roots()
21182/// #         .unwrap()
21183/// #         .https_or_http()
21184/// #         .enable_http2()
21185/// #         .build()
21186/// # );
21187/// # let mut hub = Analytics::new(client, auth);
21188/// // As the method needs a request, you would usually fill it with the desired information
21189/// // into the respective structure. Some of the parts shown here might not be applicable !
21190/// // Values shown here are possibly random and not representative !
21191/// let mut req = ProfileFilterLink::default();
21192///
21193/// // You can configure optional parameters by calling the respective setters at will, and
21194/// // execute the final call using `doit()`.
21195/// // Values shown here are possibly random and not representative !
21196/// let result = hub.management().profile_filter_links_update(req, "accountId", "webPropertyId", "profileId", "linkId")
21197///              .doit().await;
21198/// # }
21199/// ```
21200pub struct ManagementProfileFilterLinkUpdateCall<'a, C>
21201where
21202    C: 'a,
21203{
21204    hub: &'a Analytics<C>,
21205    _request: ProfileFilterLink,
21206    _account_id: String,
21207    _web_property_id: String,
21208    _profile_id: String,
21209    _link_id: String,
21210    _delegate: Option<&'a mut dyn common::Delegate>,
21211    _additional_params: HashMap<String, String>,
21212    _scopes: BTreeSet<String>,
21213}
21214
21215impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkUpdateCall<'a, C> {}
21216
21217impl<'a, C> ManagementProfileFilterLinkUpdateCall<'a, C>
21218where
21219    C: common::Connector,
21220{
21221    /// Perform the operation you have build so far.
21222    pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLink)> {
21223        use std::borrow::Cow;
21224        use std::io::{Read, Seek};
21225
21226        use common::{url::Params, ToParts};
21227        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21228
21229        let mut dd = common::DefaultDelegate;
21230        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21231        dlg.begin(common::MethodInfo {
21232            id: "analytics.management.profileFilterLinks.update",
21233            http_method: hyper::Method::PUT,
21234        });
21235
21236        for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() {
21237            if self._additional_params.contains_key(field) {
21238                dlg.finished(false);
21239                return Err(common::Error::FieldClash(field));
21240            }
21241        }
21242
21243        let mut params = Params::with_capacity(7 + self._additional_params.len());
21244        params.push("accountId", self._account_id);
21245        params.push("webPropertyId", self._web_property_id);
21246        params.push("profileId", self._profile_id);
21247        params.push("linkId", self._link_id);
21248
21249        params.extend(self._additional_params.iter());
21250
21251        params.push("alt", "json");
21252        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}";
21253        if self._scopes.is_empty() {
21254            self._scopes.insert(Scope::Edit.as_ref().to_string());
21255        }
21256
21257        #[allow(clippy::single_element_loop)]
21258        for &(find_this, param_name) in [
21259            ("{accountId}", "accountId"),
21260            ("{webPropertyId}", "webPropertyId"),
21261            ("{profileId}", "profileId"),
21262            ("{linkId}", "linkId"),
21263        ]
21264        .iter()
21265        {
21266            url = params.uri_replacement(url, param_name, find_this, false);
21267        }
21268        {
21269            let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
21270            params.remove_params(&to_remove);
21271        }
21272
21273        let url = params.parse_with_url(&url);
21274
21275        let mut json_mime_type = mime::APPLICATION_JSON;
21276        let mut request_value_reader = {
21277            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21278            common::remove_json_null_values(&mut value);
21279            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21280            serde_json::to_writer(&mut dst, &value).unwrap();
21281            dst
21282        };
21283        let request_size = request_value_reader
21284            .seek(std::io::SeekFrom::End(0))
21285            .unwrap();
21286        request_value_reader
21287            .seek(std::io::SeekFrom::Start(0))
21288            .unwrap();
21289
21290        loop {
21291            let token = match self
21292                .hub
21293                .auth
21294                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21295                .await
21296            {
21297                Ok(token) => token,
21298                Err(e) => match dlg.token(e) {
21299                    Ok(token) => token,
21300                    Err(e) => {
21301                        dlg.finished(false);
21302                        return Err(common::Error::MissingToken(e));
21303                    }
21304                },
21305            };
21306            request_value_reader
21307                .seek(std::io::SeekFrom::Start(0))
21308                .unwrap();
21309            let mut req_result = {
21310                let client = &self.hub.client;
21311                dlg.pre_request();
21312                let mut req_builder = hyper::Request::builder()
21313                    .method(hyper::Method::PUT)
21314                    .uri(url.as_str())
21315                    .header(USER_AGENT, self.hub._user_agent.clone());
21316
21317                if let Some(token) = token.as_ref() {
21318                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21319                }
21320
21321                let request = req_builder
21322                    .header(CONTENT_TYPE, json_mime_type.to_string())
21323                    .header(CONTENT_LENGTH, request_size as u64)
21324                    .body(common::to_body(
21325                        request_value_reader.get_ref().clone().into(),
21326                    ));
21327
21328                client.request(request.unwrap()).await
21329            };
21330
21331            match req_result {
21332                Err(err) => {
21333                    if let common::Retry::After(d) = dlg.http_error(&err) {
21334                        sleep(d).await;
21335                        continue;
21336                    }
21337                    dlg.finished(false);
21338                    return Err(common::Error::HttpError(err));
21339                }
21340                Ok(res) => {
21341                    let (mut parts, body) = res.into_parts();
21342                    let mut body = common::Body::new(body);
21343                    if !parts.status.is_success() {
21344                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21345                        let error = serde_json::from_str(&common::to_string(&bytes));
21346                        let response = common::to_response(parts, bytes.into());
21347
21348                        if let common::Retry::After(d) =
21349                            dlg.http_failure(&response, error.as_ref().ok())
21350                        {
21351                            sleep(d).await;
21352                            continue;
21353                        }
21354
21355                        dlg.finished(false);
21356
21357                        return Err(match error {
21358                            Ok(value) => common::Error::BadRequest(value),
21359                            _ => common::Error::Failure(response),
21360                        });
21361                    }
21362                    let response = {
21363                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21364                        let encoded = common::to_string(&bytes);
21365                        match serde_json::from_str(&encoded) {
21366                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21367                            Err(error) => {
21368                                dlg.response_json_decode_error(&encoded, &error);
21369                                return Err(common::Error::JsonDecodeError(
21370                                    encoded.to_string(),
21371                                    error,
21372                                ));
21373                            }
21374                        }
21375                    };
21376
21377                    dlg.finished(true);
21378                    return Ok(response);
21379                }
21380            }
21381        }
21382    }
21383
21384    ///
21385    /// Sets the *request* property to the given value.
21386    ///
21387    /// Even though the property as already been set when instantiating this call,
21388    /// we provide this method for API completeness.
21389    pub fn request(
21390        mut self,
21391        new_value: ProfileFilterLink,
21392    ) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
21393        self._request = new_value;
21394        self
21395    }
21396    /// Account ID to which profile filter link belongs.
21397    ///
21398    /// Sets the *account id* path property to the given value.
21399    ///
21400    /// Even though the property as already been set when instantiating this call,
21401    /// we provide this method for API completeness.
21402    pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
21403        self._account_id = new_value.to_string();
21404        self
21405    }
21406    /// Web property Id to which profile filter link belongs
21407    ///
21408    /// Sets the *web property id* path property to the given value.
21409    ///
21410    /// Even though the property as already been set when instantiating this call,
21411    /// we provide this method for API completeness.
21412    pub fn web_property_id(
21413        mut self,
21414        new_value: &str,
21415    ) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
21416        self._web_property_id = new_value.to_string();
21417        self
21418    }
21419    /// Profile ID to which filter link belongs
21420    ///
21421    /// Sets the *profile id* path property to the given value.
21422    ///
21423    /// Even though the property as already been set when instantiating this call,
21424    /// we provide this method for API completeness.
21425    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
21426        self._profile_id = new_value.to_string();
21427        self
21428    }
21429    /// ID of the profile filter link to be updated.
21430    ///
21431    /// Sets the *link id* path property to the given value.
21432    ///
21433    /// Even though the property as already been set when instantiating this call,
21434    /// we provide this method for API completeness.
21435    pub fn link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
21436        self._link_id = new_value.to_string();
21437        self
21438    }
21439    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21440    /// while executing the actual API request.
21441    ///
21442    /// ````text
21443    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21444    /// ````
21445    ///
21446    /// Sets the *delegate* property to the given value.
21447    pub fn delegate(
21448        mut self,
21449        new_value: &'a mut dyn common::Delegate,
21450    ) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
21451        self._delegate = Some(new_value);
21452        self
21453    }
21454
21455    /// Set any additional parameter of the query string used in the request.
21456    /// It should be used to set parameters which are not yet available through their own
21457    /// setters.
21458    ///
21459    /// Please note that this method must not be used to set any of the known parameters
21460    /// which have their own setter method. If done anyway, the request will fail.
21461    ///
21462    /// # Additional Parameters
21463    ///
21464    /// * *alt* (query-string) - Data format for the response.
21465    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21466    /// * *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.
21467    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21468    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21469    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21470    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21471    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkUpdateCall<'a, C>
21472    where
21473        T: AsRef<str>,
21474    {
21475        self._additional_params
21476            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21477        self
21478    }
21479
21480    /// Identifies the authorization scope for the method you are building.
21481    ///
21482    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21483    /// [`Scope::Edit`].
21484    ///
21485    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21486    /// tokens for more than one scope.
21487    ///
21488    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21489    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21490    /// sufficient, a read-write scope will do as well.
21491    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkUpdateCall<'a, C>
21492    where
21493        St: AsRef<str>,
21494    {
21495        self._scopes.insert(String::from(scope.as_ref()));
21496        self
21497    }
21498    /// Identifies the authorization scope(s) for the method you are building.
21499    ///
21500    /// See [`Self::add_scope()`] for details.
21501    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkUpdateCall<'a, C>
21502    where
21503        I: IntoIterator<Item = St>,
21504        St: AsRef<str>,
21505    {
21506        self._scopes
21507            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21508        self
21509    }
21510
21511    /// Removes all scopes, and no default scope will be used either.
21512    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21513    /// for details).
21514    pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
21515        self._scopes.clear();
21516        self
21517    }
21518}
21519
21520/// Removes a user from the given view (profile).
21521///
21522/// A builder for the *profileUserLinks.delete* method supported by a *management* resource.
21523/// It is not used directly, but through a [`ManagementMethods`] instance.
21524///
21525/// # Example
21526///
21527/// Instantiate a resource method builder
21528///
21529/// ```test_harness,no_run
21530/// # extern crate hyper;
21531/// # extern crate hyper_rustls;
21532/// # extern crate google_analytics3 as analytics3;
21533/// # async fn dox() {
21534/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21535///
21536/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21537/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21538/// #     .with_native_roots()
21539/// #     .unwrap()
21540/// #     .https_only()
21541/// #     .enable_http2()
21542/// #     .build();
21543///
21544/// # let executor = hyper_util::rt::TokioExecutor::new();
21545/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21546/// #     secret,
21547/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21548/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21549/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21550/// #     ),
21551/// # ).build().await.unwrap();
21552///
21553/// # let client = hyper_util::client::legacy::Client::builder(
21554/// #     hyper_util::rt::TokioExecutor::new()
21555/// # )
21556/// # .build(
21557/// #     hyper_rustls::HttpsConnectorBuilder::new()
21558/// #         .with_native_roots()
21559/// #         .unwrap()
21560/// #         .https_or_http()
21561/// #         .enable_http2()
21562/// #         .build()
21563/// # );
21564/// # let mut hub = Analytics::new(client, auth);
21565/// // You can configure optional parameters by calling the respective setters at will, and
21566/// // execute the final call using `doit()`.
21567/// // Values shown here are possibly random and not representative !
21568/// let result = hub.management().profile_user_links_delete("accountId", "webPropertyId", "profileId", "linkId")
21569///              .doit().await;
21570/// # }
21571/// ```
21572pub struct ManagementProfileUserLinkDeleteCall<'a, C>
21573where
21574    C: 'a,
21575{
21576    hub: &'a Analytics<C>,
21577    _account_id: String,
21578    _web_property_id: String,
21579    _profile_id: String,
21580    _link_id: String,
21581    _delegate: Option<&'a mut dyn common::Delegate>,
21582    _additional_params: HashMap<String, String>,
21583    _scopes: BTreeSet<String>,
21584}
21585
21586impl<'a, C> common::CallBuilder for ManagementProfileUserLinkDeleteCall<'a, C> {}
21587
21588impl<'a, C> ManagementProfileUserLinkDeleteCall<'a, C>
21589where
21590    C: common::Connector,
21591{
21592    /// Perform the operation you have build so far.
21593    pub async fn doit(mut self) -> common::Result<common::Response> {
21594        use std::borrow::Cow;
21595        use std::io::{Read, Seek};
21596
21597        use common::{url::Params, ToParts};
21598        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21599
21600        let mut dd = common::DefaultDelegate;
21601        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21602        dlg.begin(common::MethodInfo {
21603            id: "analytics.management.profileUserLinks.delete",
21604            http_method: hyper::Method::DELETE,
21605        });
21606
21607        for &field in ["accountId", "webPropertyId", "profileId", "linkId"].iter() {
21608            if self._additional_params.contains_key(field) {
21609                dlg.finished(false);
21610                return Err(common::Error::FieldClash(field));
21611            }
21612        }
21613
21614        let mut params = Params::with_capacity(5 + self._additional_params.len());
21615        params.push("accountId", self._account_id);
21616        params.push("webPropertyId", self._web_property_id);
21617        params.push("profileId", self._profile_id);
21618        params.push("linkId", self._link_id);
21619
21620        params.extend(self._additional_params.iter());
21621
21622        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks/{linkId}";
21623        if self._scopes.is_empty() {
21624            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
21625        }
21626
21627        #[allow(clippy::single_element_loop)]
21628        for &(find_this, param_name) in [
21629            ("{accountId}", "accountId"),
21630            ("{webPropertyId}", "webPropertyId"),
21631            ("{profileId}", "profileId"),
21632            ("{linkId}", "linkId"),
21633        ]
21634        .iter()
21635        {
21636            url = params.uri_replacement(url, param_name, find_this, false);
21637        }
21638        {
21639            let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
21640            params.remove_params(&to_remove);
21641        }
21642
21643        let url = params.parse_with_url(&url);
21644
21645        loop {
21646            let token = match self
21647                .hub
21648                .auth
21649                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21650                .await
21651            {
21652                Ok(token) => token,
21653                Err(e) => match dlg.token(e) {
21654                    Ok(token) => token,
21655                    Err(e) => {
21656                        dlg.finished(false);
21657                        return Err(common::Error::MissingToken(e));
21658                    }
21659                },
21660            };
21661            let mut req_result = {
21662                let client = &self.hub.client;
21663                dlg.pre_request();
21664                let mut req_builder = hyper::Request::builder()
21665                    .method(hyper::Method::DELETE)
21666                    .uri(url.as_str())
21667                    .header(USER_AGENT, self.hub._user_agent.clone());
21668
21669                if let Some(token) = token.as_ref() {
21670                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21671                }
21672
21673                let request = req_builder
21674                    .header(CONTENT_LENGTH, 0_u64)
21675                    .body(common::to_body::<String>(None));
21676
21677                client.request(request.unwrap()).await
21678            };
21679
21680            match req_result {
21681                Err(err) => {
21682                    if let common::Retry::After(d) = dlg.http_error(&err) {
21683                        sleep(d).await;
21684                        continue;
21685                    }
21686                    dlg.finished(false);
21687                    return Err(common::Error::HttpError(err));
21688                }
21689                Ok(res) => {
21690                    let (mut parts, body) = res.into_parts();
21691                    let mut body = common::Body::new(body);
21692                    if !parts.status.is_success() {
21693                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21694                        let error = serde_json::from_str(&common::to_string(&bytes));
21695                        let response = common::to_response(parts, bytes.into());
21696
21697                        if let common::Retry::After(d) =
21698                            dlg.http_failure(&response, error.as_ref().ok())
21699                        {
21700                            sleep(d).await;
21701                            continue;
21702                        }
21703
21704                        dlg.finished(false);
21705
21706                        return Err(match error {
21707                            Ok(value) => common::Error::BadRequest(value),
21708                            _ => common::Error::Failure(response),
21709                        });
21710                    }
21711                    let response = common::Response::from_parts(parts, body);
21712
21713                    dlg.finished(true);
21714                    return Ok(response);
21715                }
21716            }
21717        }
21718    }
21719
21720    /// Account ID to delete the user link for.
21721    ///
21722    /// Sets the *account id* path property to the given value.
21723    ///
21724    /// Even though the property as already been set when instantiating this call,
21725    /// we provide this method for API completeness.
21726    pub fn account_id(mut self, new_value: &str) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21727        self._account_id = new_value.to_string();
21728        self
21729    }
21730    /// Web Property ID to delete the user link for.
21731    ///
21732    /// Sets the *web property id* path property to the given value.
21733    ///
21734    /// Even though the property as already been set when instantiating this call,
21735    /// we provide this method for API completeness.
21736    pub fn web_property_id(
21737        mut self,
21738        new_value: &str,
21739    ) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21740        self._web_property_id = new_value.to_string();
21741        self
21742    }
21743    /// View (Profile) ID to delete the user link for.
21744    ///
21745    /// Sets the *profile id* path property to the given value.
21746    ///
21747    /// Even though the property as already been set when instantiating this call,
21748    /// we provide this method for API completeness.
21749    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21750        self._profile_id = new_value.to_string();
21751        self
21752    }
21753    /// Link ID to delete the user link for.
21754    ///
21755    /// Sets the *link id* path property to the given value.
21756    ///
21757    /// Even though the property as already been set when instantiating this call,
21758    /// we provide this method for API completeness.
21759    pub fn link_id(mut self, new_value: &str) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21760        self._link_id = new_value.to_string();
21761        self
21762    }
21763    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21764    /// while executing the actual API request.
21765    ///
21766    /// ````text
21767    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21768    /// ````
21769    ///
21770    /// Sets the *delegate* property to the given value.
21771    pub fn delegate(
21772        mut self,
21773        new_value: &'a mut dyn common::Delegate,
21774    ) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21775        self._delegate = Some(new_value);
21776        self
21777    }
21778
21779    /// Set any additional parameter of the query string used in the request.
21780    /// It should be used to set parameters which are not yet available through their own
21781    /// setters.
21782    ///
21783    /// Please note that this method must not be used to set any of the known parameters
21784    /// which have their own setter method. If done anyway, the request will fail.
21785    ///
21786    /// # Additional Parameters
21787    ///
21788    /// * *alt* (query-string) - Data format for the response.
21789    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21790    /// * *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.
21791    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21792    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21793    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21794    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21795    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUserLinkDeleteCall<'a, C>
21796    where
21797        T: AsRef<str>,
21798    {
21799        self._additional_params
21800            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21801        self
21802    }
21803
21804    /// Identifies the authorization scope for the method you are building.
21805    ///
21806    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21807    /// [`Scope::ManageUser`].
21808    ///
21809    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21810    /// tokens for more than one scope.
21811    ///
21812    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21813    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21814    /// sufficient, a read-write scope will do as well.
21815    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUserLinkDeleteCall<'a, C>
21816    where
21817        St: AsRef<str>,
21818    {
21819        self._scopes.insert(String::from(scope.as_ref()));
21820        self
21821    }
21822    /// Identifies the authorization scope(s) for the method you are building.
21823    ///
21824    /// See [`Self::add_scope()`] for details.
21825    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUserLinkDeleteCall<'a, C>
21826    where
21827        I: IntoIterator<Item = St>,
21828        St: AsRef<str>,
21829    {
21830        self._scopes
21831            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21832        self
21833    }
21834
21835    /// Removes all scopes, and no default scope will be used either.
21836    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21837    /// for details).
21838    pub fn clear_scopes(mut self) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21839        self._scopes.clear();
21840        self
21841    }
21842}
21843
21844/// Adds a new user to the given view (profile).
21845///
21846/// A builder for the *profileUserLinks.insert* method supported by a *management* resource.
21847/// It is not used directly, but through a [`ManagementMethods`] instance.
21848///
21849/// # Example
21850///
21851/// Instantiate a resource method builder
21852///
21853/// ```test_harness,no_run
21854/// # extern crate hyper;
21855/// # extern crate hyper_rustls;
21856/// # extern crate google_analytics3 as analytics3;
21857/// use analytics3::api::EntityUserLink;
21858/// # async fn dox() {
21859/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21860///
21861/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21862/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21863/// #     .with_native_roots()
21864/// #     .unwrap()
21865/// #     .https_only()
21866/// #     .enable_http2()
21867/// #     .build();
21868///
21869/// # let executor = hyper_util::rt::TokioExecutor::new();
21870/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21871/// #     secret,
21872/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21873/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21874/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21875/// #     ),
21876/// # ).build().await.unwrap();
21877///
21878/// # let client = hyper_util::client::legacy::Client::builder(
21879/// #     hyper_util::rt::TokioExecutor::new()
21880/// # )
21881/// # .build(
21882/// #     hyper_rustls::HttpsConnectorBuilder::new()
21883/// #         .with_native_roots()
21884/// #         .unwrap()
21885/// #         .https_or_http()
21886/// #         .enable_http2()
21887/// #         .build()
21888/// # );
21889/// # let mut hub = Analytics::new(client, auth);
21890/// // As the method needs a request, you would usually fill it with the desired information
21891/// // into the respective structure. Some of the parts shown here might not be applicable !
21892/// // Values shown here are possibly random and not representative !
21893/// let mut req = EntityUserLink::default();
21894///
21895/// // You can configure optional parameters by calling the respective setters at will, and
21896/// // execute the final call using `doit()`.
21897/// // Values shown here are possibly random and not representative !
21898/// let result = hub.management().profile_user_links_insert(req, "accountId", "webPropertyId", "profileId")
21899///              .doit().await;
21900/// # }
21901/// ```
21902pub struct ManagementProfileUserLinkInsertCall<'a, C>
21903where
21904    C: 'a,
21905{
21906    hub: &'a Analytics<C>,
21907    _request: EntityUserLink,
21908    _account_id: String,
21909    _web_property_id: String,
21910    _profile_id: String,
21911    _delegate: Option<&'a mut dyn common::Delegate>,
21912    _additional_params: HashMap<String, String>,
21913    _scopes: BTreeSet<String>,
21914}
21915
21916impl<'a, C> common::CallBuilder for ManagementProfileUserLinkInsertCall<'a, C> {}
21917
21918impl<'a, C> ManagementProfileUserLinkInsertCall<'a, C>
21919where
21920    C: common::Connector,
21921{
21922    /// Perform the operation you have build so far.
21923    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
21924        use std::borrow::Cow;
21925        use std::io::{Read, Seek};
21926
21927        use common::{url::Params, ToParts};
21928        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21929
21930        let mut dd = common::DefaultDelegate;
21931        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21932        dlg.begin(common::MethodInfo {
21933            id: "analytics.management.profileUserLinks.insert",
21934            http_method: hyper::Method::POST,
21935        });
21936
21937        for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
21938            if self._additional_params.contains_key(field) {
21939                dlg.finished(false);
21940                return Err(common::Error::FieldClash(field));
21941            }
21942        }
21943
21944        let mut params = Params::with_capacity(6 + self._additional_params.len());
21945        params.push("accountId", self._account_id);
21946        params.push("webPropertyId", self._web_property_id);
21947        params.push("profileId", self._profile_id);
21948
21949        params.extend(self._additional_params.iter());
21950
21951        params.push("alt", "json");
21952        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks";
21953        if self._scopes.is_empty() {
21954            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
21955        }
21956
21957        #[allow(clippy::single_element_loop)]
21958        for &(find_this, param_name) in [
21959            ("{accountId}", "accountId"),
21960            ("{webPropertyId}", "webPropertyId"),
21961            ("{profileId}", "profileId"),
21962        ]
21963        .iter()
21964        {
21965            url = params.uri_replacement(url, param_name, find_this, false);
21966        }
21967        {
21968            let to_remove = ["profileId", "webPropertyId", "accountId"];
21969            params.remove_params(&to_remove);
21970        }
21971
21972        let url = params.parse_with_url(&url);
21973
21974        let mut json_mime_type = mime::APPLICATION_JSON;
21975        let mut request_value_reader = {
21976            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21977            common::remove_json_null_values(&mut value);
21978            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21979            serde_json::to_writer(&mut dst, &value).unwrap();
21980            dst
21981        };
21982        let request_size = request_value_reader
21983            .seek(std::io::SeekFrom::End(0))
21984            .unwrap();
21985        request_value_reader
21986            .seek(std::io::SeekFrom::Start(0))
21987            .unwrap();
21988
21989        loop {
21990            let token = match self
21991                .hub
21992                .auth
21993                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21994                .await
21995            {
21996                Ok(token) => token,
21997                Err(e) => match dlg.token(e) {
21998                    Ok(token) => token,
21999                    Err(e) => {
22000                        dlg.finished(false);
22001                        return Err(common::Error::MissingToken(e));
22002                    }
22003                },
22004            };
22005            request_value_reader
22006                .seek(std::io::SeekFrom::Start(0))
22007                .unwrap();
22008            let mut req_result = {
22009                let client = &self.hub.client;
22010                dlg.pre_request();
22011                let mut req_builder = hyper::Request::builder()
22012                    .method(hyper::Method::POST)
22013                    .uri(url.as_str())
22014                    .header(USER_AGENT, self.hub._user_agent.clone());
22015
22016                if let Some(token) = token.as_ref() {
22017                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22018                }
22019
22020                let request = req_builder
22021                    .header(CONTENT_TYPE, json_mime_type.to_string())
22022                    .header(CONTENT_LENGTH, request_size as u64)
22023                    .body(common::to_body(
22024                        request_value_reader.get_ref().clone().into(),
22025                    ));
22026
22027                client.request(request.unwrap()).await
22028            };
22029
22030            match req_result {
22031                Err(err) => {
22032                    if let common::Retry::After(d) = dlg.http_error(&err) {
22033                        sleep(d).await;
22034                        continue;
22035                    }
22036                    dlg.finished(false);
22037                    return Err(common::Error::HttpError(err));
22038                }
22039                Ok(res) => {
22040                    let (mut parts, body) = res.into_parts();
22041                    let mut body = common::Body::new(body);
22042                    if !parts.status.is_success() {
22043                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22044                        let error = serde_json::from_str(&common::to_string(&bytes));
22045                        let response = common::to_response(parts, bytes.into());
22046
22047                        if let common::Retry::After(d) =
22048                            dlg.http_failure(&response, error.as_ref().ok())
22049                        {
22050                            sleep(d).await;
22051                            continue;
22052                        }
22053
22054                        dlg.finished(false);
22055
22056                        return Err(match error {
22057                            Ok(value) => common::Error::BadRequest(value),
22058                            _ => common::Error::Failure(response),
22059                        });
22060                    }
22061                    let response = {
22062                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22063                        let encoded = common::to_string(&bytes);
22064                        match serde_json::from_str(&encoded) {
22065                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22066                            Err(error) => {
22067                                dlg.response_json_decode_error(&encoded, &error);
22068                                return Err(common::Error::JsonDecodeError(
22069                                    encoded.to_string(),
22070                                    error,
22071                                ));
22072                            }
22073                        }
22074                    };
22075
22076                    dlg.finished(true);
22077                    return Ok(response);
22078                }
22079            }
22080        }
22081    }
22082
22083    ///
22084    /// Sets the *request* property to the given value.
22085    ///
22086    /// Even though the property as already been set when instantiating this call,
22087    /// we provide this method for API completeness.
22088    pub fn request(
22089        mut self,
22090        new_value: EntityUserLink,
22091    ) -> ManagementProfileUserLinkInsertCall<'a, C> {
22092        self._request = new_value;
22093        self
22094    }
22095    /// Account ID to create the user link for.
22096    ///
22097    /// Sets the *account id* path property to the given value.
22098    ///
22099    /// Even though the property as already been set when instantiating this call,
22100    /// we provide this method for API completeness.
22101    pub fn account_id(mut self, new_value: &str) -> ManagementProfileUserLinkInsertCall<'a, C> {
22102        self._account_id = new_value.to_string();
22103        self
22104    }
22105    /// Web Property ID to create the user link for.
22106    ///
22107    /// Sets the *web property id* path property to the given value.
22108    ///
22109    /// Even though the property as already been set when instantiating this call,
22110    /// we provide this method for API completeness.
22111    pub fn web_property_id(
22112        mut self,
22113        new_value: &str,
22114    ) -> ManagementProfileUserLinkInsertCall<'a, C> {
22115        self._web_property_id = new_value.to_string();
22116        self
22117    }
22118    /// View (Profile) ID to create the user link for.
22119    ///
22120    /// Sets the *profile id* path property to the given value.
22121    ///
22122    /// Even though the property as already been set when instantiating this call,
22123    /// we provide this method for API completeness.
22124    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUserLinkInsertCall<'a, C> {
22125        self._profile_id = new_value.to_string();
22126        self
22127    }
22128    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22129    /// while executing the actual API request.
22130    ///
22131    /// ````text
22132    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22133    /// ````
22134    ///
22135    /// Sets the *delegate* property to the given value.
22136    pub fn delegate(
22137        mut self,
22138        new_value: &'a mut dyn common::Delegate,
22139    ) -> ManagementProfileUserLinkInsertCall<'a, C> {
22140        self._delegate = Some(new_value);
22141        self
22142    }
22143
22144    /// Set any additional parameter of the query string used in the request.
22145    /// It should be used to set parameters which are not yet available through their own
22146    /// setters.
22147    ///
22148    /// Please note that this method must not be used to set any of the known parameters
22149    /// which have their own setter method. If done anyway, the request will fail.
22150    ///
22151    /// # Additional Parameters
22152    ///
22153    /// * *alt* (query-string) - Data format for the response.
22154    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22155    /// * *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.
22156    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22157    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22158    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22159    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22160    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUserLinkInsertCall<'a, C>
22161    where
22162        T: AsRef<str>,
22163    {
22164        self._additional_params
22165            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22166        self
22167    }
22168
22169    /// Identifies the authorization scope for the method you are building.
22170    ///
22171    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22172    /// [`Scope::ManageUser`].
22173    ///
22174    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22175    /// tokens for more than one scope.
22176    ///
22177    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22178    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22179    /// sufficient, a read-write scope will do as well.
22180    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUserLinkInsertCall<'a, C>
22181    where
22182        St: AsRef<str>,
22183    {
22184        self._scopes.insert(String::from(scope.as_ref()));
22185        self
22186    }
22187    /// Identifies the authorization scope(s) for the method you are building.
22188    ///
22189    /// See [`Self::add_scope()`] for details.
22190    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUserLinkInsertCall<'a, C>
22191    where
22192        I: IntoIterator<Item = St>,
22193        St: AsRef<str>,
22194    {
22195        self._scopes
22196            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22197        self
22198    }
22199
22200    /// Removes all scopes, and no default scope will be used either.
22201    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22202    /// for details).
22203    pub fn clear_scopes(mut self) -> ManagementProfileUserLinkInsertCall<'a, C> {
22204        self._scopes.clear();
22205        self
22206    }
22207}
22208
22209/// Lists profile-user links for a given view (profile).
22210///
22211/// A builder for the *profileUserLinks.list* method supported by a *management* resource.
22212/// It is not used directly, but through a [`ManagementMethods`] instance.
22213///
22214/// # Example
22215///
22216/// Instantiate a resource method builder
22217///
22218/// ```test_harness,no_run
22219/// # extern crate hyper;
22220/// # extern crate hyper_rustls;
22221/// # extern crate google_analytics3 as analytics3;
22222/// # async fn dox() {
22223/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22224///
22225/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22226/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22227/// #     .with_native_roots()
22228/// #     .unwrap()
22229/// #     .https_only()
22230/// #     .enable_http2()
22231/// #     .build();
22232///
22233/// # let executor = hyper_util::rt::TokioExecutor::new();
22234/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22235/// #     secret,
22236/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22237/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22238/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22239/// #     ),
22240/// # ).build().await.unwrap();
22241///
22242/// # let client = hyper_util::client::legacy::Client::builder(
22243/// #     hyper_util::rt::TokioExecutor::new()
22244/// # )
22245/// # .build(
22246/// #     hyper_rustls::HttpsConnectorBuilder::new()
22247/// #         .with_native_roots()
22248/// #         .unwrap()
22249/// #         .https_or_http()
22250/// #         .enable_http2()
22251/// #         .build()
22252/// # );
22253/// # let mut hub = Analytics::new(client, auth);
22254/// // You can configure optional parameters by calling the respective setters at will, and
22255/// // execute the final call using `doit()`.
22256/// // Values shown here are possibly random and not representative !
22257/// let result = hub.management().profile_user_links_list("accountId", "webPropertyId", "profileId")
22258///              .start_index(-77)
22259///              .max_results(-19)
22260///              .doit().await;
22261/// # }
22262/// ```
22263pub struct ManagementProfileUserLinkListCall<'a, C>
22264where
22265    C: 'a,
22266{
22267    hub: &'a Analytics<C>,
22268    _account_id: String,
22269    _web_property_id: String,
22270    _profile_id: String,
22271    _start_index: Option<i32>,
22272    _max_results: Option<i32>,
22273    _delegate: Option<&'a mut dyn common::Delegate>,
22274    _additional_params: HashMap<String, String>,
22275    _scopes: BTreeSet<String>,
22276}
22277
22278impl<'a, C> common::CallBuilder for ManagementProfileUserLinkListCall<'a, C> {}
22279
22280impl<'a, C> ManagementProfileUserLinkListCall<'a, C>
22281where
22282    C: common::Connector,
22283{
22284    /// Perform the operation you have build so far.
22285    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLinks)> {
22286        use std::borrow::Cow;
22287        use std::io::{Read, Seek};
22288
22289        use common::{url::Params, ToParts};
22290        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22291
22292        let mut dd = common::DefaultDelegate;
22293        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22294        dlg.begin(common::MethodInfo {
22295            id: "analytics.management.profileUserLinks.list",
22296            http_method: hyper::Method::GET,
22297        });
22298
22299        for &field in [
22300            "alt",
22301            "accountId",
22302            "webPropertyId",
22303            "profileId",
22304            "start-index",
22305            "max-results",
22306        ]
22307        .iter()
22308        {
22309            if self._additional_params.contains_key(field) {
22310                dlg.finished(false);
22311                return Err(common::Error::FieldClash(field));
22312            }
22313        }
22314
22315        let mut params = Params::with_capacity(7 + self._additional_params.len());
22316        params.push("accountId", self._account_id);
22317        params.push("webPropertyId", self._web_property_id);
22318        params.push("profileId", self._profile_id);
22319        if let Some(value) = self._start_index.as_ref() {
22320            params.push("start-index", value.to_string());
22321        }
22322        if let Some(value) = self._max_results.as_ref() {
22323            params.push("max-results", value.to_string());
22324        }
22325
22326        params.extend(self._additional_params.iter());
22327
22328        params.push("alt", "json");
22329        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks";
22330        if self._scopes.is_empty() {
22331            self._scopes
22332                .insert(Scope::ManageUserReadonly.as_ref().to_string());
22333        }
22334
22335        #[allow(clippy::single_element_loop)]
22336        for &(find_this, param_name) in [
22337            ("{accountId}", "accountId"),
22338            ("{webPropertyId}", "webPropertyId"),
22339            ("{profileId}", "profileId"),
22340        ]
22341        .iter()
22342        {
22343            url = params.uri_replacement(url, param_name, find_this, false);
22344        }
22345        {
22346            let to_remove = ["profileId", "webPropertyId", "accountId"];
22347            params.remove_params(&to_remove);
22348        }
22349
22350        let url = params.parse_with_url(&url);
22351
22352        loop {
22353            let token = match self
22354                .hub
22355                .auth
22356                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22357                .await
22358            {
22359                Ok(token) => token,
22360                Err(e) => match dlg.token(e) {
22361                    Ok(token) => token,
22362                    Err(e) => {
22363                        dlg.finished(false);
22364                        return Err(common::Error::MissingToken(e));
22365                    }
22366                },
22367            };
22368            let mut req_result = {
22369                let client = &self.hub.client;
22370                dlg.pre_request();
22371                let mut req_builder = hyper::Request::builder()
22372                    .method(hyper::Method::GET)
22373                    .uri(url.as_str())
22374                    .header(USER_AGENT, self.hub._user_agent.clone());
22375
22376                if let Some(token) = token.as_ref() {
22377                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22378                }
22379
22380                let request = req_builder
22381                    .header(CONTENT_LENGTH, 0_u64)
22382                    .body(common::to_body::<String>(None));
22383
22384                client.request(request.unwrap()).await
22385            };
22386
22387            match req_result {
22388                Err(err) => {
22389                    if let common::Retry::After(d) = dlg.http_error(&err) {
22390                        sleep(d).await;
22391                        continue;
22392                    }
22393                    dlg.finished(false);
22394                    return Err(common::Error::HttpError(err));
22395                }
22396                Ok(res) => {
22397                    let (mut parts, body) = res.into_parts();
22398                    let mut body = common::Body::new(body);
22399                    if !parts.status.is_success() {
22400                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22401                        let error = serde_json::from_str(&common::to_string(&bytes));
22402                        let response = common::to_response(parts, bytes.into());
22403
22404                        if let common::Retry::After(d) =
22405                            dlg.http_failure(&response, error.as_ref().ok())
22406                        {
22407                            sleep(d).await;
22408                            continue;
22409                        }
22410
22411                        dlg.finished(false);
22412
22413                        return Err(match error {
22414                            Ok(value) => common::Error::BadRequest(value),
22415                            _ => common::Error::Failure(response),
22416                        });
22417                    }
22418                    let response = {
22419                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22420                        let encoded = common::to_string(&bytes);
22421                        match serde_json::from_str(&encoded) {
22422                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22423                            Err(error) => {
22424                                dlg.response_json_decode_error(&encoded, &error);
22425                                return Err(common::Error::JsonDecodeError(
22426                                    encoded.to_string(),
22427                                    error,
22428                                ));
22429                            }
22430                        }
22431                    };
22432
22433                    dlg.finished(true);
22434                    return Ok(response);
22435                }
22436            }
22437        }
22438    }
22439
22440    /// Account ID which the given view (profile) belongs to.
22441    ///
22442    /// Sets the *account id* path property to the given value.
22443    ///
22444    /// Even though the property as already been set when instantiating this call,
22445    /// we provide this method for API completeness.
22446    pub fn account_id(mut self, new_value: &str) -> ManagementProfileUserLinkListCall<'a, C> {
22447        self._account_id = new_value.to_string();
22448        self
22449    }
22450    /// Web Property ID which the given view (profile) belongs to. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
22451    ///
22452    /// Sets the *web property id* path property to the given value.
22453    ///
22454    /// Even though the property as already been set when instantiating this call,
22455    /// we provide this method for API completeness.
22456    pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileUserLinkListCall<'a, C> {
22457        self._web_property_id = new_value.to_string();
22458        self
22459    }
22460    /// View (Profile) ID to retrieve the profile-user links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to.
22461    ///
22462    /// Sets the *profile id* path property to the given value.
22463    ///
22464    /// Even though the property as already been set when instantiating this call,
22465    /// we provide this method for API completeness.
22466    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUserLinkListCall<'a, C> {
22467        self._profile_id = new_value.to_string();
22468        self
22469    }
22470    /// An index of the first profile-user link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
22471    ///
22472    /// Sets the *start-index* query property to the given value.
22473    pub fn start_index(mut self, new_value: i32) -> ManagementProfileUserLinkListCall<'a, C> {
22474        self._start_index = Some(new_value);
22475        self
22476    }
22477    /// The maximum number of profile-user links to include in this response.
22478    ///
22479    /// Sets the *max-results* query property to the given value.
22480    pub fn max_results(mut self, new_value: i32) -> ManagementProfileUserLinkListCall<'a, C> {
22481        self._max_results = Some(new_value);
22482        self
22483    }
22484    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22485    /// while executing the actual API request.
22486    ///
22487    /// ````text
22488    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22489    /// ````
22490    ///
22491    /// Sets the *delegate* property to the given value.
22492    pub fn delegate(
22493        mut self,
22494        new_value: &'a mut dyn common::Delegate,
22495    ) -> ManagementProfileUserLinkListCall<'a, C> {
22496        self._delegate = Some(new_value);
22497        self
22498    }
22499
22500    /// Set any additional parameter of the query string used in the request.
22501    /// It should be used to set parameters which are not yet available through their own
22502    /// setters.
22503    ///
22504    /// Please note that this method must not be used to set any of the known parameters
22505    /// which have their own setter method. If done anyway, the request will fail.
22506    ///
22507    /// # Additional Parameters
22508    ///
22509    /// * *alt* (query-string) - Data format for the response.
22510    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22511    /// * *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.
22512    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22513    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22514    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22515    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22516    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUserLinkListCall<'a, C>
22517    where
22518        T: AsRef<str>,
22519    {
22520        self._additional_params
22521            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22522        self
22523    }
22524
22525    /// Identifies the authorization scope for the method you are building.
22526    ///
22527    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22528    /// [`Scope::ManageUserReadonly`].
22529    ///
22530    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22531    /// tokens for more than one scope.
22532    ///
22533    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22534    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22535    /// sufficient, a read-write scope will do as well.
22536    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUserLinkListCall<'a, C>
22537    where
22538        St: AsRef<str>,
22539    {
22540        self._scopes.insert(String::from(scope.as_ref()));
22541        self
22542    }
22543    /// Identifies the authorization scope(s) for the method you are building.
22544    ///
22545    /// See [`Self::add_scope()`] for details.
22546    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUserLinkListCall<'a, C>
22547    where
22548        I: IntoIterator<Item = St>,
22549        St: AsRef<str>,
22550    {
22551        self._scopes
22552            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22553        self
22554    }
22555
22556    /// Removes all scopes, and no default scope will be used either.
22557    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22558    /// for details).
22559    pub fn clear_scopes(mut self) -> ManagementProfileUserLinkListCall<'a, C> {
22560        self._scopes.clear();
22561        self
22562    }
22563}
22564
22565/// Updates permissions for an existing user on the given view (profile).
22566///
22567/// A builder for the *profileUserLinks.update* method supported by a *management* resource.
22568/// It is not used directly, but through a [`ManagementMethods`] instance.
22569///
22570/// # Example
22571///
22572/// Instantiate a resource method builder
22573///
22574/// ```test_harness,no_run
22575/// # extern crate hyper;
22576/// # extern crate hyper_rustls;
22577/// # extern crate google_analytics3 as analytics3;
22578/// use analytics3::api::EntityUserLink;
22579/// # async fn dox() {
22580/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22581///
22582/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22583/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22584/// #     .with_native_roots()
22585/// #     .unwrap()
22586/// #     .https_only()
22587/// #     .enable_http2()
22588/// #     .build();
22589///
22590/// # let executor = hyper_util::rt::TokioExecutor::new();
22591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22592/// #     secret,
22593/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22594/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22595/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22596/// #     ),
22597/// # ).build().await.unwrap();
22598///
22599/// # let client = hyper_util::client::legacy::Client::builder(
22600/// #     hyper_util::rt::TokioExecutor::new()
22601/// # )
22602/// # .build(
22603/// #     hyper_rustls::HttpsConnectorBuilder::new()
22604/// #         .with_native_roots()
22605/// #         .unwrap()
22606/// #         .https_or_http()
22607/// #         .enable_http2()
22608/// #         .build()
22609/// # );
22610/// # let mut hub = Analytics::new(client, auth);
22611/// // As the method needs a request, you would usually fill it with the desired information
22612/// // into the respective structure. Some of the parts shown here might not be applicable !
22613/// // Values shown here are possibly random and not representative !
22614/// let mut req = EntityUserLink::default();
22615///
22616/// // You can configure optional parameters by calling the respective setters at will, and
22617/// // execute the final call using `doit()`.
22618/// // Values shown here are possibly random and not representative !
22619/// let result = hub.management().profile_user_links_update(req, "accountId", "webPropertyId", "profileId", "linkId")
22620///              .doit().await;
22621/// # }
22622/// ```
22623pub struct ManagementProfileUserLinkUpdateCall<'a, C>
22624where
22625    C: 'a,
22626{
22627    hub: &'a Analytics<C>,
22628    _request: EntityUserLink,
22629    _account_id: String,
22630    _web_property_id: String,
22631    _profile_id: String,
22632    _link_id: String,
22633    _delegate: Option<&'a mut dyn common::Delegate>,
22634    _additional_params: HashMap<String, String>,
22635    _scopes: BTreeSet<String>,
22636}
22637
22638impl<'a, C> common::CallBuilder for ManagementProfileUserLinkUpdateCall<'a, C> {}
22639
22640impl<'a, C> ManagementProfileUserLinkUpdateCall<'a, C>
22641where
22642    C: common::Connector,
22643{
22644    /// Perform the operation you have build so far.
22645    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
22646        use std::borrow::Cow;
22647        use std::io::{Read, Seek};
22648
22649        use common::{url::Params, ToParts};
22650        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22651
22652        let mut dd = common::DefaultDelegate;
22653        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22654        dlg.begin(common::MethodInfo {
22655            id: "analytics.management.profileUserLinks.update",
22656            http_method: hyper::Method::PUT,
22657        });
22658
22659        for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() {
22660            if self._additional_params.contains_key(field) {
22661                dlg.finished(false);
22662                return Err(common::Error::FieldClash(field));
22663            }
22664        }
22665
22666        let mut params = Params::with_capacity(7 + self._additional_params.len());
22667        params.push("accountId", self._account_id);
22668        params.push("webPropertyId", self._web_property_id);
22669        params.push("profileId", self._profile_id);
22670        params.push("linkId", self._link_id);
22671
22672        params.extend(self._additional_params.iter());
22673
22674        params.push("alt", "json");
22675        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks/{linkId}";
22676        if self._scopes.is_empty() {
22677            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
22678        }
22679
22680        #[allow(clippy::single_element_loop)]
22681        for &(find_this, param_name) in [
22682            ("{accountId}", "accountId"),
22683            ("{webPropertyId}", "webPropertyId"),
22684            ("{profileId}", "profileId"),
22685            ("{linkId}", "linkId"),
22686        ]
22687        .iter()
22688        {
22689            url = params.uri_replacement(url, param_name, find_this, false);
22690        }
22691        {
22692            let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
22693            params.remove_params(&to_remove);
22694        }
22695
22696        let url = params.parse_with_url(&url);
22697
22698        let mut json_mime_type = mime::APPLICATION_JSON;
22699        let mut request_value_reader = {
22700            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22701            common::remove_json_null_values(&mut value);
22702            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22703            serde_json::to_writer(&mut dst, &value).unwrap();
22704            dst
22705        };
22706        let request_size = request_value_reader
22707            .seek(std::io::SeekFrom::End(0))
22708            .unwrap();
22709        request_value_reader
22710            .seek(std::io::SeekFrom::Start(0))
22711            .unwrap();
22712
22713        loop {
22714            let token = match self
22715                .hub
22716                .auth
22717                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22718                .await
22719            {
22720                Ok(token) => token,
22721                Err(e) => match dlg.token(e) {
22722                    Ok(token) => token,
22723                    Err(e) => {
22724                        dlg.finished(false);
22725                        return Err(common::Error::MissingToken(e));
22726                    }
22727                },
22728            };
22729            request_value_reader
22730                .seek(std::io::SeekFrom::Start(0))
22731                .unwrap();
22732            let mut req_result = {
22733                let client = &self.hub.client;
22734                dlg.pre_request();
22735                let mut req_builder = hyper::Request::builder()
22736                    .method(hyper::Method::PUT)
22737                    .uri(url.as_str())
22738                    .header(USER_AGENT, self.hub._user_agent.clone());
22739
22740                if let Some(token) = token.as_ref() {
22741                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22742                }
22743
22744                let request = req_builder
22745                    .header(CONTENT_TYPE, json_mime_type.to_string())
22746                    .header(CONTENT_LENGTH, request_size as u64)
22747                    .body(common::to_body(
22748                        request_value_reader.get_ref().clone().into(),
22749                    ));
22750
22751                client.request(request.unwrap()).await
22752            };
22753
22754            match req_result {
22755                Err(err) => {
22756                    if let common::Retry::After(d) = dlg.http_error(&err) {
22757                        sleep(d).await;
22758                        continue;
22759                    }
22760                    dlg.finished(false);
22761                    return Err(common::Error::HttpError(err));
22762                }
22763                Ok(res) => {
22764                    let (mut parts, body) = res.into_parts();
22765                    let mut body = common::Body::new(body);
22766                    if !parts.status.is_success() {
22767                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22768                        let error = serde_json::from_str(&common::to_string(&bytes));
22769                        let response = common::to_response(parts, bytes.into());
22770
22771                        if let common::Retry::After(d) =
22772                            dlg.http_failure(&response, error.as_ref().ok())
22773                        {
22774                            sleep(d).await;
22775                            continue;
22776                        }
22777
22778                        dlg.finished(false);
22779
22780                        return Err(match error {
22781                            Ok(value) => common::Error::BadRequest(value),
22782                            _ => common::Error::Failure(response),
22783                        });
22784                    }
22785                    let response = {
22786                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22787                        let encoded = common::to_string(&bytes);
22788                        match serde_json::from_str(&encoded) {
22789                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22790                            Err(error) => {
22791                                dlg.response_json_decode_error(&encoded, &error);
22792                                return Err(common::Error::JsonDecodeError(
22793                                    encoded.to_string(),
22794                                    error,
22795                                ));
22796                            }
22797                        }
22798                    };
22799
22800                    dlg.finished(true);
22801                    return Ok(response);
22802                }
22803            }
22804        }
22805    }
22806
22807    ///
22808    /// Sets the *request* property to the given value.
22809    ///
22810    /// Even though the property as already been set when instantiating this call,
22811    /// we provide this method for API completeness.
22812    pub fn request(
22813        mut self,
22814        new_value: EntityUserLink,
22815    ) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22816        self._request = new_value;
22817        self
22818    }
22819    /// Account ID to update the user link for.
22820    ///
22821    /// Sets the *account id* path property to the given value.
22822    ///
22823    /// Even though the property as already been set when instantiating this call,
22824    /// we provide this method for API completeness.
22825    pub fn account_id(mut self, new_value: &str) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22826        self._account_id = new_value.to_string();
22827        self
22828    }
22829    /// Web Property ID to update the user link for.
22830    ///
22831    /// Sets the *web property id* path property to the given value.
22832    ///
22833    /// Even though the property as already been set when instantiating this call,
22834    /// we provide this method for API completeness.
22835    pub fn web_property_id(
22836        mut self,
22837        new_value: &str,
22838    ) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22839        self._web_property_id = new_value.to_string();
22840        self
22841    }
22842    /// View (Profile ID) to update the user link for.
22843    ///
22844    /// Sets the *profile id* path property to the given value.
22845    ///
22846    /// Even though the property as already been set when instantiating this call,
22847    /// we provide this method for API completeness.
22848    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22849        self._profile_id = new_value.to_string();
22850        self
22851    }
22852    /// Link ID to update the user link for.
22853    ///
22854    /// Sets the *link id* path property to the given value.
22855    ///
22856    /// Even though the property as already been set when instantiating this call,
22857    /// we provide this method for API completeness.
22858    pub fn link_id(mut self, new_value: &str) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22859        self._link_id = new_value.to_string();
22860        self
22861    }
22862    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22863    /// while executing the actual API request.
22864    ///
22865    /// ````text
22866    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22867    /// ````
22868    ///
22869    /// Sets the *delegate* property to the given value.
22870    pub fn delegate(
22871        mut self,
22872        new_value: &'a mut dyn common::Delegate,
22873    ) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22874        self._delegate = Some(new_value);
22875        self
22876    }
22877
22878    /// Set any additional parameter of the query string used in the request.
22879    /// It should be used to set parameters which are not yet available through their own
22880    /// setters.
22881    ///
22882    /// Please note that this method must not be used to set any of the known parameters
22883    /// which have their own setter method. If done anyway, the request will fail.
22884    ///
22885    /// # Additional Parameters
22886    ///
22887    /// * *alt* (query-string) - Data format for the response.
22888    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22889    /// * *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.
22890    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22891    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22892    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22893    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22894    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUserLinkUpdateCall<'a, C>
22895    where
22896        T: AsRef<str>,
22897    {
22898        self._additional_params
22899            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22900        self
22901    }
22902
22903    /// Identifies the authorization scope for the method you are building.
22904    ///
22905    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22906    /// [`Scope::ManageUser`].
22907    ///
22908    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22909    /// tokens for more than one scope.
22910    ///
22911    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22912    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22913    /// sufficient, a read-write scope will do as well.
22914    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUserLinkUpdateCall<'a, C>
22915    where
22916        St: AsRef<str>,
22917    {
22918        self._scopes.insert(String::from(scope.as_ref()));
22919        self
22920    }
22921    /// Identifies the authorization scope(s) for the method you are building.
22922    ///
22923    /// See [`Self::add_scope()`] for details.
22924    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUserLinkUpdateCall<'a, C>
22925    where
22926        I: IntoIterator<Item = St>,
22927        St: AsRef<str>,
22928    {
22929        self._scopes
22930            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22931        self
22932    }
22933
22934    /// Removes all scopes, and no default scope will be used either.
22935    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22936    /// for details).
22937    pub fn clear_scopes(mut self) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22938        self._scopes.clear();
22939        self
22940    }
22941}
22942
22943/// Deletes a view (profile).
22944///
22945/// A builder for the *profiles.delete* method supported by a *management* resource.
22946/// It is not used directly, but through a [`ManagementMethods`] instance.
22947///
22948/// # Example
22949///
22950/// Instantiate a resource method builder
22951///
22952/// ```test_harness,no_run
22953/// # extern crate hyper;
22954/// # extern crate hyper_rustls;
22955/// # extern crate google_analytics3 as analytics3;
22956/// # async fn dox() {
22957/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22958///
22959/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22960/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22961/// #     .with_native_roots()
22962/// #     .unwrap()
22963/// #     .https_only()
22964/// #     .enable_http2()
22965/// #     .build();
22966///
22967/// # let executor = hyper_util::rt::TokioExecutor::new();
22968/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22969/// #     secret,
22970/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22971/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22972/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22973/// #     ),
22974/// # ).build().await.unwrap();
22975///
22976/// # let client = hyper_util::client::legacy::Client::builder(
22977/// #     hyper_util::rt::TokioExecutor::new()
22978/// # )
22979/// # .build(
22980/// #     hyper_rustls::HttpsConnectorBuilder::new()
22981/// #         .with_native_roots()
22982/// #         .unwrap()
22983/// #         .https_or_http()
22984/// #         .enable_http2()
22985/// #         .build()
22986/// # );
22987/// # let mut hub = Analytics::new(client, auth);
22988/// // You can configure optional parameters by calling the respective setters at will, and
22989/// // execute the final call using `doit()`.
22990/// // Values shown here are possibly random and not representative !
22991/// let result = hub.management().profiles_delete("accountId", "webPropertyId", "profileId")
22992///              .doit().await;
22993/// # }
22994/// ```
22995pub struct ManagementProfileDeleteCall<'a, C>
22996where
22997    C: 'a,
22998{
22999    hub: &'a Analytics<C>,
23000    _account_id: String,
23001    _web_property_id: String,
23002    _profile_id: String,
23003    _delegate: Option<&'a mut dyn common::Delegate>,
23004    _additional_params: HashMap<String, String>,
23005    _scopes: BTreeSet<String>,
23006}
23007
23008impl<'a, C> common::CallBuilder for ManagementProfileDeleteCall<'a, C> {}
23009
23010impl<'a, C> ManagementProfileDeleteCall<'a, C>
23011where
23012    C: common::Connector,
23013{
23014    /// Perform the operation you have build so far.
23015    pub async fn doit(mut self) -> common::Result<common::Response> {
23016        use std::borrow::Cow;
23017        use std::io::{Read, Seek};
23018
23019        use common::{url::Params, ToParts};
23020        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23021
23022        let mut dd = common::DefaultDelegate;
23023        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23024        dlg.begin(common::MethodInfo {
23025            id: "analytics.management.profiles.delete",
23026            http_method: hyper::Method::DELETE,
23027        });
23028
23029        for &field in ["accountId", "webPropertyId", "profileId"].iter() {
23030            if self._additional_params.contains_key(field) {
23031                dlg.finished(false);
23032                return Err(common::Error::FieldClash(field));
23033            }
23034        }
23035
23036        let mut params = Params::with_capacity(4 + self._additional_params.len());
23037        params.push("accountId", self._account_id);
23038        params.push("webPropertyId", self._web_property_id);
23039        params.push("profileId", self._profile_id);
23040
23041        params.extend(self._additional_params.iter());
23042
23043        let mut url = self.hub._base_url.clone()
23044            + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}";
23045        if self._scopes.is_empty() {
23046            self._scopes.insert(Scope::Edit.as_ref().to_string());
23047        }
23048
23049        #[allow(clippy::single_element_loop)]
23050        for &(find_this, param_name) in [
23051            ("{accountId}", "accountId"),
23052            ("{webPropertyId}", "webPropertyId"),
23053            ("{profileId}", "profileId"),
23054        ]
23055        .iter()
23056        {
23057            url = params.uri_replacement(url, param_name, find_this, false);
23058        }
23059        {
23060            let to_remove = ["profileId", "webPropertyId", "accountId"];
23061            params.remove_params(&to_remove);
23062        }
23063
23064        let url = params.parse_with_url(&url);
23065
23066        loop {
23067            let token = match self
23068                .hub
23069                .auth
23070                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23071                .await
23072            {
23073                Ok(token) => token,
23074                Err(e) => match dlg.token(e) {
23075                    Ok(token) => token,
23076                    Err(e) => {
23077                        dlg.finished(false);
23078                        return Err(common::Error::MissingToken(e));
23079                    }
23080                },
23081            };
23082            let mut req_result = {
23083                let client = &self.hub.client;
23084                dlg.pre_request();
23085                let mut req_builder = hyper::Request::builder()
23086                    .method(hyper::Method::DELETE)
23087                    .uri(url.as_str())
23088                    .header(USER_AGENT, self.hub._user_agent.clone());
23089
23090                if let Some(token) = token.as_ref() {
23091                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23092                }
23093
23094                let request = req_builder
23095                    .header(CONTENT_LENGTH, 0_u64)
23096                    .body(common::to_body::<String>(None));
23097
23098                client.request(request.unwrap()).await
23099            };
23100
23101            match req_result {
23102                Err(err) => {
23103                    if let common::Retry::After(d) = dlg.http_error(&err) {
23104                        sleep(d).await;
23105                        continue;
23106                    }
23107                    dlg.finished(false);
23108                    return Err(common::Error::HttpError(err));
23109                }
23110                Ok(res) => {
23111                    let (mut parts, body) = res.into_parts();
23112                    let mut body = common::Body::new(body);
23113                    if !parts.status.is_success() {
23114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23115                        let error = serde_json::from_str(&common::to_string(&bytes));
23116                        let response = common::to_response(parts, bytes.into());
23117
23118                        if let common::Retry::After(d) =
23119                            dlg.http_failure(&response, error.as_ref().ok())
23120                        {
23121                            sleep(d).await;
23122                            continue;
23123                        }
23124
23125                        dlg.finished(false);
23126
23127                        return Err(match error {
23128                            Ok(value) => common::Error::BadRequest(value),
23129                            _ => common::Error::Failure(response),
23130                        });
23131                    }
23132                    let response = common::Response::from_parts(parts, body);
23133
23134                    dlg.finished(true);
23135                    return Ok(response);
23136                }
23137            }
23138        }
23139    }
23140
23141    /// Account ID to delete the view (profile) for.
23142    ///
23143    /// Sets the *account id* path property to the given value.
23144    ///
23145    /// Even though the property as already been set when instantiating this call,
23146    /// we provide this method for API completeness.
23147    pub fn account_id(mut self, new_value: &str) -> ManagementProfileDeleteCall<'a, C> {
23148        self._account_id = new_value.to_string();
23149        self
23150    }
23151    /// Web property ID to delete the view (profile) for.
23152    ///
23153    /// Sets the *web property id* path property to the given value.
23154    ///
23155    /// Even though the property as already been set when instantiating this call,
23156    /// we provide this method for API completeness.
23157    pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileDeleteCall<'a, C> {
23158        self._web_property_id = new_value.to_string();
23159        self
23160    }
23161    /// ID of the view (profile) to be deleted.
23162    ///
23163    /// Sets the *profile id* path property to the given value.
23164    ///
23165    /// Even though the property as already been set when instantiating this call,
23166    /// we provide this method for API completeness.
23167    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileDeleteCall<'a, C> {
23168        self._profile_id = new_value.to_string();
23169        self
23170    }
23171    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23172    /// while executing the actual API request.
23173    ///
23174    /// ````text
23175    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23176    /// ````
23177    ///
23178    /// Sets the *delegate* property to the given value.
23179    pub fn delegate(
23180        mut self,
23181        new_value: &'a mut dyn common::Delegate,
23182    ) -> ManagementProfileDeleteCall<'a, C> {
23183        self._delegate = Some(new_value);
23184        self
23185    }
23186
23187    /// Set any additional parameter of the query string used in the request.
23188    /// It should be used to set parameters which are not yet available through their own
23189    /// setters.
23190    ///
23191    /// Please note that this method must not be used to set any of the known parameters
23192    /// which have their own setter method. If done anyway, the request will fail.
23193    ///
23194    /// # Additional Parameters
23195    ///
23196    /// * *alt* (query-string) - Data format for the response.
23197    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23198    /// * *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.
23199    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23200    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23201    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23202    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23203    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileDeleteCall<'a, C>
23204    where
23205        T: AsRef<str>,
23206    {
23207        self._additional_params
23208            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23209        self
23210    }
23211
23212    /// Identifies the authorization scope for the method you are building.
23213    ///
23214    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23215    /// [`Scope::Edit`].
23216    ///
23217    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23218    /// tokens for more than one scope.
23219    ///
23220    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23221    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23222    /// sufficient, a read-write scope will do as well.
23223    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileDeleteCall<'a, C>
23224    where
23225        St: AsRef<str>,
23226    {
23227        self._scopes.insert(String::from(scope.as_ref()));
23228        self
23229    }
23230    /// Identifies the authorization scope(s) for the method you are building.
23231    ///
23232    /// See [`Self::add_scope()`] for details.
23233    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileDeleteCall<'a, C>
23234    where
23235        I: IntoIterator<Item = St>,
23236        St: AsRef<str>,
23237    {
23238        self._scopes
23239            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23240        self
23241    }
23242
23243    /// Removes all scopes, and no default scope will be used either.
23244    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23245    /// for details).
23246    pub fn clear_scopes(mut self) -> ManagementProfileDeleteCall<'a, C> {
23247        self._scopes.clear();
23248        self
23249    }
23250}
23251
23252/// Gets a view (profile) to which the user has access.
23253///
23254/// A builder for the *profiles.get* method supported by a *management* resource.
23255/// It is not used directly, but through a [`ManagementMethods`] instance.
23256///
23257/// # Example
23258///
23259/// Instantiate a resource method builder
23260///
23261/// ```test_harness,no_run
23262/// # extern crate hyper;
23263/// # extern crate hyper_rustls;
23264/// # extern crate google_analytics3 as analytics3;
23265/// # async fn dox() {
23266/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23267///
23268/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23269/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23270/// #     .with_native_roots()
23271/// #     .unwrap()
23272/// #     .https_only()
23273/// #     .enable_http2()
23274/// #     .build();
23275///
23276/// # let executor = hyper_util::rt::TokioExecutor::new();
23277/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23278/// #     secret,
23279/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23280/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23281/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23282/// #     ),
23283/// # ).build().await.unwrap();
23284///
23285/// # let client = hyper_util::client::legacy::Client::builder(
23286/// #     hyper_util::rt::TokioExecutor::new()
23287/// # )
23288/// # .build(
23289/// #     hyper_rustls::HttpsConnectorBuilder::new()
23290/// #         .with_native_roots()
23291/// #         .unwrap()
23292/// #         .https_or_http()
23293/// #         .enable_http2()
23294/// #         .build()
23295/// # );
23296/// # let mut hub = Analytics::new(client, auth);
23297/// // You can configure optional parameters by calling the respective setters at will, and
23298/// // execute the final call using `doit()`.
23299/// // Values shown here are possibly random and not representative !
23300/// let result = hub.management().profiles_get("accountId", "webPropertyId", "profileId")
23301///              .doit().await;
23302/// # }
23303/// ```
23304pub struct ManagementProfileGetCall<'a, C>
23305where
23306    C: 'a,
23307{
23308    hub: &'a Analytics<C>,
23309    _account_id: String,
23310    _web_property_id: String,
23311    _profile_id: String,
23312    _delegate: Option<&'a mut dyn common::Delegate>,
23313    _additional_params: HashMap<String, String>,
23314    _scopes: BTreeSet<String>,
23315}
23316
23317impl<'a, C> common::CallBuilder for ManagementProfileGetCall<'a, C> {}
23318
23319impl<'a, C> ManagementProfileGetCall<'a, C>
23320where
23321    C: common::Connector,
23322{
23323    /// Perform the operation you have build so far.
23324    pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
23325        use std::borrow::Cow;
23326        use std::io::{Read, Seek};
23327
23328        use common::{url::Params, ToParts};
23329        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23330
23331        let mut dd = common::DefaultDelegate;
23332        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23333        dlg.begin(common::MethodInfo {
23334            id: "analytics.management.profiles.get",
23335            http_method: hyper::Method::GET,
23336        });
23337
23338        for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
23339            if self._additional_params.contains_key(field) {
23340                dlg.finished(false);
23341                return Err(common::Error::FieldClash(field));
23342            }
23343        }
23344
23345        let mut params = Params::with_capacity(5 + self._additional_params.len());
23346        params.push("accountId", self._account_id);
23347        params.push("webPropertyId", self._web_property_id);
23348        params.push("profileId", self._profile_id);
23349
23350        params.extend(self._additional_params.iter());
23351
23352        params.push("alt", "json");
23353        let mut url = self.hub._base_url.clone()
23354            + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}";
23355        if self._scopes.is_empty() {
23356            self._scopes.insert(Scope::Readonly.as_ref().to_string());
23357        }
23358
23359        #[allow(clippy::single_element_loop)]
23360        for &(find_this, param_name) in [
23361            ("{accountId}", "accountId"),
23362            ("{webPropertyId}", "webPropertyId"),
23363            ("{profileId}", "profileId"),
23364        ]
23365        .iter()
23366        {
23367            url = params.uri_replacement(url, param_name, find_this, false);
23368        }
23369        {
23370            let to_remove = ["profileId", "webPropertyId", "accountId"];
23371            params.remove_params(&to_remove);
23372        }
23373
23374        let url = params.parse_with_url(&url);
23375
23376        loop {
23377            let token = match self
23378                .hub
23379                .auth
23380                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23381                .await
23382            {
23383                Ok(token) => token,
23384                Err(e) => match dlg.token(e) {
23385                    Ok(token) => token,
23386                    Err(e) => {
23387                        dlg.finished(false);
23388                        return Err(common::Error::MissingToken(e));
23389                    }
23390                },
23391            };
23392            let mut req_result = {
23393                let client = &self.hub.client;
23394                dlg.pre_request();
23395                let mut req_builder = hyper::Request::builder()
23396                    .method(hyper::Method::GET)
23397                    .uri(url.as_str())
23398                    .header(USER_AGENT, self.hub._user_agent.clone());
23399
23400                if let Some(token) = token.as_ref() {
23401                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23402                }
23403
23404                let request = req_builder
23405                    .header(CONTENT_LENGTH, 0_u64)
23406                    .body(common::to_body::<String>(None));
23407
23408                client.request(request.unwrap()).await
23409            };
23410
23411            match req_result {
23412                Err(err) => {
23413                    if let common::Retry::After(d) = dlg.http_error(&err) {
23414                        sleep(d).await;
23415                        continue;
23416                    }
23417                    dlg.finished(false);
23418                    return Err(common::Error::HttpError(err));
23419                }
23420                Ok(res) => {
23421                    let (mut parts, body) = res.into_parts();
23422                    let mut body = common::Body::new(body);
23423                    if !parts.status.is_success() {
23424                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23425                        let error = serde_json::from_str(&common::to_string(&bytes));
23426                        let response = common::to_response(parts, bytes.into());
23427
23428                        if let common::Retry::After(d) =
23429                            dlg.http_failure(&response, error.as_ref().ok())
23430                        {
23431                            sleep(d).await;
23432                            continue;
23433                        }
23434
23435                        dlg.finished(false);
23436
23437                        return Err(match error {
23438                            Ok(value) => common::Error::BadRequest(value),
23439                            _ => common::Error::Failure(response),
23440                        });
23441                    }
23442                    let response = {
23443                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23444                        let encoded = common::to_string(&bytes);
23445                        match serde_json::from_str(&encoded) {
23446                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23447                            Err(error) => {
23448                                dlg.response_json_decode_error(&encoded, &error);
23449                                return Err(common::Error::JsonDecodeError(
23450                                    encoded.to_string(),
23451                                    error,
23452                                ));
23453                            }
23454                        }
23455                    };
23456
23457                    dlg.finished(true);
23458                    return Ok(response);
23459                }
23460            }
23461        }
23462    }
23463
23464    /// Account ID to retrieve the view (profile) for.
23465    ///
23466    /// Sets the *account id* path property to the given value.
23467    ///
23468    /// Even though the property as already been set when instantiating this call,
23469    /// we provide this method for API completeness.
23470    pub fn account_id(mut self, new_value: &str) -> ManagementProfileGetCall<'a, C> {
23471        self._account_id = new_value.to_string();
23472        self
23473    }
23474    /// Web property ID to retrieve the view (profile) for.
23475    ///
23476    /// Sets the *web property id* path property to the given value.
23477    ///
23478    /// Even though the property as already been set when instantiating this call,
23479    /// we provide this method for API completeness.
23480    pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileGetCall<'a, C> {
23481        self._web_property_id = new_value.to_string();
23482        self
23483    }
23484    /// View (Profile) ID to retrieve the view (profile) for.
23485    ///
23486    /// Sets the *profile id* path property to the given value.
23487    ///
23488    /// Even though the property as already been set when instantiating this call,
23489    /// we provide this method for API completeness.
23490    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileGetCall<'a, C> {
23491        self._profile_id = new_value.to_string();
23492        self
23493    }
23494    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23495    /// while executing the actual API request.
23496    ///
23497    /// ````text
23498    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23499    /// ````
23500    ///
23501    /// Sets the *delegate* property to the given value.
23502    pub fn delegate(
23503        mut self,
23504        new_value: &'a mut dyn common::Delegate,
23505    ) -> ManagementProfileGetCall<'a, C> {
23506        self._delegate = Some(new_value);
23507        self
23508    }
23509
23510    /// Set any additional parameter of the query string used in the request.
23511    /// It should be used to set parameters which are not yet available through their own
23512    /// setters.
23513    ///
23514    /// Please note that this method must not be used to set any of the known parameters
23515    /// which have their own setter method. If done anyway, the request will fail.
23516    ///
23517    /// # Additional Parameters
23518    ///
23519    /// * *alt* (query-string) - Data format for the response.
23520    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23521    /// * *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.
23522    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23523    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23524    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23525    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23526    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileGetCall<'a, C>
23527    where
23528        T: AsRef<str>,
23529    {
23530        self._additional_params
23531            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23532        self
23533    }
23534
23535    /// Identifies the authorization scope for the method you are building.
23536    ///
23537    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23538    /// [`Scope::Readonly`].
23539    ///
23540    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23541    /// tokens for more than one scope.
23542    ///
23543    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23544    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23545    /// sufficient, a read-write scope will do as well.
23546    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileGetCall<'a, C>
23547    where
23548        St: AsRef<str>,
23549    {
23550        self._scopes.insert(String::from(scope.as_ref()));
23551        self
23552    }
23553    /// Identifies the authorization scope(s) for the method you are building.
23554    ///
23555    /// See [`Self::add_scope()`] for details.
23556    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileGetCall<'a, C>
23557    where
23558        I: IntoIterator<Item = St>,
23559        St: AsRef<str>,
23560    {
23561        self._scopes
23562            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23563        self
23564    }
23565
23566    /// Removes all scopes, and no default scope will be used either.
23567    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23568    /// for details).
23569    pub fn clear_scopes(mut self) -> ManagementProfileGetCall<'a, C> {
23570        self._scopes.clear();
23571        self
23572    }
23573}
23574
23575/// Create a new view (profile).
23576///
23577/// A builder for the *profiles.insert* method supported by a *management* resource.
23578/// It is not used directly, but through a [`ManagementMethods`] instance.
23579///
23580/// # Example
23581///
23582/// Instantiate a resource method builder
23583///
23584/// ```test_harness,no_run
23585/// # extern crate hyper;
23586/// # extern crate hyper_rustls;
23587/// # extern crate google_analytics3 as analytics3;
23588/// use analytics3::api::Profile;
23589/// # async fn dox() {
23590/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23591///
23592/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23593/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23594/// #     .with_native_roots()
23595/// #     .unwrap()
23596/// #     .https_only()
23597/// #     .enable_http2()
23598/// #     .build();
23599///
23600/// # let executor = hyper_util::rt::TokioExecutor::new();
23601/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23602/// #     secret,
23603/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23604/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23605/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23606/// #     ),
23607/// # ).build().await.unwrap();
23608///
23609/// # let client = hyper_util::client::legacy::Client::builder(
23610/// #     hyper_util::rt::TokioExecutor::new()
23611/// # )
23612/// # .build(
23613/// #     hyper_rustls::HttpsConnectorBuilder::new()
23614/// #         .with_native_roots()
23615/// #         .unwrap()
23616/// #         .https_or_http()
23617/// #         .enable_http2()
23618/// #         .build()
23619/// # );
23620/// # let mut hub = Analytics::new(client, auth);
23621/// // As the method needs a request, you would usually fill it with the desired information
23622/// // into the respective structure. Some of the parts shown here might not be applicable !
23623/// // Values shown here are possibly random and not representative !
23624/// let mut req = Profile::default();
23625///
23626/// // You can configure optional parameters by calling the respective setters at will, and
23627/// // execute the final call using `doit()`.
23628/// // Values shown here are possibly random and not representative !
23629/// let result = hub.management().profiles_insert(req, "accountId", "webPropertyId")
23630///              .doit().await;
23631/// # }
23632/// ```
23633pub struct ManagementProfileInsertCall<'a, C>
23634where
23635    C: 'a,
23636{
23637    hub: &'a Analytics<C>,
23638    _request: Profile,
23639    _account_id: String,
23640    _web_property_id: String,
23641    _delegate: Option<&'a mut dyn common::Delegate>,
23642    _additional_params: HashMap<String, String>,
23643    _scopes: BTreeSet<String>,
23644}
23645
23646impl<'a, C> common::CallBuilder for ManagementProfileInsertCall<'a, C> {}
23647
23648impl<'a, C> ManagementProfileInsertCall<'a, C>
23649where
23650    C: common::Connector,
23651{
23652    /// Perform the operation you have build so far.
23653    pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
23654        use std::borrow::Cow;
23655        use std::io::{Read, Seek};
23656
23657        use common::{url::Params, ToParts};
23658        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23659
23660        let mut dd = common::DefaultDelegate;
23661        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23662        dlg.begin(common::MethodInfo {
23663            id: "analytics.management.profiles.insert",
23664            http_method: hyper::Method::POST,
23665        });
23666
23667        for &field in ["alt", "accountId", "webPropertyId"].iter() {
23668            if self._additional_params.contains_key(field) {
23669                dlg.finished(false);
23670                return Err(common::Error::FieldClash(field));
23671            }
23672        }
23673
23674        let mut params = Params::with_capacity(5 + self._additional_params.len());
23675        params.push("accountId", self._account_id);
23676        params.push("webPropertyId", self._web_property_id);
23677
23678        params.extend(self._additional_params.iter());
23679
23680        params.push("alt", "json");
23681        let mut url = self.hub._base_url.clone()
23682            + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles";
23683        if self._scopes.is_empty() {
23684            self._scopes.insert(Scope::Edit.as_ref().to_string());
23685        }
23686
23687        #[allow(clippy::single_element_loop)]
23688        for &(find_this, param_name) in [
23689            ("{accountId}", "accountId"),
23690            ("{webPropertyId}", "webPropertyId"),
23691        ]
23692        .iter()
23693        {
23694            url = params.uri_replacement(url, param_name, find_this, false);
23695        }
23696        {
23697            let to_remove = ["webPropertyId", "accountId"];
23698            params.remove_params(&to_remove);
23699        }
23700
23701        let url = params.parse_with_url(&url);
23702
23703        let mut json_mime_type = mime::APPLICATION_JSON;
23704        let mut request_value_reader = {
23705            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23706            common::remove_json_null_values(&mut value);
23707            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23708            serde_json::to_writer(&mut dst, &value).unwrap();
23709            dst
23710        };
23711        let request_size = request_value_reader
23712            .seek(std::io::SeekFrom::End(0))
23713            .unwrap();
23714        request_value_reader
23715            .seek(std::io::SeekFrom::Start(0))
23716            .unwrap();
23717
23718        loop {
23719            let token = match self
23720                .hub
23721                .auth
23722                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23723                .await
23724            {
23725                Ok(token) => token,
23726                Err(e) => match dlg.token(e) {
23727                    Ok(token) => token,
23728                    Err(e) => {
23729                        dlg.finished(false);
23730                        return Err(common::Error::MissingToken(e));
23731                    }
23732                },
23733            };
23734            request_value_reader
23735                .seek(std::io::SeekFrom::Start(0))
23736                .unwrap();
23737            let mut req_result = {
23738                let client = &self.hub.client;
23739                dlg.pre_request();
23740                let mut req_builder = hyper::Request::builder()
23741                    .method(hyper::Method::POST)
23742                    .uri(url.as_str())
23743                    .header(USER_AGENT, self.hub._user_agent.clone());
23744
23745                if let Some(token) = token.as_ref() {
23746                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23747                }
23748
23749                let request = req_builder
23750                    .header(CONTENT_TYPE, json_mime_type.to_string())
23751                    .header(CONTENT_LENGTH, request_size as u64)
23752                    .body(common::to_body(
23753                        request_value_reader.get_ref().clone().into(),
23754                    ));
23755
23756                client.request(request.unwrap()).await
23757            };
23758
23759            match req_result {
23760                Err(err) => {
23761                    if let common::Retry::After(d) = dlg.http_error(&err) {
23762                        sleep(d).await;
23763                        continue;
23764                    }
23765                    dlg.finished(false);
23766                    return Err(common::Error::HttpError(err));
23767                }
23768                Ok(res) => {
23769                    let (mut parts, body) = res.into_parts();
23770                    let mut body = common::Body::new(body);
23771                    if !parts.status.is_success() {
23772                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23773                        let error = serde_json::from_str(&common::to_string(&bytes));
23774                        let response = common::to_response(parts, bytes.into());
23775
23776                        if let common::Retry::After(d) =
23777                            dlg.http_failure(&response, error.as_ref().ok())
23778                        {
23779                            sleep(d).await;
23780                            continue;
23781                        }
23782
23783                        dlg.finished(false);
23784
23785                        return Err(match error {
23786                            Ok(value) => common::Error::BadRequest(value),
23787                            _ => common::Error::Failure(response),
23788                        });
23789                    }
23790                    let response = {
23791                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23792                        let encoded = common::to_string(&bytes);
23793                        match serde_json::from_str(&encoded) {
23794                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23795                            Err(error) => {
23796                                dlg.response_json_decode_error(&encoded, &error);
23797                                return Err(common::Error::JsonDecodeError(
23798                                    encoded.to_string(),
23799                                    error,
23800                                ));
23801                            }
23802                        }
23803                    };
23804
23805                    dlg.finished(true);
23806                    return Ok(response);
23807                }
23808            }
23809        }
23810    }
23811
23812    ///
23813    /// Sets the *request* property to the given value.
23814    ///
23815    /// Even though the property as already been set when instantiating this call,
23816    /// we provide this method for API completeness.
23817    pub fn request(mut self, new_value: Profile) -> ManagementProfileInsertCall<'a, C> {
23818        self._request = new_value;
23819        self
23820    }
23821    /// Account ID to create the view (profile) for.
23822    ///
23823    /// Sets the *account id* path property to the given value.
23824    ///
23825    /// Even though the property as already been set when instantiating this call,
23826    /// we provide this method for API completeness.
23827    pub fn account_id(mut self, new_value: &str) -> ManagementProfileInsertCall<'a, C> {
23828        self._account_id = new_value.to_string();
23829        self
23830    }
23831    /// Web property ID to create the view (profile) for.
23832    ///
23833    /// Sets the *web property id* path property to the given value.
23834    ///
23835    /// Even though the property as already been set when instantiating this call,
23836    /// we provide this method for API completeness.
23837    pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileInsertCall<'a, C> {
23838        self._web_property_id = new_value.to_string();
23839        self
23840    }
23841    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23842    /// while executing the actual API request.
23843    ///
23844    /// ````text
23845    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23846    /// ````
23847    ///
23848    /// Sets the *delegate* property to the given value.
23849    pub fn delegate(
23850        mut self,
23851        new_value: &'a mut dyn common::Delegate,
23852    ) -> ManagementProfileInsertCall<'a, C> {
23853        self._delegate = Some(new_value);
23854        self
23855    }
23856
23857    /// Set any additional parameter of the query string used in the request.
23858    /// It should be used to set parameters which are not yet available through their own
23859    /// setters.
23860    ///
23861    /// Please note that this method must not be used to set any of the known parameters
23862    /// which have their own setter method. If done anyway, the request will fail.
23863    ///
23864    /// # Additional Parameters
23865    ///
23866    /// * *alt* (query-string) - Data format for the response.
23867    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23868    /// * *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.
23869    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23870    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23871    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23872    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23873    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileInsertCall<'a, C>
23874    where
23875        T: AsRef<str>,
23876    {
23877        self._additional_params
23878            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23879        self
23880    }
23881
23882    /// Identifies the authorization scope for the method you are building.
23883    ///
23884    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23885    /// [`Scope::Edit`].
23886    ///
23887    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23888    /// tokens for more than one scope.
23889    ///
23890    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23891    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23892    /// sufficient, a read-write scope will do as well.
23893    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileInsertCall<'a, C>
23894    where
23895        St: AsRef<str>,
23896    {
23897        self._scopes.insert(String::from(scope.as_ref()));
23898        self
23899    }
23900    /// Identifies the authorization scope(s) for the method you are building.
23901    ///
23902    /// See [`Self::add_scope()`] for details.
23903    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileInsertCall<'a, C>
23904    where
23905        I: IntoIterator<Item = St>,
23906        St: AsRef<str>,
23907    {
23908        self._scopes
23909            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23910        self
23911    }
23912
23913    /// Removes all scopes, and no default scope will be used either.
23914    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23915    /// for details).
23916    pub fn clear_scopes(mut self) -> ManagementProfileInsertCall<'a, C> {
23917        self._scopes.clear();
23918        self
23919    }
23920}
23921
23922/// Lists views (profiles) to which the user has access.
23923///
23924/// A builder for the *profiles.list* method supported by a *management* resource.
23925/// It is not used directly, but through a [`ManagementMethods`] instance.
23926///
23927/// # Example
23928///
23929/// Instantiate a resource method builder
23930///
23931/// ```test_harness,no_run
23932/// # extern crate hyper;
23933/// # extern crate hyper_rustls;
23934/// # extern crate google_analytics3 as analytics3;
23935/// # async fn dox() {
23936/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23937///
23938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23939/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23940/// #     .with_native_roots()
23941/// #     .unwrap()
23942/// #     .https_only()
23943/// #     .enable_http2()
23944/// #     .build();
23945///
23946/// # let executor = hyper_util::rt::TokioExecutor::new();
23947/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23948/// #     secret,
23949/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23950/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23951/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23952/// #     ),
23953/// # ).build().await.unwrap();
23954///
23955/// # let client = hyper_util::client::legacy::Client::builder(
23956/// #     hyper_util::rt::TokioExecutor::new()
23957/// # )
23958/// # .build(
23959/// #     hyper_rustls::HttpsConnectorBuilder::new()
23960/// #         .with_native_roots()
23961/// #         .unwrap()
23962/// #         .https_or_http()
23963/// #         .enable_http2()
23964/// #         .build()
23965/// # );
23966/// # let mut hub = Analytics::new(client, auth);
23967/// // You can configure optional parameters by calling the respective setters at will, and
23968/// // execute the final call using `doit()`.
23969/// // Values shown here are possibly random and not representative !
23970/// let result = hub.management().profiles_list("accountId", "webPropertyId")
23971///              .start_index(-53)
23972///              .max_results(-83)
23973///              .doit().await;
23974/// # }
23975/// ```
23976pub struct ManagementProfileListCall<'a, C>
23977where
23978    C: 'a,
23979{
23980    hub: &'a Analytics<C>,
23981    _account_id: String,
23982    _web_property_id: String,
23983    _start_index: Option<i32>,
23984    _max_results: Option<i32>,
23985    _delegate: Option<&'a mut dyn common::Delegate>,
23986    _additional_params: HashMap<String, String>,
23987    _scopes: BTreeSet<String>,
23988}
23989
23990impl<'a, C> common::CallBuilder for ManagementProfileListCall<'a, C> {}
23991
23992impl<'a, C> ManagementProfileListCall<'a, C>
23993where
23994    C: common::Connector,
23995{
23996    /// Perform the operation you have build so far.
23997    pub async fn doit(mut self) -> common::Result<(common::Response, Profiles)> {
23998        use std::borrow::Cow;
23999        use std::io::{Read, Seek};
24000
24001        use common::{url::Params, ToParts};
24002        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24003
24004        let mut dd = common::DefaultDelegate;
24005        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24006        dlg.begin(common::MethodInfo {
24007            id: "analytics.management.profiles.list",
24008            http_method: hyper::Method::GET,
24009        });
24010
24011        for &field in [
24012            "alt",
24013            "accountId",
24014            "webPropertyId",
24015            "start-index",
24016            "max-results",
24017        ]
24018        .iter()
24019        {
24020            if self._additional_params.contains_key(field) {
24021                dlg.finished(false);
24022                return Err(common::Error::FieldClash(field));
24023            }
24024        }
24025
24026        let mut params = Params::with_capacity(6 + self._additional_params.len());
24027        params.push("accountId", self._account_id);
24028        params.push("webPropertyId", self._web_property_id);
24029        if let Some(value) = self._start_index.as_ref() {
24030            params.push("start-index", value.to_string());
24031        }
24032        if let Some(value) = self._max_results.as_ref() {
24033            params.push("max-results", value.to_string());
24034        }
24035
24036        params.extend(self._additional_params.iter());
24037
24038        params.push("alt", "json");
24039        let mut url = self.hub._base_url.clone()
24040            + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles";
24041        if self._scopes.is_empty() {
24042            self._scopes.insert(Scope::Readonly.as_ref().to_string());
24043        }
24044
24045        #[allow(clippy::single_element_loop)]
24046        for &(find_this, param_name) in [
24047            ("{accountId}", "accountId"),
24048            ("{webPropertyId}", "webPropertyId"),
24049        ]
24050        .iter()
24051        {
24052            url = params.uri_replacement(url, param_name, find_this, false);
24053        }
24054        {
24055            let to_remove = ["webPropertyId", "accountId"];
24056            params.remove_params(&to_remove);
24057        }
24058
24059        let url = params.parse_with_url(&url);
24060
24061        loop {
24062            let token = match self
24063                .hub
24064                .auth
24065                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24066                .await
24067            {
24068                Ok(token) => token,
24069                Err(e) => match dlg.token(e) {
24070                    Ok(token) => token,
24071                    Err(e) => {
24072                        dlg.finished(false);
24073                        return Err(common::Error::MissingToken(e));
24074                    }
24075                },
24076            };
24077            let mut req_result = {
24078                let client = &self.hub.client;
24079                dlg.pre_request();
24080                let mut req_builder = hyper::Request::builder()
24081                    .method(hyper::Method::GET)
24082                    .uri(url.as_str())
24083                    .header(USER_AGENT, self.hub._user_agent.clone());
24084
24085                if let Some(token) = token.as_ref() {
24086                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24087                }
24088
24089                let request = req_builder
24090                    .header(CONTENT_LENGTH, 0_u64)
24091                    .body(common::to_body::<String>(None));
24092
24093                client.request(request.unwrap()).await
24094            };
24095
24096            match req_result {
24097                Err(err) => {
24098                    if let common::Retry::After(d) = dlg.http_error(&err) {
24099                        sleep(d).await;
24100                        continue;
24101                    }
24102                    dlg.finished(false);
24103                    return Err(common::Error::HttpError(err));
24104                }
24105                Ok(res) => {
24106                    let (mut parts, body) = res.into_parts();
24107                    let mut body = common::Body::new(body);
24108                    if !parts.status.is_success() {
24109                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24110                        let error = serde_json::from_str(&common::to_string(&bytes));
24111                        let response = common::to_response(parts, bytes.into());
24112
24113                        if let common::Retry::After(d) =
24114                            dlg.http_failure(&response, error.as_ref().ok())
24115                        {
24116                            sleep(d).await;
24117                            continue;
24118                        }
24119
24120                        dlg.finished(false);
24121
24122                        return Err(match error {
24123                            Ok(value) => common::Error::BadRequest(value),
24124                            _ => common::Error::Failure(response),
24125                        });
24126                    }
24127                    let response = {
24128                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24129                        let encoded = common::to_string(&bytes);
24130                        match serde_json::from_str(&encoded) {
24131                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24132                            Err(error) => {
24133                                dlg.response_json_decode_error(&encoded, &error);
24134                                return Err(common::Error::JsonDecodeError(
24135                                    encoded.to_string(),
24136                                    error,
24137                                ));
24138                            }
24139                        }
24140                    };
24141
24142                    dlg.finished(true);
24143                    return Ok(response);
24144                }
24145            }
24146        }
24147    }
24148
24149    /// Account ID for the view (profiles) to retrieve. Can either be a specific account ID or '~all', which refers to all the accounts to which the user has access.
24150    ///
24151    /// Sets the *account id* path property to the given value.
24152    ///
24153    /// Even though the property as already been set when instantiating this call,
24154    /// we provide this method for API completeness.
24155    pub fn account_id(mut self, new_value: &str) -> ManagementProfileListCall<'a, C> {
24156        self._account_id = new_value.to_string();
24157        self
24158    }
24159    /// Web property ID for the views (profiles) to retrieve. Can either be a specific web property ID or '~all', which refers to all the web properties to which the user has access.
24160    ///
24161    /// Sets the *web property id* path property to the given value.
24162    ///
24163    /// Even though the property as already been set when instantiating this call,
24164    /// we provide this method for API completeness.
24165    pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileListCall<'a, C> {
24166        self._web_property_id = new_value.to_string();
24167        self
24168    }
24169    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
24170    ///
24171    /// Sets the *start-index* query property to the given value.
24172    pub fn start_index(mut self, new_value: i32) -> ManagementProfileListCall<'a, C> {
24173        self._start_index = Some(new_value);
24174        self
24175    }
24176    /// The maximum number of views (profiles) to include in this response.
24177    ///
24178    /// Sets the *max-results* query property to the given value.
24179    pub fn max_results(mut self, new_value: i32) -> ManagementProfileListCall<'a, C> {
24180        self._max_results = Some(new_value);
24181        self
24182    }
24183    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24184    /// while executing the actual API request.
24185    ///
24186    /// ````text
24187    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24188    /// ````
24189    ///
24190    /// Sets the *delegate* property to the given value.
24191    pub fn delegate(
24192        mut self,
24193        new_value: &'a mut dyn common::Delegate,
24194    ) -> ManagementProfileListCall<'a, C> {
24195        self._delegate = Some(new_value);
24196        self
24197    }
24198
24199    /// Set any additional parameter of the query string used in the request.
24200    /// It should be used to set parameters which are not yet available through their own
24201    /// setters.
24202    ///
24203    /// Please note that this method must not be used to set any of the known parameters
24204    /// which have their own setter method. If done anyway, the request will fail.
24205    ///
24206    /// # Additional Parameters
24207    ///
24208    /// * *alt* (query-string) - Data format for the response.
24209    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24210    /// * *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.
24211    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24212    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24213    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24214    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24215    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileListCall<'a, C>
24216    where
24217        T: AsRef<str>,
24218    {
24219        self._additional_params
24220            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24221        self
24222    }
24223
24224    /// Identifies the authorization scope for the method you are building.
24225    ///
24226    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24227    /// [`Scope::Readonly`].
24228    ///
24229    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24230    /// tokens for more than one scope.
24231    ///
24232    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24233    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24234    /// sufficient, a read-write scope will do as well.
24235    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileListCall<'a, C>
24236    where
24237        St: AsRef<str>,
24238    {
24239        self._scopes.insert(String::from(scope.as_ref()));
24240        self
24241    }
24242    /// Identifies the authorization scope(s) for the method you are building.
24243    ///
24244    /// See [`Self::add_scope()`] for details.
24245    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileListCall<'a, C>
24246    where
24247        I: IntoIterator<Item = St>,
24248        St: AsRef<str>,
24249    {
24250        self._scopes
24251            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24252        self
24253    }
24254
24255    /// Removes all scopes, and no default scope will be used either.
24256    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24257    /// for details).
24258    pub fn clear_scopes(mut self) -> ManagementProfileListCall<'a, C> {
24259        self._scopes.clear();
24260        self
24261    }
24262}
24263
24264/// Updates an existing view (profile). This method supports patch semantics.
24265///
24266/// A builder for the *profiles.patch* method supported by a *management* resource.
24267/// It is not used directly, but through a [`ManagementMethods`] instance.
24268///
24269/// # Example
24270///
24271/// Instantiate a resource method builder
24272///
24273/// ```test_harness,no_run
24274/// # extern crate hyper;
24275/// # extern crate hyper_rustls;
24276/// # extern crate google_analytics3 as analytics3;
24277/// use analytics3::api::Profile;
24278/// # async fn dox() {
24279/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24280///
24281/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24282/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24283/// #     .with_native_roots()
24284/// #     .unwrap()
24285/// #     .https_only()
24286/// #     .enable_http2()
24287/// #     .build();
24288///
24289/// # let executor = hyper_util::rt::TokioExecutor::new();
24290/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24291/// #     secret,
24292/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24293/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24294/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24295/// #     ),
24296/// # ).build().await.unwrap();
24297///
24298/// # let client = hyper_util::client::legacy::Client::builder(
24299/// #     hyper_util::rt::TokioExecutor::new()
24300/// # )
24301/// # .build(
24302/// #     hyper_rustls::HttpsConnectorBuilder::new()
24303/// #         .with_native_roots()
24304/// #         .unwrap()
24305/// #         .https_or_http()
24306/// #         .enable_http2()
24307/// #         .build()
24308/// # );
24309/// # let mut hub = Analytics::new(client, auth);
24310/// // As the method needs a request, you would usually fill it with the desired information
24311/// // into the respective structure. Some of the parts shown here might not be applicable !
24312/// // Values shown here are possibly random and not representative !
24313/// let mut req = Profile::default();
24314///
24315/// // You can configure optional parameters by calling the respective setters at will, and
24316/// // execute the final call using `doit()`.
24317/// // Values shown here are possibly random and not representative !
24318/// let result = hub.management().profiles_patch(req, "accountId", "webPropertyId", "profileId")
24319///              .doit().await;
24320/// # }
24321/// ```
24322pub struct ManagementProfilePatchCall<'a, C>
24323where
24324    C: 'a,
24325{
24326    hub: &'a Analytics<C>,
24327    _request: Profile,
24328    _account_id: String,
24329    _web_property_id: String,
24330    _profile_id: String,
24331    _delegate: Option<&'a mut dyn common::Delegate>,
24332    _additional_params: HashMap<String, String>,
24333    _scopes: BTreeSet<String>,
24334}
24335
24336impl<'a, C> common::CallBuilder for ManagementProfilePatchCall<'a, C> {}
24337
24338impl<'a, C> ManagementProfilePatchCall<'a, C>
24339where
24340    C: common::Connector,
24341{
24342    /// Perform the operation you have build so far.
24343    pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
24344        use std::borrow::Cow;
24345        use std::io::{Read, Seek};
24346
24347        use common::{url::Params, ToParts};
24348        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24349
24350        let mut dd = common::DefaultDelegate;
24351        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24352        dlg.begin(common::MethodInfo {
24353            id: "analytics.management.profiles.patch",
24354            http_method: hyper::Method::PATCH,
24355        });
24356
24357        for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
24358            if self._additional_params.contains_key(field) {
24359                dlg.finished(false);
24360                return Err(common::Error::FieldClash(field));
24361            }
24362        }
24363
24364        let mut params = Params::with_capacity(6 + self._additional_params.len());
24365        params.push("accountId", self._account_id);
24366        params.push("webPropertyId", self._web_property_id);
24367        params.push("profileId", self._profile_id);
24368
24369        params.extend(self._additional_params.iter());
24370
24371        params.push("alt", "json");
24372        let mut url = self.hub._base_url.clone()
24373            + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}";
24374        if self._scopes.is_empty() {
24375            self._scopes.insert(Scope::Edit.as_ref().to_string());
24376        }
24377
24378        #[allow(clippy::single_element_loop)]
24379        for &(find_this, param_name) in [
24380            ("{accountId}", "accountId"),
24381            ("{webPropertyId}", "webPropertyId"),
24382            ("{profileId}", "profileId"),
24383        ]
24384        .iter()
24385        {
24386            url = params.uri_replacement(url, param_name, find_this, false);
24387        }
24388        {
24389            let to_remove = ["profileId", "webPropertyId", "accountId"];
24390            params.remove_params(&to_remove);
24391        }
24392
24393        let url = params.parse_with_url(&url);
24394
24395        let mut json_mime_type = mime::APPLICATION_JSON;
24396        let mut request_value_reader = {
24397            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24398            common::remove_json_null_values(&mut value);
24399            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24400            serde_json::to_writer(&mut dst, &value).unwrap();
24401            dst
24402        };
24403        let request_size = request_value_reader
24404            .seek(std::io::SeekFrom::End(0))
24405            .unwrap();
24406        request_value_reader
24407            .seek(std::io::SeekFrom::Start(0))
24408            .unwrap();
24409
24410        loop {
24411            let token = match self
24412                .hub
24413                .auth
24414                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24415                .await
24416            {
24417                Ok(token) => token,
24418                Err(e) => match dlg.token(e) {
24419                    Ok(token) => token,
24420                    Err(e) => {
24421                        dlg.finished(false);
24422                        return Err(common::Error::MissingToken(e));
24423                    }
24424                },
24425            };
24426            request_value_reader
24427                .seek(std::io::SeekFrom::Start(0))
24428                .unwrap();
24429            let mut req_result = {
24430                let client = &self.hub.client;
24431                dlg.pre_request();
24432                let mut req_builder = hyper::Request::builder()
24433                    .method(hyper::Method::PATCH)
24434                    .uri(url.as_str())
24435                    .header(USER_AGENT, self.hub._user_agent.clone());
24436
24437                if let Some(token) = token.as_ref() {
24438                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24439                }
24440
24441                let request = req_builder
24442                    .header(CONTENT_TYPE, json_mime_type.to_string())
24443                    .header(CONTENT_LENGTH, request_size as u64)
24444                    .body(common::to_body(
24445                        request_value_reader.get_ref().clone().into(),
24446                    ));
24447
24448                client.request(request.unwrap()).await
24449            };
24450
24451            match req_result {
24452                Err(err) => {
24453                    if let common::Retry::After(d) = dlg.http_error(&err) {
24454                        sleep(d).await;
24455                        continue;
24456                    }
24457                    dlg.finished(false);
24458                    return Err(common::Error::HttpError(err));
24459                }
24460                Ok(res) => {
24461                    let (mut parts, body) = res.into_parts();
24462                    let mut body = common::Body::new(body);
24463                    if !parts.status.is_success() {
24464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24465                        let error = serde_json::from_str(&common::to_string(&bytes));
24466                        let response = common::to_response(parts, bytes.into());
24467
24468                        if let common::Retry::After(d) =
24469                            dlg.http_failure(&response, error.as_ref().ok())
24470                        {
24471                            sleep(d).await;
24472                            continue;
24473                        }
24474
24475                        dlg.finished(false);
24476
24477                        return Err(match error {
24478                            Ok(value) => common::Error::BadRequest(value),
24479                            _ => common::Error::Failure(response),
24480                        });
24481                    }
24482                    let response = {
24483                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24484                        let encoded = common::to_string(&bytes);
24485                        match serde_json::from_str(&encoded) {
24486                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24487                            Err(error) => {
24488                                dlg.response_json_decode_error(&encoded, &error);
24489                                return Err(common::Error::JsonDecodeError(
24490                                    encoded.to_string(),
24491                                    error,
24492                                ));
24493                            }
24494                        }
24495                    };
24496
24497                    dlg.finished(true);
24498                    return Ok(response);
24499                }
24500            }
24501        }
24502    }
24503
24504    ///
24505    /// Sets the *request* property to the given value.
24506    ///
24507    /// Even though the property as already been set when instantiating this call,
24508    /// we provide this method for API completeness.
24509    pub fn request(mut self, new_value: Profile) -> ManagementProfilePatchCall<'a, C> {
24510        self._request = new_value;
24511        self
24512    }
24513    /// Account ID to which the view (profile) belongs
24514    ///
24515    /// Sets the *account id* path property to the given value.
24516    ///
24517    /// Even though the property as already been set when instantiating this call,
24518    /// we provide this method for API completeness.
24519    pub fn account_id(mut self, new_value: &str) -> ManagementProfilePatchCall<'a, C> {
24520        self._account_id = new_value.to_string();
24521        self
24522    }
24523    /// Web property ID to which the view (profile) belongs
24524    ///
24525    /// Sets the *web property id* path property to the given value.
24526    ///
24527    /// Even though the property as already been set when instantiating this call,
24528    /// we provide this method for API completeness.
24529    pub fn web_property_id(mut self, new_value: &str) -> ManagementProfilePatchCall<'a, C> {
24530        self._web_property_id = new_value.to_string();
24531        self
24532    }
24533    /// ID of the view (profile) to be updated.
24534    ///
24535    /// Sets the *profile id* path property to the given value.
24536    ///
24537    /// Even though the property as already been set when instantiating this call,
24538    /// we provide this method for API completeness.
24539    pub fn profile_id(mut self, new_value: &str) -> ManagementProfilePatchCall<'a, C> {
24540        self._profile_id = new_value.to_string();
24541        self
24542    }
24543    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24544    /// while executing the actual API request.
24545    ///
24546    /// ````text
24547    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24548    /// ````
24549    ///
24550    /// Sets the *delegate* property to the given value.
24551    pub fn delegate(
24552        mut self,
24553        new_value: &'a mut dyn common::Delegate,
24554    ) -> ManagementProfilePatchCall<'a, C> {
24555        self._delegate = Some(new_value);
24556        self
24557    }
24558
24559    /// Set any additional parameter of the query string used in the request.
24560    /// It should be used to set parameters which are not yet available through their own
24561    /// setters.
24562    ///
24563    /// Please note that this method must not be used to set any of the known parameters
24564    /// which have their own setter method. If done anyway, the request will fail.
24565    ///
24566    /// # Additional Parameters
24567    ///
24568    /// * *alt* (query-string) - Data format for the response.
24569    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24570    /// * *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.
24571    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24572    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24573    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24574    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24575    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfilePatchCall<'a, C>
24576    where
24577        T: AsRef<str>,
24578    {
24579        self._additional_params
24580            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24581        self
24582    }
24583
24584    /// Identifies the authorization scope for the method you are building.
24585    ///
24586    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24587    /// [`Scope::Edit`].
24588    ///
24589    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24590    /// tokens for more than one scope.
24591    ///
24592    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24593    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24594    /// sufficient, a read-write scope will do as well.
24595    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfilePatchCall<'a, C>
24596    where
24597        St: AsRef<str>,
24598    {
24599        self._scopes.insert(String::from(scope.as_ref()));
24600        self
24601    }
24602    /// Identifies the authorization scope(s) for the method you are building.
24603    ///
24604    /// See [`Self::add_scope()`] for details.
24605    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfilePatchCall<'a, C>
24606    where
24607        I: IntoIterator<Item = St>,
24608        St: AsRef<str>,
24609    {
24610        self._scopes
24611            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24612        self
24613    }
24614
24615    /// Removes all scopes, and no default scope will be used either.
24616    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24617    /// for details).
24618    pub fn clear_scopes(mut self) -> ManagementProfilePatchCall<'a, C> {
24619        self._scopes.clear();
24620        self
24621    }
24622}
24623
24624/// Updates an existing view (profile).
24625///
24626/// A builder for the *profiles.update* method supported by a *management* resource.
24627/// It is not used directly, but through a [`ManagementMethods`] instance.
24628///
24629/// # Example
24630///
24631/// Instantiate a resource method builder
24632///
24633/// ```test_harness,no_run
24634/// # extern crate hyper;
24635/// # extern crate hyper_rustls;
24636/// # extern crate google_analytics3 as analytics3;
24637/// use analytics3::api::Profile;
24638/// # async fn dox() {
24639/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24640///
24641/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24642/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24643/// #     .with_native_roots()
24644/// #     .unwrap()
24645/// #     .https_only()
24646/// #     .enable_http2()
24647/// #     .build();
24648///
24649/// # let executor = hyper_util::rt::TokioExecutor::new();
24650/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24651/// #     secret,
24652/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24653/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24654/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24655/// #     ),
24656/// # ).build().await.unwrap();
24657///
24658/// # let client = hyper_util::client::legacy::Client::builder(
24659/// #     hyper_util::rt::TokioExecutor::new()
24660/// # )
24661/// # .build(
24662/// #     hyper_rustls::HttpsConnectorBuilder::new()
24663/// #         .with_native_roots()
24664/// #         .unwrap()
24665/// #         .https_or_http()
24666/// #         .enable_http2()
24667/// #         .build()
24668/// # );
24669/// # let mut hub = Analytics::new(client, auth);
24670/// // As the method needs a request, you would usually fill it with the desired information
24671/// // into the respective structure. Some of the parts shown here might not be applicable !
24672/// // Values shown here are possibly random and not representative !
24673/// let mut req = Profile::default();
24674///
24675/// // You can configure optional parameters by calling the respective setters at will, and
24676/// // execute the final call using `doit()`.
24677/// // Values shown here are possibly random and not representative !
24678/// let result = hub.management().profiles_update(req, "accountId", "webPropertyId", "profileId")
24679///              .doit().await;
24680/// # }
24681/// ```
24682pub struct ManagementProfileUpdateCall<'a, C>
24683where
24684    C: 'a,
24685{
24686    hub: &'a Analytics<C>,
24687    _request: Profile,
24688    _account_id: String,
24689    _web_property_id: String,
24690    _profile_id: String,
24691    _delegate: Option<&'a mut dyn common::Delegate>,
24692    _additional_params: HashMap<String, String>,
24693    _scopes: BTreeSet<String>,
24694}
24695
24696impl<'a, C> common::CallBuilder for ManagementProfileUpdateCall<'a, C> {}
24697
24698impl<'a, C> ManagementProfileUpdateCall<'a, C>
24699where
24700    C: common::Connector,
24701{
24702    /// Perform the operation you have build so far.
24703    pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
24704        use std::borrow::Cow;
24705        use std::io::{Read, Seek};
24706
24707        use common::{url::Params, ToParts};
24708        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24709
24710        let mut dd = common::DefaultDelegate;
24711        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24712        dlg.begin(common::MethodInfo {
24713            id: "analytics.management.profiles.update",
24714            http_method: hyper::Method::PUT,
24715        });
24716
24717        for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
24718            if self._additional_params.contains_key(field) {
24719                dlg.finished(false);
24720                return Err(common::Error::FieldClash(field));
24721            }
24722        }
24723
24724        let mut params = Params::with_capacity(6 + self._additional_params.len());
24725        params.push("accountId", self._account_id);
24726        params.push("webPropertyId", self._web_property_id);
24727        params.push("profileId", self._profile_id);
24728
24729        params.extend(self._additional_params.iter());
24730
24731        params.push("alt", "json");
24732        let mut url = self.hub._base_url.clone()
24733            + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}";
24734        if self._scopes.is_empty() {
24735            self._scopes.insert(Scope::Edit.as_ref().to_string());
24736        }
24737
24738        #[allow(clippy::single_element_loop)]
24739        for &(find_this, param_name) in [
24740            ("{accountId}", "accountId"),
24741            ("{webPropertyId}", "webPropertyId"),
24742            ("{profileId}", "profileId"),
24743        ]
24744        .iter()
24745        {
24746            url = params.uri_replacement(url, param_name, find_this, false);
24747        }
24748        {
24749            let to_remove = ["profileId", "webPropertyId", "accountId"];
24750            params.remove_params(&to_remove);
24751        }
24752
24753        let url = params.parse_with_url(&url);
24754
24755        let mut json_mime_type = mime::APPLICATION_JSON;
24756        let mut request_value_reader = {
24757            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24758            common::remove_json_null_values(&mut value);
24759            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24760            serde_json::to_writer(&mut dst, &value).unwrap();
24761            dst
24762        };
24763        let request_size = request_value_reader
24764            .seek(std::io::SeekFrom::End(0))
24765            .unwrap();
24766        request_value_reader
24767            .seek(std::io::SeekFrom::Start(0))
24768            .unwrap();
24769
24770        loop {
24771            let token = match self
24772                .hub
24773                .auth
24774                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24775                .await
24776            {
24777                Ok(token) => token,
24778                Err(e) => match dlg.token(e) {
24779                    Ok(token) => token,
24780                    Err(e) => {
24781                        dlg.finished(false);
24782                        return Err(common::Error::MissingToken(e));
24783                    }
24784                },
24785            };
24786            request_value_reader
24787                .seek(std::io::SeekFrom::Start(0))
24788                .unwrap();
24789            let mut req_result = {
24790                let client = &self.hub.client;
24791                dlg.pre_request();
24792                let mut req_builder = hyper::Request::builder()
24793                    .method(hyper::Method::PUT)
24794                    .uri(url.as_str())
24795                    .header(USER_AGENT, self.hub._user_agent.clone());
24796
24797                if let Some(token) = token.as_ref() {
24798                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24799                }
24800
24801                let request = req_builder
24802                    .header(CONTENT_TYPE, json_mime_type.to_string())
24803                    .header(CONTENT_LENGTH, request_size as u64)
24804                    .body(common::to_body(
24805                        request_value_reader.get_ref().clone().into(),
24806                    ));
24807
24808                client.request(request.unwrap()).await
24809            };
24810
24811            match req_result {
24812                Err(err) => {
24813                    if let common::Retry::After(d) = dlg.http_error(&err) {
24814                        sleep(d).await;
24815                        continue;
24816                    }
24817                    dlg.finished(false);
24818                    return Err(common::Error::HttpError(err));
24819                }
24820                Ok(res) => {
24821                    let (mut parts, body) = res.into_parts();
24822                    let mut body = common::Body::new(body);
24823                    if !parts.status.is_success() {
24824                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24825                        let error = serde_json::from_str(&common::to_string(&bytes));
24826                        let response = common::to_response(parts, bytes.into());
24827
24828                        if let common::Retry::After(d) =
24829                            dlg.http_failure(&response, error.as_ref().ok())
24830                        {
24831                            sleep(d).await;
24832                            continue;
24833                        }
24834
24835                        dlg.finished(false);
24836
24837                        return Err(match error {
24838                            Ok(value) => common::Error::BadRequest(value),
24839                            _ => common::Error::Failure(response),
24840                        });
24841                    }
24842                    let response = {
24843                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24844                        let encoded = common::to_string(&bytes);
24845                        match serde_json::from_str(&encoded) {
24846                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24847                            Err(error) => {
24848                                dlg.response_json_decode_error(&encoded, &error);
24849                                return Err(common::Error::JsonDecodeError(
24850                                    encoded.to_string(),
24851                                    error,
24852                                ));
24853                            }
24854                        }
24855                    };
24856
24857                    dlg.finished(true);
24858                    return Ok(response);
24859                }
24860            }
24861        }
24862    }
24863
24864    ///
24865    /// Sets the *request* property to the given value.
24866    ///
24867    /// Even though the property as already been set when instantiating this call,
24868    /// we provide this method for API completeness.
24869    pub fn request(mut self, new_value: Profile) -> ManagementProfileUpdateCall<'a, C> {
24870        self._request = new_value;
24871        self
24872    }
24873    /// Account ID to which the view (profile) belongs
24874    ///
24875    /// Sets the *account id* path property to the given value.
24876    ///
24877    /// Even though the property as already been set when instantiating this call,
24878    /// we provide this method for API completeness.
24879    pub fn account_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C> {
24880        self._account_id = new_value.to_string();
24881        self
24882    }
24883    /// Web property ID to which the view (profile) belongs
24884    ///
24885    /// Sets the *web property id* path property to the given value.
24886    ///
24887    /// Even though the property as already been set when instantiating this call,
24888    /// we provide this method for API completeness.
24889    pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C> {
24890        self._web_property_id = new_value.to_string();
24891        self
24892    }
24893    /// ID of the view (profile) to be updated.
24894    ///
24895    /// Sets the *profile id* path property to the given value.
24896    ///
24897    /// Even though the property as already been set when instantiating this call,
24898    /// we provide this method for API completeness.
24899    pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C> {
24900        self._profile_id = new_value.to_string();
24901        self
24902    }
24903    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24904    /// while executing the actual API request.
24905    ///
24906    /// ````text
24907    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24908    /// ````
24909    ///
24910    /// Sets the *delegate* property to the given value.
24911    pub fn delegate(
24912        mut self,
24913        new_value: &'a mut dyn common::Delegate,
24914    ) -> ManagementProfileUpdateCall<'a, C> {
24915        self._delegate = Some(new_value);
24916        self
24917    }
24918
24919    /// Set any additional parameter of the query string used in the request.
24920    /// It should be used to set parameters which are not yet available through their own
24921    /// setters.
24922    ///
24923    /// Please note that this method must not be used to set any of the known parameters
24924    /// which have their own setter method. If done anyway, the request will fail.
24925    ///
24926    /// # Additional Parameters
24927    ///
24928    /// * *alt* (query-string) - Data format for the response.
24929    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24930    /// * *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.
24931    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24932    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24933    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24934    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24935    pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUpdateCall<'a, C>
24936    where
24937        T: AsRef<str>,
24938    {
24939        self._additional_params
24940            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24941        self
24942    }
24943
24944    /// Identifies the authorization scope for the method you are building.
24945    ///
24946    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24947    /// [`Scope::Edit`].
24948    ///
24949    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24950    /// tokens for more than one scope.
24951    ///
24952    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24953    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24954    /// sufficient, a read-write scope will do as well.
24955    pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUpdateCall<'a, C>
24956    where
24957        St: AsRef<str>,
24958    {
24959        self._scopes.insert(String::from(scope.as_ref()));
24960        self
24961    }
24962    /// Identifies the authorization scope(s) for the method you are building.
24963    ///
24964    /// See [`Self::add_scope()`] for details.
24965    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUpdateCall<'a, C>
24966    where
24967        I: IntoIterator<Item = St>,
24968        St: AsRef<str>,
24969    {
24970        self._scopes
24971            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24972        self
24973    }
24974
24975    /// Removes all scopes, and no default scope will be used either.
24976    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24977    /// for details).
24978    pub fn clear_scopes(mut self) -> ManagementProfileUpdateCall<'a, C> {
24979        self._scopes.clear();
24980        self
24981    }
24982}
24983
24984/// Delete a remarketing audience.
24985///
24986/// A builder for the *remarketingAudience.delete* method supported by a *management* resource.
24987/// It is not used directly, but through a [`ManagementMethods`] instance.
24988///
24989/// # Example
24990///
24991/// Instantiate a resource method builder
24992///
24993/// ```test_harness,no_run
24994/// # extern crate hyper;
24995/// # extern crate hyper_rustls;
24996/// # extern crate google_analytics3 as analytics3;
24997/// # async fn dox() {
24998/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24999///
25000/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25001/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25002/// #     .with_native_roots()
25003/// #     .unwrap()
25004/// #     .https_only()
25005/// #     .enable_http2()
25006/// #     .build();
25007///
25008/// # let executor = hyper_util::rt::TokioExecutor::new();
25009/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25010/// #     secret,
25011/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25012/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25013/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25014/// #     ),
25015/// # ).build().await.unwrap();
25016///
25017/// # let client = hyper_util::client::legacy::Client::builder(
25018/// #     hyper_util::rt::TokioExecutor::new()
25019/// # )
25020/// # .build(
25021/// #     hyper_rustls::HttpsConnectorBuilder::new()
25022/// #         .with_native_roots()
25023/// #         .unwrap()
25024/// #         .https_or_http()
25025/// #         .enable_http2()
25026/// #         .build()
25027/// # );
25028/// # let mut hub = Analytics::new(client, auth);
25029/// // You can configure optional parameters by calling the respective setters at will, and
25030/// // execute the final call using `doit()`.
25031/// // Values shown here are possibly random and not representative !
25032/// let result = hub.management().remarketing_audience_delete("accountId", "webPropertyId", "remarketingAudienceId")
25033///              .doit().await;
25034/// # }
25035/// ```
25036pub struct ManagementRemarketingAudienceDeleteCall<'a, C>
25037where
25038    C: 'a,
25039{
25040    hub: &'a Analytics<C>,
25041    _account_id: String,
25042    _web_property_id: String,
25043    _remarketing_audience_id: String,
25044    _delegate: Option<&'a mut dyn common::Delegate>,
25045    _additional_params: HashMap<String, String>,
25046    _scopes: BTreeSet<String>,
25047}
25048
25049impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceDeleteCall<'a, C> {}
25050
25051impl<'a, C> ManagementRemarketingAudienceDeleteCall<'a, C>
25052where
25053    C: common::Connector,
25054{
25055    /// Perform the operation you have build so far.
25056    pub async fn doit(mut self) -> common::Result<common::Response> {
25057        use std::borrow::Cow;
25058        use std::io::{Read, Seek};
25059
25060        use common::{url::Params, ToParts};
25061        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25062
25063        let mut dd = common::DefaultDelegate;
25064        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25065        dlg.begin(common::MethodInfo {
25066            id: "analytics.management.remarketingAudience.delete",
25067            http_method: hyper::Method::DELETE,
25068        });
25069
25070        for &field in ["accountId", "webPropertyId", "remarketingAudienceId"].iter() {
25071            if self._additional_params.contains_key(field) {
25072                dlg.finished(false);
25073                return Err(common::Error::FieldClash(field));
25074            }
25075        }
25076
25077        let mut params = Params::with_capacity(4 + self._additional_params.len());
25078        params.push("accountId", self._account_id);
25079        params.push("webPropertyId", self._web_property_id);
25080        params.push("remarketingAudienceId", self._remarketing_audience_id);
25081
25082        params.extend(self._additional_params.iter());
25083
25084        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}";
25085        if self._scopes.is_empty() {
25086            self._scopes.insert(Scope::Edit.as_ref().to_string());
25087        }
25088
25089        #[allow(clippy::single_element_loop)]
25090        for &(find_this, param_name) in [
25091            ("{accountId}", "accountId"),
25092            ("{webPropertyId}", "webPropertyId"),
25093            ("{remarketingAudienceId}", "remarketingAudienceId"),
25094        ]
25095        .iter()
25096        {
25097            url = params.uri_replacement(url, param_name, find_this, false);
25098        }
25099        {
25100            let to_remove = ["remarketingAudienceId", "webPropertyId", "accountId"];
25101            params.remove_params(&to_remove);
25102        }
25103
25104        let url = params.parse_with_url(&url);
25105
25106        loop {
25107            let token = match self
25108                .hub
25109                .auth
25110                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25111                .await
25112            {
25113                Ok(token) => token,
25114                Err(e) => match dlg.token(e) {
25115                    Ok(token) => token,
25116                    Err(e) => {
25117                        dlg.finished(false);
25118                        return Err(common::Error::MissingToken(e));
25119                    }
25120                },
25121            };
25122            let mut req_result = {
25123                let client = &self.hub.client;
25124                dlg.pre_request();
25125                let mut req_builder = hyper::Request::builder()
25126                    .method(hyper::Method::DELETE)
25127                    .uri(url.as_str())
25128                    .header(USER_AGENT, self.hub._user_agent.clone());
25129
25130                if let Some(token) = token.as_ref() {
25131                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25132                }
25133
25134                let request = req_builder
25135                    .header(CONTENT_LENGTH, 0_u64)
25136                    .body(common::to_body::<String>(None));
25137
25138                client.request(request.unwrap()).await
25139            };
25140
25141            match req_result {
25142                Err(err) => {
25143                    if let common::Retry::After(d) = dlg.http_error(&err) {
25144                        sleep(d).await;
25145                        continue;
25146                    }
25147                    dlg.finished(false);
25148                    return Err(common::Error::HttpError(err));
25149                }
25150                Ok(res) => {
25151                    let (mut parts, body) = res.into_parts();
25152                    let mut body = common::Body::new(body);
25153                    if !parts.status.is_success() {
25154                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25155                        let error = serde_json::from_str(&common::to_string(&bytes));
25156                        let response = common::to_response(parts, bytes.into());
25157
25158                        if let common::Retry::After(d) =
25159                            dlg.http_failure(&response, error.as_ref().ok())
25160                        {
25161                            sleep(d).await;
25162                            continue;
25163                        }
25164
25165                        dlg.finished(false);
25166
25167                        return Err(match error {
25168                            Ok(value) => common::Error::BadRequest(value),
25169                            _ => common::Error::Failure(response),
25170                        });
25171                    }
25172                    let response = common::Response::from_parts(parts, body);
25173
25174                    dlg.finished(true);
25175                    return Ok(response);
25176                }
25177            }
25178        }
25179    }
25180
25181    /// Account ID to which the remarketing audience belongs.
25182    ///
25183    /// Sets the *account id* path property to the given value.
25184    ///
25185    /// Even though the property as already been set when instantiating this call,
25186    /// we provide this method for API completeness.
25187    pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
25188        self._account_id = new_value.to_string();
25189        self
25190    }
25191    /// Web property ID to which the remarketing audience belongs.
25192    ///
25193    /// Sets the *web property id* path property to the given value.
25194    ///
25195    /// Even though the property as already been set when instantiating this call,
25196    /// we provide this method for API completeness.
25197    pub fn web_property_id(
25198        mut self,
25199        new_value: &str,
25200    ) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
25201        self._web_property_id = new_value.to_string();
25202        self
25203    }
25204    /// The ID of the remarketing audience to delete.
25205    ///
25206    /// Sets the *remarketing audience id* path property to the given value.
25207    ///
25208    /// Even though the property as already been set when instantiating this call,
25209    /// we provide this method for API completeness.
25210    pub fn remarketing_audience_id(
25211        mut self,
25212        new_value: &str,
25213    ) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
25214        self._remarketing_audience_id = new_value.to_string();
25215        self
25216    }
25217    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25218    /// while executing the actual API request.
25219    ///
25220    /// ````text
25221    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25222    /// ````
25223    ///
25224    /// Sets the *delegate* property to the given value.
25225    pub fn delegate(
25226        mut self,
25227        new_value: &'a mut dyn common::Delegate,
25228    ) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
25229        self._delegate = Some(new_value);
25230        self
25231    }
25232
25233    /// Set any additional parameter of the query string used in the request.
25234    /// It should be used to set parameters which are not yet available through their own
25235    /// setters.
25236    ///
25237    /// Please note that this method must not be used to set any of the known parameters
25238    /// which have their own setter method. If done anyway, the request will fail.
25239    ///
25240    /// # Additional Parameters
25241    ///
25242    /// * *alt* (query-string) - Data format for the response.
25243    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25244    /// * *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.
25245    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25246    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25247    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25248    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25249    pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceDeleteCall<'a, C>
25250    where
25251        T: AsRef<str>,
25252    {
25253        self._additional_params
25254            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25255        self
25256    }
25257
25258    /// Identifies the authorization scope for the method you are building.
25259    ///
25260    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25261    /// [`Scope::Edit`].
25262    ///
25263    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25264    /// tokens for more than one scope.
25265    ///
25266    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25267    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25268    /// sufficient, a read-write scope will do as well.
25269    pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceDeleteCall<'a, C>
25270    where
25271        St: AsRef<str>,
25272    {
25273        self._scopes.insert(String::from(scope.as_ref()));
25274        self
25275    }
25276    /// Identifies the authorization scope(s) for the method you are building.
25277    ///
25278    /// See [`Self::add_scope()`] for details.
25279    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceDeleteCall<'a, C>
25280    where
25281        I: IntoIterator<Item = St>,
25282        St: AsRef<str>,
25283    {
25284        self._scopes
25285            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25286        self
25287    }
25288
25289    /// Removes all scopes, and no default scope will be used either.
25290    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25291    /// for details).
25292    pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
25293        self._scopes.clear();
25294        self
25295    }
25296}
25297
25298/// Gets a remarketing audience to which the user has access.
25299///
25300/// A builder for the *remarketingAudience.get* method supported by a *management* resource.
25301/// It is not used directly, but through a [`ManagementMethods`] instance.
25302///
25303/// # Example
25304///
25305/// Instantiate a resource method builder
25306///
25307/// ```test_harness,no_run
25308/// # extern crate hyper;
25309/// # extern crate hyper_rustls;
25310/// # extern crate google_analytics3 as analytics3;
25311/// # async fn dox() {
25312/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25313///
25314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25315/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25316/// #     .with_native_roots()
25317/// #     .unwrap()
25318/// #     .https_only()
25319/// #     .enable_http2()
25320/// #     .build();
25321///
25322/// # let executor = hyper_util::rt::TokioExecutor::new();
25323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25324/// #     secret,
25325/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25326/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25327/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25328/// #     ),
25329/// # ).build().await.unwrap();
25330///
25331/// # let client = hyper_util::client::legacy::Client::builder(
25332/// #     hyper_util::rt::TokioExecutor::new()
25333/// # )
25334/// # .build(
25335/// #     hyper_rustls::HttpsConnectorBuilder::new()
25336/// #         .with_native_roots()
25337/// #         .unwrap()
25338/// #         .https_or_http()
25339/// #         .enable_http2()
25340/// #         .build()
25341/// # );
25342/// # let mut hub = Analytics::new(client, auth);
25343/// // You can configure optional parameters by calling the respective setters at will, and
25344/// // execute the final call using `doit()`.
25345/// // Values shown here are possibly random and not representative !
25346/// let result = hub.management().remarketing_audience_get("accountId", "webPropertyId", "remarketingAudienceId")
25347///              .doit().await;
25348/// # }
25349/// ```
25350pub struct ManagementRemarketingAudienceGetCall<'a, C>
25351where
25352    C: 'a,
25353{
25354    hub: &'a Analytics<C>,
25355    _account_id: String,
25356    _web_property_id: String,
25357    _remarketing_audience_id: String,
25358    _delegate: Option<&'a mut dyn common::Delegate>,
25359    _additional_params: HashMap<String, String>,
25360    _scopes: BTreeSet<String>,
25361}
25362
25363impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceGetCall<'a, C> {}
25364
25365impl<'a, C> ManagementRemarketingAudienceGetCall<'a, C>
25366where
25367    C: common::Connector,
25368{
25369    /// Perform the operation you have build so far.
25370    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudience)> {
25371        use std::borrow::Cow;
25372        use std::io::{Read, Seek};
25373
25374        use common::{url::Params, ToParts};
25375        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25376
25377        let mut dd = common::DefaultDelegate;
25378        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25379        dlg.begin(common::MethodInfo {
25380            id: "analytics.management.remarketingAudience.get",
25381            http_method: hyper::Method::GET,
25382        });
25383
25384        for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() {
25385            if self._additional_params.contains_key(field) {
25386                dlg.finished(false);
25387                return Err(common::Error::FieldClash(field));
25388            }
25389        }
25390
25391        let mut params = Params::with_capacity(5 + self._additional_params.len());
25392        params.push("accountId", self._account_id);
25393        params.push("webPropertyId", self._web_property_id);
25394        params.push("remarketingAudienceId", self._remarketing_audience_id);
25395
25396        params.extend(self._additional_params.iter());
25397
25398        params.push("alt", "json");
25399        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}";
25400        if self._scopes.is_empty() {
25401            self._scopes.insert(Scope::Readonly.as_ref().to_string());
25402        }
25403
25404        #[allow(clippy::single_element_loop)]
25405        for &(find_this, param_name) in [
25406            ("{accountId}", "accountId"),
25407            ("{webPropertyId}", "webPropertyId"),
25408            ("{remarketingAudienceId}", "remarketingAudienceId"),
25409        ]
25410        .iter()
25411        {
25412            url = params.uri_replacement(url, param_name, find_this, false);
25413        }
25414        {
25415            let to_remove = ["remarketingAudienceId", "webPropertyId", "accountId"];
25416            params.remove_params(&to_remove);
25417        }
25418
25419        let url = params.parse_with_url(&url);
25420
25421        loop {
25422            let token = match self
25423                .hub
25424                .auth
25425                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25426                .await
25427            {
25428                Ok(token) => token,
25429                Err(e) => match dlg.token(e) {
25430                    Ok(token) => token,
25431                    Err(e) => {
25432                        dlg.finished(false);
25433                        return Err(common::Error::MissingToken(e));
25434                    }
25435                },
25436            };
25437            let mut req_result = {
25438                let client = &self.hub.client;
25439                dlg.pre_request();
25440                let mut req_builder = hyper::Request::builder()
25441                    .method(hyper::Method::GET)
25442                    .uri(url.as_str())
25443                    .header(USER_AGENT, self.hub._user_agent.clone());
25444
25445                if let Some(token) = token.as_ref() {
25446                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25447                }
25448
25449                let request = req_builder
25450                    .header(CONTENT_LENGTH, 0_u64)
25451                    .body(common::to_body::<String>(None));
25452
25453                client.request(request.unwrap()).await
25454            };
25455
25456            match req_result {
25457                Err(err) => {
25458                    if let common::Retry::After(d) = dlg.http_error(&err) {
25459                        sleep(d).await;
25460                        continue;
25461                    }
25462                    dlg.finished(false);
25463                    return Err(common::Error::HttpError(err));
25464                }
25465                Ok(res) => {
25466                    let (mut parts, body) = res.into_parts();
25467                    let mut body = common::Body::new(body);
25468                    if !parts.status.is_success() {
25469                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25470                        let error = serde_json::from_str(&common::to_string(&bytes));
25471                        let response = common::to_response(parts, bytes.into());
25472
25473                        if let common::Retry::After(d) =
25474                            dlg.http_failure(&response, error.as_ref().ok())
25475                        {
25476                            sleep(d).await;
25477                            continue;
25478                        }
25479
25480                        dlg.finished(false);
25481
25482                        return Err(match error {
25483                            Ok(value) => common::Error::BadRequest(value),
25484                            _ => common::Error::Failure(response),
25485                        });
25486                    }
25487                    let response = {
25488                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25489                        let encoded = common::to_string(&bytes);
25490                        match serde_json::from_str(&encoded) {
25491                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25492                            Err(error) => {
25493                                dlg.response_json_decode_error(&encoded, &error);
25494                                return Err(common::Error::JsonDecodeError(
25495                                    encoded.to_string(),
25496                                    error,
25497                                ));
25498                            }
25499                        }
25500                    };
25501
25502                    dlg.finished(true);
25503                    return Ok(response);
25504                }
25505            }
25506        }
25507    }
25508
25509    /// The account ID of the remarketing audience to retrieve.
25510    ///
25511    /// Sets the *account id* path property to the given value.
25512    ///
25513    /// Even though the property as already been set when instantiating this call,
25514    /// we provide this method for API completeness.
25515    pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceGetCall<'a, C> {
25516        self._account_id = new_value.to_string();
25517        self
25518    }
25519    /// The web property ID of the remarketing audience to retrieve.
25520    ///
25521    /// Sets the *web property id* path property to the given value.
25522    ///
25523    /// Even though the property as already been set when instantiating this call,
25524    /// we provide this method for API completeness.
25525    pub fn web_property_id(
25526        mut self,
25527        new_value: &str,
25528    ) -> ManagementRemarketingAudienceGetCall<'a, C> {
25529        self._web_property_id = new_value.to_string();
25530        self
25531    }
25532    /// The ID of the remarketing audience to retrieve.
25533    ///
25534    /// Sets the *remarketing audience id* path property to the given value.
25535    ///
25536    /// Even though the property as already been set when instantiating this call,
25537    /// we provide this method for API completeness.
25538    pub fn remarketing_audience_id(
25539        mut self,
25540        new_value: &str,
25541    ) -> ManagementRemarketingAudienceGetCall<'a, C> {
25542        self._remarketing_audience_id = new_value.to_string();
25543        self
25544    }
25545    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25546    /// while executing the actual API request.
25547    ///
25548    /// ````text
25549    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25550    /// ````
25551    ///
25552    /// Sets the *delegate* property to the given value.
25553    pub fn delegate(
25554        mut self,
25555        new_value: &'a mut dyn common::Delegate,
25556    ) -> ManagementRemarketingAudienceGetCall<'a, C> {
25557        self._delegate = Some(new_value);
25558        self
25559    }
25560
25561    /// Set any additional parameter of the query string used in the request.
25562    /// It should be used to set parameters which are not yet available through their own
25563    /// setters.
25564    ///
25565    /// Please note that this method must not be used to set any of the known parameters
25566    /// which have their own setter method. If done anyway, the request will fail.
25567    ///
25568    /// # Additional Parameters
25569    ///
25570    /// * *alt* (query-string) - Data format for the response.
25571    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25572    /// * *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.
25573    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25574    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25575    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25576    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25577    pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceGetCall<'a, C>
25578    where
25579        T: AsRef<str>,
25580    {
25581        self._additional_params
25582            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25583        self
25584    }
25585
25586    /// Identifies the authorization scope for the method you are building.
25587    ///
25588    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25589    /// [`Scope::Readonly`].
25590    ///
25591    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25592    /// tokens for more than one scope.
25593    ///
25594    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25595    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25596    /// sufficient, a read-write scope will do as well.
25597    pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceGetCall<'a, C>
25598    where
25599        St: AsRef<str>,
25600    {
25601        self._scopes.insert(String::from(scope.as_ref()));
25602        self
25603    }
25604    /// Identifies the authorization scope(s) for the method you are building.
25605    ///
25606    /// See [`Self::add_scope()`] for details.
25607    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceGetCall<'a, C>
25608    where
25609        I: IntoIterator<Item = St>,
25610        St: AsRef<str>,
25611    {
25612        self._scopes
25613            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25614        self
25615    }
25616
25617    /// Removes all scopes, and no default scope will be used either.
25618    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25619    /// for details).
25620    pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceGetCall<'a, C> {
25621        self._scopes.clear();
25622        self
25623    }
25624}
25625
25626/// Creates a new remarketing audience.
25627///
25628/// A builder for the *remarketingAudience.insert* method supported by a *management* resource.
25629/// It is not used directly, but through a [`ManagementMethods`] instance.
25630///
25631/// # Example
25632///
25633/// Instantiate a resource method builder
25634///
25635/// ```test_harness,no_run
25636/// # extern crate hyper;
25637/// # extern crate hyper_rustls;
25638/// # extern crate google_analytics3 as analytics3;
25639/// use analytics3::api::RemarketingAudience;
25640/// # async fn dox() {
25641/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25642///
25643/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25644/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25645/// #     .with_native_roots()
25646/// #     .unwrap()
25647/// #     .https_only()
25648/// #     .enable_http2()
25649/// #     .build();
25650///
25651/// # let executor = hyper_util::rt::TokioExecutor::new();
25652/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25653/// #     secret,
25654/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25655/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25656/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25657/// #     ),
25658/// # ).build().await.unwrap();
25659///
25660/// # let client = hyper_util::client::legacy::Client::builder(
25661/// #     hyper_util::rt::TokioExecutor::new()
25662/// # )
25663/// # .build(
25664/// #     hyper_rustls::HttpsConnectorBuilder::new()
25665/// #         .with_native_roots()
25666/// #         .unwrap()
25667/// #         .https_or_http()
25668/// #         .enable_http2()
25669/// #         .build()
25670/// # );
25671/// # let mut hub = Analytics::new(client, auth);
25672/// // As the method needs a request, you would usually fill it with the desired information
25673/// // into the respective structure. Some of the parts shown here might not be applicable !
25674/// // Values shown here are possibly random and not representative !
25675/// let mut req = RemarketingAudience::default();
25676///
25677/// // You can configure optional parameters by calling the respective setters at will, and
25678/// // execute the final call using `doit()`.
25679/// // Values shown here are possibly random and not representative !
25680/// let result = hub.management().remarketing_audience_insert(req, "accountId", "webPropertyId")
25681///              .doit().await;
25682/// # }
25683/// ```
25684pub struct ManagementRemarketingAudienceInsertCall<'a, C>
25685where
25686    C: 'a,
25687{
25688    hub: &'a Analytics<C>,
25689    _request: RemarketingAudience,
25690    _account_id: String,
25691    _web_property_id: String,
25692    _delegate: Option<&'a mut dyn common::Delegate>,
25693    _additional_params: HashMap<String, String>,
25694    _scopes: BTreeSet<String>,
25695}
25696
25697impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceInsertCall<'a, C> {}
25698
25699impl<'a, C> ManagementRemarketingAudienceInsertCall<'a, C>
25700where
25701    C: common::Connector,
25702{
25703    /// Perform the operation you have build so far.
25704    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudience)> {
25705        use std::borrow::Cow;
25706        use std::io::{Read, Seek};
25707
25708        use common::{url::Params, ToParts};
25709        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25710
25711        let mut dd = common::DefaultDelegate;
25712        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25713        dlg.begin(common::MethodInfo {
25714            id: "analytics.management.remarketingAudience.insert",
25715            http_method: hyper::Method::POST,
25716        });
25717
25718        for &field in ["alt", "accountId", "webPropertyId"].iter() {
25719            if self._additional_params.contains_key(field) {
25720                dlg.finished(false);
25721                return Err(common::Error::FieldClash(field));
25722            }
25723        }
25724
25725        let mut params = Params::with_capacity(5 + self._additional_params.len());
25726        params.push("accountId", self._account_id);
25727        params.push("webPropertyId", self._web_property_id);
25728
25729        params.extend(self._additional_params.iter());
25730
25731        params.push("alt", "json");
25732        let mut url = self.hub._base_url.clone()
25733            + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences";
25734        if self._scopes.is_empty() {
25735            self._scopes.insert(Scope::Edit.as_ref().to_string());
25736        }
25737
25738        #[allow(clippy::single_element_loop)]
25739        for &(find_this, param_name) in [
25740            ("{accountId}", "accountId"),
25741            ("{webPropertyId}", "webPropertyId"),
25742        ]
25743        .iter()
25744        {
25745            url = params.uri_replacement(url, param_name, find_this, false);
25746        }
25747        {
25748            let to_remove = ["webPropertyId", "accountId"];
25749            params.remove_params(&to_remove);
25750        }
25751
25752        let url = params.parse_with_url(&url);
25753
25754        let mut json_mime_type = mime::APPLICATION_JSON;
25755        let mut request_value_reader = {
25756            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25757            common::remove_json_null_values(&mut value);
25758            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25759            serde_json::to_writer(&mut dst, &value).unwrap();
25760            dst
25761        };
25762        let request_size = request_value_reader
25763            .seek(std::io::SeekFrom::End(0))
25764            .unwrap();
25765        request_value_reader
25766            .seek(std::io::SeekFrom::Start(0))
25767            .unwrap();
25768
25769        loop {
25770            let token = match self
25771                .hub
25772                .auth
25773                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25774                .await
25775            {
25776                Ok(token) => token,
25777                Err(e) => match dlg.token(e) {
25778                    Ok(token) => token,
25779                    Err(e) => {
25780                        dlg.finished(false);
25781                        return Err(common::Error::MissingToken(e));
25782                    }
25783                },
25784            };
25785            request_value_reader
25786                .seek(std::io::SeekFrom::Start(0))
25787                .unwrap();
25788            let mut req_result = {
25789                let client = &self.hub.client;
25790                dlg.pre_request();
25791                let mut req_builder = hyper::Request::builder()
25792                    .method(hyper::Method::POST)
25793                    .uri(url.as_str())
25794                    .header(USER_AGENT, self.hub._user_agent.clone());
25795
25796                if let Some(token) = token.as_ref() {
25797                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25798                }
25799
25800                let request = req_builder
25801                    .header(CONTENT_TYPE, json_mime_type.to_string())
25802                    .header(CONTENT_LENGTH, request_size as u64)
25803                    .body(common::to_body(
25804                        request_value_reader.get_ref().clone().into(),
25805                    ));
25806
25807                client.request(request.unwrap()).await
25808            };
25809
25810            match req_result {
25811                Err(err) => {
25812                    if let common::Retry::After(d) = dlg.http_error(&err) {
25813                        sleep(d).await;
25814                        continue;
25815                    }
25816                    dlg.finished(false);
25817                    return Err(common::Error::HttpError(err));
25818                }
25819                Ok(res) => {
25820                    let (mut parts, body) = res.into_parts();
25821                    let mut body = common::Body::new(body);
25822                    if !parts.status.is_success() {
25823                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25824                        let error = serde_json::from_str(&common::to_string(&bytes));
25825                        let response = common::to_response(parts, bytes.into());
25826
25827                        if let common::Retry::After(d) =
25828                            dlg.http_failure(&response, error.as_ref().ok())
25829                        {
25830                            sleep(d).await;
25831                            continue;
25832                        }
25833
25834                        dlg.finished(false);
25835
25836                        return Err(match error {
25837                            Ok(value) => common::Error::BadRequest(value),
25838                            _ => common::Error::Failure(response),
25839                        });
25840                    }
25841                    let response = {
25842                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25843                        let encoded = common::to_string(&bytes);
25844                        match serde_json::from_str(&encoded) {
25845                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25846                            Err(error) => {
25847                                dlg.response_json_decode_error(&encoded, &error);
25848                                return Err(common::Error::JsonDecodeError(
25849                                    encoded.to_string(),
25850                                    error,
25851                                ));
25852                            }
25853                        }
25854                    };
25855
25856                    dlg.finished(true);
25857                    return Ok(response);
25858                }
25859            }
25860        }
25861    }
25862
25863    ///
25864    /// Sets the *request* property to the given value.
25865    ///
25866    /// Even though the property as already been set when instantiating this call,
25867    /// we provide this method for API completeness.
25868    pub fn request(
25869        mut self,
25870        new_value: RemarketingAudience,
25871    ) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25872        self._request = new_value;
25873        self
25874    }
25875    /// The account ID for which to create the remarketing audience.
25876    ///
25877    /// Sets the *account id* path property to the given value.
25878    ///
25879    /// Even though the property as already been set when instantiating this call,
25880    /// we provide this method for API completeness.
25881    pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25882        self._account_id = new_value.to_string();
25883        self
25884    }
25885    /// Web property ID for which to create the remarketing audience.
25886    ///
25887    /// Sets the *web property id* path property to the given value.
25888    ///
25889    /// Even though the property as already been set when instantiating this call,
25890    /// we provide this method for API completeness.
25891    pub fn web_property_id(
25892        mut self,
25893        new_value: &str,
25894    ) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25895        self._web_property_id = new_value.to_string();
25896        self
25897    }
25898    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25899    /// while executing the actual API request.
25900    ///
25901    /// ````text
25902    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25903    /// ````
25904    ///
25905    /// Sets the *delegate* property to the given value.
25906    pub fn delegate(
25907        mut self,
25908        new_value: &'a mut dyn common::Delegate,
25909    ) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25910        self._delegate = Some(new_value);
25911        self
25912    }
25913
25914    /// Set any additional parameter of the query string used in the request.
25915    /// It should be used to set parameters which are not yet available through their own
25916    /// setters.
25917    ///
25918    /// Please note that this method must not be used to set any of the known parameters
25919    /// which have their own setter method. If done anyway, the request will fail.
25920    ///
25921    /// # Additional Parameters
25922    ///
25923    /// * *alt* (query-string) - Data format for the response.
25924    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25925    /// * *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.
25926    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25927    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25928    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25929    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25930    pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceInsertCall<'a, C>
25931    where
25932        T: AsRef<str>,
25933    {
25934        self._additional_params
25935            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25936        self
25937    }
25938
25939    /// Identifies the authorization scope for the method you are building.
25940    ///
25941    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25942    /// [`Scope::Edit`].
25943    ///
25944    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25945    /// tokens for more than one scope.
25946    ///
25947    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25948    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25949    /// sufficient, a read-write scope will do as well.
25950    pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceInsertCall<'a, C>
25951    where
25952        St: AsRef<str>,
25953    {
25954        self._scopes.insert(String::from(scope.as_ref()));
25955        self
25956    }
25957    /// Identifies the authorization scope(s) for the method you are building.
25958    ///
25959    /// See [`Self::add_scope()`] for details.
25960    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceInsertCall<'a, C>
25961    where
25962        I: IntoIterator<Item = St>,
25963        St: AsRef<str>,
25964    {
25965        self._scopes
25966            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25967        self
25968    }
25969
25970    /// Removes all scopes, and no default scope will be used either.
25971    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25972    /// for details).
25973    pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25974        self._scopes.clear();
25975        self
25976    }
25977}
25978
25979/// Lists remarketing audiences to which the user has access.
25980///
25981/// A builder for the *remarketingAudience.list* method supported by a *management* resource.
25982/// It is not used directly, but through a [`ManagementMethods`] instance.
25983///
25984/// # Example
25985///
25986/// Instantiate a resource method builder
25987///
25988/// ```test_harness,no_run
25989/// # extern crate hyper;
25990/// # extern crate hyper_rustls;
25991/// # extern crate google_analytics3 as analytics3;
25992/// # async fn dox() {
25993/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25994///
25995/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25996/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25997/// #     .with_native_roots()
25998/// #     .unwrap()
25999/// #     .https_only()
26000/// #     .enable_http2()
26001/// #     .build();
26002///
26003/// # let executor = hyper_util::rt::TokioExecutor::new();
26004/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26005/// #     secret,
26006/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26007/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26008/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26009/// #     ),
26010/// # ).build().await.unwrap();
26011///
26012/// # let client = hyper_util::client::legacy::Client::builder(
26013/// #     hyper_util::rt::TokioExecutor::new()
26014/// # )
26015/// # .build(
26016/// #     hyper_rustls::HttpsConnectorBuilder::new()
26017/// #         .with_native_roots()
26018/// #         .unwrap()
26019/// #         .https_or_http()
26020/// #         .enable_http2()
26021/// #         .build()
26022/// # );
26023/// # let mut hub = Analytics::new(client, auth);
26024/// // You can configure optional parameters by calling the respective setters at will, and
26025/// // execute the final call using `doit()`.
26026/// // Values shown here are possibly random and not representative !
26027/// let result = hub.management().remarketing_audience_list("accountId", "webPropertyId")
26028///              .type_("eos")
26029///              .start_index(-52)
26030///              .max_results(-84)
26031///              .doit().await;
26032/// # }
26033/// ```
26034pub struct ManagementRemarketingAudienceListCall<'a, C>
26035where
26036    C: 'a,
26037{
26038    hub: &'a Analytics<C>,
26039    _account_id: String,
26040    _web_property_id: String,
26041    _type_: Option<String>,
26042    _start_index: Option<i32>,
26043    _max_results: Option<i32>,
26044    _delegate: Option<&'a mut dyn common::Delegate>,
26045    _additional_params: HashMap<String, String>,
26046    _scopes: BTreeSet<String>,
26047}
26048
26049impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceListCall<'a, C> {}
26050
26051impl<'a, C> ManagementRemarketingAudienceListCall<'a, C>
26052where
26053    C: common::Connector,
26054{
26055    /// Perform the operation you have build so far.
26056    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudiences)> {
26057        use std::borrow::Cow;
26058        use std::io::{Read, Seek};
26059
26060        use common::{url::Params, ToParts};
26061        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26062
26063        let mut dd = common::DefaultDelegate;
26064        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26065        dlg.begin(common::MethodInfo {
26066            id: "analytics.management.remarketingAudience.list",
26067            http_method: hyper::Method::GET,
26068        });
26069
26070        for &field in [
26071            "alt",
26072            "accountId",
26073            "webPropertyId",
26074            "type",
26075            "start-index",
26076            "max-results",
26077        ]
26078        .iter()
26079        {
26080            if self._additional_params.contains_key(field) {
26081                dlg.finished(false);
26082                return Err(common::Error::FieldClash(field));
26083            }
26084        }
26085
26086        let mut params = Params::with_capacity(7 + self._additional_params.len());
26087        params.push("accountId", self._account_id);
26088        params.push("webPropertyId", self._web_property_id);
26089        if let Some(value) = self._type_.as_ref() {
26090            params.push("type", value);
26091        }
26092        if let Some(value) = self._start_index.as_ref() {
26093            params.push("start-index", value.to_string());
26094        }
26095        if let Some(value) = self._max_results.as_ref() {
26096            params.push("max-results", value.to_string());
26097        }
26098
26099        params.extend(self._additional_params.iter());
26100
26101        params.push("alt", "json");
26102        let mut url = self.hub._base_url.clone()
26103            + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences";
26104        if self._scopes.is_empty() {
26105            self._scopes.insert(Scope::Readonly.as_ref().to_string());
26106        }
26107
26108        #[allow(clippy::single_element_loop)]
26109        for &(find_this, param_name) in [
26110            ("{accountId}", "accountId"),
26111            ("{webPropertyId}", "webPropertyId"),
26112        ]
26113        .iter()
26114        {
26115            url = params.uri_replacement(url, param_name, find_this, false);
26116        }
26117        {
26118            let to_remove = ["webPropertyId", "accountId"];
26119            params.remove_params(&to_remove);
26120        }
26121
26122        let url = params.parse_with_url(&url);
26123
26124        loop {
26125            let token = match self
26126                .hub
26127                .auth
26128                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26129                .await
26130            {
26131                Ok(token) => token,
26132                Err(e) => match dlg.token(e) {
26133                    Ok(token) => token,
26134                    Err(e) => {
26135                        dlg.finished(false);
26136                        return Err(common::Error::MissingToken(e));
26137                    }
26138                },
26139            };
26140            let mut req_result = {
26141                let client = &self.hub.client;
26142                dlg.pre_request();
26143                let mut req_builder = hyper::Request::builder()
26144                    .method(hyper::Method::GET)
26145                    .uri(url.as_str())
26146                    .header(USER_AGENT, self.hub._user_agent.clone());
26147
26148                if let Some(token) = token.as_ref() {
26149                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26150                }
26151
26152                let request = req_builder
26153                    .header(CONTENT_LENGTH, 0_u64)
26154                    .body(common::to_body::<String>(None));
26155
26156                client.request(request.unwrap()).await
26157            };
26158
26159            match req_result {
26160                Err(err) => {
26161                    if let common::Retry::After(d) = dlg.http_error(&err) {
26162                        sleep(d).await;
26163                        continue;
26164                    }
26165                    dlg.finished(false);
26166                    return Err(common::Error::HttpError(err));
26167                }
26168                Ok(res) => {
26169                    let (mut parts, body) = res.into_parts();
26170                    let mut body = common::Body::new(body);
26171                    if !parts.status.is_success() {
26172                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26173                        let error = serde_json::from_str(&common::to_string(&bytes));
26174                        let response = common::to_response(parts, bytes.into());
26175
26176                        if let common::Retry::After(d) =
26177                            dlg.http_failure(&response, error.as_ref().ok())
26178                        {
26179                            sleep(d).await;
26180                            continue;
26181                        }
26182
26183                        dlg.finished(false);
26184
26185                        return Err(match error {
26186                            Ok(value) => common::Error::BadRequest(value),
26187                            _ => common::Error::Failure(response),
26188                        });
26189                    }
26190                    let response = {
26191                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26192                        let encoded = common::to_string(&bytes);
26193                        match serde_json::from_str(&encoded) {
26194                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26195                            Err(error) => {
26196                                dlg.response_json_decode_error(&encoded, &error);
26197                                return Err(common::Error::JsonDecodeError(
26198                                    encoded.to_string(),
26199                                    error,
26200                                ));
26201                            }
26202                        }
26203                    };
26204
26205                    dlg.finished(true);
26206                    return Ok(response);
26207                }
26208            }
26209        }
26210    }
26211
26212    /// The account ID of the remarketing audiences to retrieve.
26213    ///
26214    /// Sets the *account id* path property to the given value.
26215    ///
26216    /// Even though the property as already been set when instantiating this call,
26217    /// we provide this method for API completeness.
26218    pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceListCall<'a, C> {
26219        self._account_id = new_value.to_string();
26220        self
26221    }
26222    /// The web property ID of the remarketing audiences to retrieve.
26223    ///
26224    /// Sets the *web property id* path property to the given value.
26225    ///
26226    /// Even though the property as already been set when instantiating this call,
26227    /// we provide this method for API completeness.
26228    pub fn web_property_id(
26229        mut self,
26230        new_value: &str,
26231    ) -> ManagementRemarketingAudienceListCall<'a, C> {
26232        self._web_property_id = new_value.to_string();
26233        self
26234    }
26235    ///
26236    /// Sets the *type* query property to the given value.
26237    pub fn type_(mut self, new_value: &str) -> ManagementRemarketingAudienceListCall<'a, C> {
26238        self._type_ = Some(new_value.to_string());
26239        self
26240    }
26241    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
26242    ///
26243    /// Sets the *start-index* query property to the given value.
26244    pub fn start_index(mut self, new_value: i32) -> ManagementRemarketingAudienceListCall<'a, C> {
26245        self._start_index = Some(new_value);
26246        self
26247    }
26248    /// The maximum number of remarketing audiences to include in this response.
26249    ///
26250    /// Sets the *max-results* query property to the given value.
26251    pub fn max_results(mut self, new_value: i32) -> ManagementRemarketingAudienceListCall<'a, C> {
26252        self._max_results = Some(new_value);
26253        self
26254    }
26255    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26256    /// while executing the actual API request.
26257    ///
26258    /// ````text
26259    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26260    /// ````
26261    ///
26262    /// Sets the *delegate* property to the given value.
26263    pub fn delegate(
26264        mut self,
26265        new_value: &'a mut dyn common::Delegate,
26266    ) -> ManagementRemarketingAudienceListCall<'a, C> {
26267        self._delegate = Some(new_value);
26268        self
26269    }
26270
26271    /// Set any additional parameter of the query string used in the request.
26272    /// It should be used to set parameters which are not yet available through their own
26273    /// setters.
26274    ///
26275    /// Please note that this method must not be used to set any of the known parameters
26276    /// which have their own setter method. If done anyway, the request will fail.
26277    ///
26278    /// # Additional Parameters
26279    ///
26280    /// * *alt* (query-string) - Data format for the response.
26281    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26282    /// * *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.
26283    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26284    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26285    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26286    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26287    pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceListCall<'a, C>
26288    where
26289        T: AsRef<str>,
26290    {
26291        self._additional_params
26292            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26293        self
26294    }
26295
26296    /// Identifies the authorization scope for the method you are building.
26297    ///
26298    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26299    /// [`Scope::Readonly`].
26300    ///
26301    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26302    /// tokens for more than one scope.
26303    ///
26304    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26305    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26306    /// sufficient, a read-write scope will do as well.
26307    pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceListCall<'a, C>
26308    where
26309        St: AsRef<str>,
26310    {
26311        self._scopes.insert(String::from(scope.as_ref()));
26312        self
26313    }
26314    /// Identifies the authorization scope(s) for the method you are building.
26315    ///
26316    /// See [`Self::add_scope()`] for details.
26317    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceListCall<'a, C>
26318    where
26319        I: IntoIterator<Item = St>,
26320        St: AsRef<str>,
26321    {
26322        self._scopes
26323            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26324        self
26325    }
26326
26327    /// Removes all scopes, and no default scope will be used either.
26328    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26329    /// for details).
26330    pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceListCall<'a, C> {
26331        self._scopes.clear();
26332        self
26333    }
26334}
26335
26336/// Updates an existing remarketing audience. This method supports patch semantics.
26337///
26338/// A builder for the *remarketingAudience.patch* method supported by a *management* resource.
26339/// It is not used directly, but through a [`ManagementMethods`] instance.
26340///
26341/// # Example
26342///
26343/// Instantiate a resource method builder
26344///
26345/// ```test_harness,no_run
26346/// # extern crate hyper;
26347/// # extern crate hyper_rustls;
26348/// # extern crate google_analytics3 as analytics3;
26349/// use analytics3::api::RemarketingAudience;
26350/// # async fn dox() {
26351/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26352///
26353/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26354/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26355/// #     .with_native_roots()
26356/// #     .unwrap()
26357/// #     .https_only()
26358/// #     .enable_http2()
26359/// #     .build();
26360///
26361/// # let executor = hyper_util::rt::TokioExecutor::new();
26362/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26363/// #     secret,
26364/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26365/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26366/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26367/// #     ),
26368/// # ).build().await.unwrap();
26369///
26370/// # let client = hyper_util::client::legacy::Client::builder(
26371/// #     hyper_util::rt::TokioExecutor::new()
26372/// # )
26373/// # .build(
26374/// #     hyper_rustls::HttpsConnectorBuilder::new()
26375/// #         .with_native_roots()
26376/// #         .unwrap()
26377/// #         .https_or_http()
26378/// #         .enable_http2()
26379/// #         .build()
26380/// # );
26381/// # let mut hub = Analytics::new(client, auth);
26382/// // As the method needs a request, you would usually fill it with the desired information
26383/// // into the respective structure. Some of the parts shown here might not be applicable !
26384/// // Values shown here are possibly random and not representative !
26385/// let mut req = RemarketingAudience::default();
26386///
26387/// // You can configure optional parameters by calling the respective setters at will, and
26388/// // execute the final call using `doit()`.
26389/// // Values shown here are possibly random and not representative !
26390/// let result = hub.management().remarketing_audience_patch(req, "accountId", "webPropertyId", "remarketingAudienceId")
26391///              .doit().await;
26392/// # }
26393/// ```
26394pub struct ManagementRemarketingAudiencePatchCall<'a, C>
26395where
26396    C: 'a,
26397{
26398    hub: &'a Analytics<C>,
26399    _request: RemarketingAudience,
26400    _account_id: String,
26401    _web_property_id: String,
26402    _remarketing_audience_id: String,
26403    _delegate: Option<&'a mut dyn common::Delegate>,
26404    _additional_params: HashMap<String, String>,
26405    _scopes: BTreeSet<String>,
26406}
26407
26408impl<'a, C> common::CallBuilder for ManagementRemarketingAudiencePatchCall<'a, C> {}
26409
26410impl<'a, C> ManagementRemarketingAudiencePatchCall<'a, C>
26411where
26412    C: common::Connector,
26413{
26414    /// Perform the operation you have build so far.
26415    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudience)> {
26416        use std::borrow::Cow;
26417        use std::io::{Read, Seek};
26418
26419        use common::{url::Params, ToParts};
26420        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26421
26422        let mut dd = common::DefaultDelegate;
26423        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26424        dlg.begin(common::MethodInfo {
26425            id: "analytics.management.remarketingAudience.patch",
26426            http_method: hyper::Method::PATCH,
26427        });
26428
26429        for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() {
26430            if self._additional_params.contains_key(field) {
26431                dlg.finished(false);
26432                return Err(common::Error::FieldClash(field));
26433            }
26434        }
26435
26436        let mut params = Params::with_capacity(6 + self._additional_params.len());
26437        params.push("accountId", self._account_id);
26438        params.push("webPropertyId", self._web_property_id);
26439        params.push("remarketingAudienceId", self._remarketing_audience_id);
26440
26441        params.extend(self._additional_params.iter());
26442
26443        params.push("alt", "json");
26444        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}";
26445        if self._scopes.is_empty() {
26446            self._scopes.insert(Scope::Edit.as_ref().to_string());
26447        }
26448
26449        #[allow(clippy::single_element_loop)]
26450        for &(find_this, param_name) in [
26451            ("{accountId}", "accountId"),
26452            ("{webPropertyId}", "webPropertyId"),
26453            ("{remarketingAudienceId}", "remarketingAudienceId"),
26454        ]
26455        .iter()
26456        {
26457            url = params.uri_replacement(url, param_name, find_this, false);
26458        }
26459        {
26460            let to_remove = ["remarketingAudienceId", "webPropertyId", "accountId"];
26461            params.remove_params(&to_remove);
26462        }
26463
26464        let url = params.parse_with_url(&url);
26465
26466        let mut json_mime_type = mime::APPLICATION_JSON;
26467        let mut request_value_reader = {
26468            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26469            common::remove_json_null_values(&mut value);
26470            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26471            serde_json::to_writer(&mut dst, &value).unwrap();
26472            dst
26473        };
26474        let request_size = request_value_reader
26475            .seek(std::io::SeekFrom::End(0))
26476            .unwrap();
26477        request_value_reader
26478            .seek(std::io::SeekFrom::Start(0))
26479            .unwrap();
26480
26481        loop {
26482            let token = match self
26483                .hub
26484                .auth
26485                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26486                .await
26487            {
26488                Ok(token) => token,
26489                Err(e) => match dlg.token(e) {
26490                    Ok(token) => token,
26491                    Err(e) => {
26492                        dlg.finished(false);
26493                        return Err(common::Error::MissingToken(e));
26494                    }
26495                },
26496            };
26497            request_value_reader
26498                .seek(std::io::SeekFrom::Start(0))
26499                .unwrap();
26500            let mut req_result = {
26501                let client = &self.hub.client;
26502                dlg.pre_request();
26503                let mut req_builder = hyper::Request::builder()
26504                    .method(hyper::Method::PATCH)
26505                    .uri(url.as_str())
26506                    .header(USER_AGENT, self.hub._user_agent.clone());
26507
26508                if let Some(token) = token.as_ref() {
26509                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26510                }
26511
26512                let request = req_builder
26513                    .header(CONTENT_TYPE, json_mime_type.to_string())
26514                    .header(CONTENT_LENGTH, request_size as u64)
26515                    .body(common::to_body(
26516                        request_value_reader.get_ref().clone().into(),
26517                    ));
26518
26519                client.request(request.unwrap()).await
26520            };
26521
26522            match req_result {
26523                Err(err) => {
26524                    if let common::Retry::After(d) = dlg.http_error(&err) {
26525                        sleep(d).await;
26526                        continue;
26527                    }
26528                    dlg.finished(false);
26529                    return Err(common::Error::HttpError(err));
26530                }
26531                Ok(res) => {
26532                    let (mut parts, body) = res.into_parts();
26533                    let mut body = common::Body::new(body);
26534                    if !parts.status.is_success() {
26535                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26536                        let error = serde_json::from_str(&common::to_string(&bytes));
26537                        let response = common::to_response(parts, bytes.into());
26538
26539                        if let common::Retry::After(d) =
26540                            dlg.http_failure(&response, error.as_ref().ok())
26541                        {
26542                            sleep(d).await;
26543                            continue;
26544                        }
26545
26546                        dlg.finished(false);
26547
26548                        return Err(match error {
26549                            Ok(value) => common::Error::BadRequest(value),
26550                            _ => common::Error::Failure(response),
26551                        });
26552                    }
26553                    let response = {
26554                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26555                        let encoded = common::to_string(&bytes);
26556                        match serde_json::from_str(&encoded) {
26557                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26558                            Err(error) => {
26559                                dlg.response_json_decode_error(&encoded, &error);
26560                                return Err(common::Error::JsonDecodeError(
26561                                    encoded.to_string(),
26562                                    error,
26563                                ));
26564                            }
26565                        }
26566                    };
26567
26568                    dlg.finished(true);
26569                    return Ok(response);
26570                }
26571            }
26572        }
26573    }
26574
26575    ///
26576    /// Sets the *request* property to the given value.
26577    ///
26578    /// Even though the property as already been set when instantiating this call,
26579    /// we provide this method for API completeness.
26580    pub fn request(
26581        mut self,
26582        new_value: RemarketingAudience,
26583    ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
26584        self._request = new_value;
26585        self
26586    }
26587    /// The account ID of the remarketing audience to update.
26588    ///
26589    /// Sets the *account id* path property to the given value.
26590    ///
26591    /// Even though the property as already been set when instantiating this call,
26592    /// we provide this method for API completeness.
26593    pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudiencePatchCall<'a, C> {
26594        self._account_id = new_value.to_string();
26595        self
26596    }
26597    /// The web property ID of the remarketing audience to update.
26598    ///
26599    /// Sets the *web property id* path property to the given value.
26600    ///
26601    /// Even though the property as already been set when instantiating this call,
26602    /// we provide this method for API completeness.
26603    pub fn web_property_id(
26604        mut self,
26605        new_value: &str,
26606    ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
26607        self._web_property_id = new_value.to_string();
26608        self
26609    }
26610    /// The ID of the remarketing audience to update.
26611    ///
26612    /// Sets the *remarketing audience id* path property to the given value.
26613    ///
26614    /// Even though the property as already been set when instantiating this call,
26615    /// we provide this method for API completeness.
26616    pub fn remarketing_audience_id(
26617        mut self,
26618        new_value: &str,
26619    ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
26620        self._remarketing_audience_id = new_value.to_string();
26621        self
26622    }
26623    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26624    /// while executing the actual API request.
26625    ///
26626    /// ````text
26627    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26628    /// ````
26629    ///
26630    /// Sets the *delegate* property to the given value.
26631    pub fn delegate(
26632        mut self,
26633        new_value: &'a mut dyn common::Delegate,
26634    ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
26635        self._delegate = Some(new_value);
26636        self
26637    }
26638
26639    /// Set any additional parameter of the query string used in the request.
26640    /// It should be used to set parameters which are not yet available through their own
26641    /// setters.
26642    ///
26643    /// Please note that this method must not be used to set any of the known parameters
26644    /// which have their own setter method. If done anyway, the request will fail.
26645    ///
26646    /// # Additional Parameters
26647    ///
26648    /// * *alt* (query-string) - Data format for the response.
26649    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26650    /// * *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.
26651    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26652    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26653    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26654    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26655    pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudiencePatchCall<'a, C>
26656    where
26657        T: AsRef<str>,
26658    {
26659        self._additional_params
26660            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26661        self
26662    }
26663
26664    /// Identifies the authorization scope for the method you are building.
26665    ///
26666    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26667    /// [`Scope::Edit`].
26668    ///
26669    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26670    /// tokens for more than one scope.
26671    ///
26672    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26673    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26674    /// sufficient, a read-write scope will do as well.
26675    pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudiencePatchCall<'a, C>
26676    where
26677        St: AsRef<str>,
26678    {
26679        self._scopes.insert(String::from(scope.as_ref()));
26680        self
26681    }
26682    /// Identifies the authorization scope(s) for the method you are building.
26683    ///
26684    /// See [`Self::add_scope()`] for details.
26685    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudiencePatchCall<'a, C>
26686    where
26687        I: IntoIterator<Item = St>,
26688        St: AsRef<str>,
26689    {
26690        self._scopes
26691            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26692        self
26693    }
26694
26695    /// Removes all scopes, and no default scope will be used either.
26696    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26697    /// for details).
26698    pub fn clear_scopes(mut self) -> ManagementRemarketingAudiencePatchCall<'a, C> {
26699        self._scopes.clear();
26700        self
26701    }
26702}
26703
26704/// Updates an existing remarketing audience.
26705///
26706/// A builder for the *remarketingAudience.update* method supported by a *management* resource.
26707/// It is not used directly, but through a [`ManagementMethods`] instance.
26708///
26709/// # Example
26710///
26711/// Instantiate a resource method builder
26712///
26713/// ```test_harness,no_run
26714/// # extern crate hyper;
26715/// # extern crate hyper_rustls;
26716/// # extern crate google_analytics3 as analytics3;
26717/// use analytics3::api::RemarketingAudience;
26718/// # async fn dox() {
26719/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26720///
26721/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26722/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26723/// #     .with_native_roots()
26724/// #     .unwrap()
26725/// #     .https_only()
26726/// #     .enable_http2()
26727/// #     .build();
26728///
26729/// # let executor = hyper_util::rt::TokioExecutor::new();
26730/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26731/// #     secret,
26732/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26733/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26734/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26735/// #     ),
26736/// # ).build().await.unwrap();
26737///
26738/// # let client = hyper_util::client::legacy::Client::builder(
26739/// #     hyper_util::rt::TokioExecutor::new()
26740/// # )
26741/// # .build(
26742/// #     hyper_rustls::HttpsConnectorBuilder::new()
26743/// #         .with_native_roots()
26744/// #         .unwrap()
26745/// #         .https_or_http()
26746/// #         .enable_http2()
26747/// #         .build()
26748/// # );
26749/// # let mut hub = Analytics::new(client, auth);
26750/// // As the method needs a request, you would usually fill it with the desired information
26751/// // into the respective structure. Some of the parts shown here might not be applicable !
26752/// // Values shown here are possibly random and not representative !
26753/// let mut req = RemarketingAudience::default();
26754///
26755/// // You can configure optional parameters by calling the respective setters at will, and
26756/// // execute the final call using `doit()`.
26757/// // Values shown here are possibly random and not representative !
26758/// let result = hub.management().remarketing_audience_update(req, "accountId", "webPropertyId", "remarketingAudienceId")
26759///              .doit().await;
26760/// # }
26761/// ```
26762pub struct ManagementRemarketingAudienceUpdateCall<'a, C>
26763where
26764    C: 'a,
26765{
26766    hub: &'a Analytics<C>,
26767    _request: RemarketingAudience,
26768    _account_id: String,
26769    _web_property_id: String,
26770    _remarketing_audience_id: String,
26771    _delegate: Option<&'a mut dyn common::Delegate>,
26772    _additional_params: HashMap<String, String>,
26773    _scopes: BTreeSet<String>,
26774}
26775
26776impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceUpdateCall<'a, C> {}
26777
26778impl<'a, C> ManagementRemarketingAudienceUpdateCall<'a, C>
26779where
26780    C: common::Connector,
26781{
26782    /// Perform the operation you have build so far.
26783    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudience)> {
26784        use std::borrow::Cow;
26785        use std::io::{Read, Seek};
26786
26787        use common::{url::Params, ToParts};
26788        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26789
26790        let mut dd = common::DefaultDelegate;
26791        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26792        dlg.begin(common::MethodInfo {
26793            id: "analytics.management.remarketingAudience.update",
26794            http_method: hyper::Method::PUT,
26795        });
26796
26797        for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() {
26798            if self._additional_params.contains_key(field) {
26799                dlg.finished(false);
26800                return Err(common::Error::FieldClash(field));
26801            }
26802        }
26803
26804        let mut params = Params::with_capacity(6 + self._additional_params.len());
26805        params.push("accountId", self._account_id);
26806        params.push("webPropertyId", self._web_property_id);
26807        params.push("remarketingAudienceId", self._remarketing_audience_id);
26808
26809        params.extend(self._additional_params.iter());
26810
26811        params.push("alt", "json");
26812        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}";
26813        if self._scopes.is_empty() {
26814            self._scopes.insert(Scope::Edit.as_ref().to_string());
26815        }
26816
26817        #[allow(clippy::single_element_loop)]
26818        for &(find_this, param_name) in [
26819            ("{accountId}", "accountId"),
26820            ("{webPropertyId}", "webPropertyId"),
26821            ("{remarketingAudienceId}", "remarketingAudienceId"),
26822        ]
26823        .iter()
26824        {
26825            url = params.uri_replacement(url, param_name, find_this, false);
26826        }
26827        {
26828            let to_remove = ["remarketingAudienceId", "webPropertyId", "accountId"];
26829            params.remove_params(&to_remove);
26830        }
26831
26832        let url = params.parse_with_url(&url);
26833
26834        let mut json_mime_type = mime::APPLICATION_JSON;
26835        let mut request_value_reader = {
26836            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26837            common::remove_json_null_values(&mut value);
26838            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26839            serde_json::to_writer(&mut dst, &value).unwrap();
26840            dst
26841        };
26842        let request_size = request_value_reader
26843            .seek(std::io::SeekFrom::End(0))
26844            .unwrap();
26845        request_value_reader
26846            .seek(std::io::SeekFrom::Start(0))
26847            .unwrap();
26848
26849        loop {
26850            let token = match self
26851                .hub
26852                .auth
26853                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26854                .await
26855            {
26856                Ok(token) => token,
26857                Err(e) => match dlg.token(e) {
26858                    Ok(token) => token,
26859                    Err(e) => {
26860                        dlg.finished(false);
26861                        return Err(common::Error::MissingToken(e));
26862                    }
26863                },
26864            };
26865            request_value_reader
26866                .seek(std::io::SeekFrom::Start(0))
26867                .unwrap();
26868            let mut req_result = {
26869                let client = &self.hub.client;
26870                dlg.pre_request();
26871                let mut req_builder = hyper::Request::builder()
26872                    .method(hyper::Method::PUT)
26873                    .uri(url.as_str())
26874                    .header(USER_AGENT, self.hub._user_agent.clone());
26875
26876                if let Some(token) = token.as_ref() {
26877                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26878                }
26879
26880                let request = req_builder
26881                    .header(CONTENT_TYPE, json_mime_type.to_string())
26882                    .header(CONTENT_LENGTH, request_size as u64)
26883                    .body(common::to_body(
26884                        request_value_reader.get_ref().clone().into(),
26885                    ));
26886
26887                client.request(request.unwrap()).await
26888            };
26889
26890            match req_result {
26891                Err(err) => {
26892                    if let common::Retry::After(d) = dlg.http_error(&err) {
26893                        sleep(d).await;
26894                        continue;
26895                    }
26896                    dlg.finished(false);
26897                    return Err(common::Error::HttpError(err));
26898                }
26899                Ok(res) => {
26900                    let (mut parts, body) = res.into_parts();
26901                    let mut body = common::Body::new(body);
26902                    if !parts.status.is_success() {
26903                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26904                        let error = serde_json::from_str(&common::to_string(&bytes));
26905                        let response = common::to_response(parts, bytes.into());
26906
26907                        if let common::Retry::After(d) =
26908                            dlg.http_failure(&response, error.as_ref().ok())
26909                        {
26910                            sleep(d).await;
26911                            continue;
26912                        }
26913
26914                        dlg.finished(false);
26915
26916                        return Err(match error {
26917                            Ok(value) => common::Error::BadRequest(value),
26918                            _ => common::Error::Failure(response),
26919                        });
26920                    }
26921                    let response = {
26922                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26923                        let encoded = common::to_string(&bytes);
26924                        match serde_json::from_str(&encoded) {
26925                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26926                            Err(error) => {
26927                                dlg.response_json_decode_error(&encoded, &error);
26928                                return Err(common::Error::JsonDecodeError(
26929                                    encoded.to_string(),
26930                                    error,
26931                                ));
26932                            }
26933                        }
26934                    };
26935
26936                    dlg.finished(true);
26937                    return Ok(response);
26938                }
26939            }
26940        }
26941    }
26942
26943    ///
26944    /// Sets the *request* property to the given value.
26945    ///
26946    /// Even though the property as already been set when instantiating this call,
26947    /// we provide this method for API completeness.
26948    pub fn request(
26949        mut self,
26950        new_value: RemarketingAudience,
26951    ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26952        self._request = new_value;
26953        self
26954    }
26955    /// The account ID of the remarketing audience to update.
26956    ///
26957    /// Sets the *account id* path property to the given value.
26958    ///
26959    /// Even though the property as already been set when instantiating this call,
26960    /// we provide this method for API completeness.
26961    pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26962        self._account_id = new_value.to_string();
26963        self
26964    }
26965    /// The web property ID of the remarketing audience to update.
26966    ///
26967    /// Sets the *web property id* path property to the given value.
26968    ///
26969    /// Even though the property as already been set when instantiating this call,
26970    /// we provide this method for API completeness.
26971    pub fn web_property_id(
26972        mut self,
26973        new_value: &str,
26974    ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26975        self._web_property_id = new_value.to_string();
26976        self
26977    }
26978    /// The ID of the remarketing audience to update.
26979    ///
26980    /// Sets the *remarketing audience id* path property to the given value.
26981    ///
26982    /// Even though the property as already been set when instantiating this call,
26983    /// we provide this method for API completeness.
26984    pub fn remarketing_audience_id(
26985        mut self,
26986        new_value: &str,
26987    ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26988        self._remarketing_audience_id = new_value.to_string();
26989        self
26990    }
26991    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26992    /// while executing the actual API request.
26993    ///
26994    /// ````text
26995    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26996    /// ````
26997    ///
26998    /// Sets the *delegate* property to the given value.
26999    pub fn delegate(
27000        mut self,
27001        new_value: &'a mut dyn common::Delegate,
27002    ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
27003        self._delegate = Some(new_value);
27004        self
27005    }
27006
27007    /// Set any additional parameter of the query string used in the request.
27008    /// It should be used to set parameters which are not yet available through their own
27009    /// setters.
27010    ///
27011    /// Please note that this method must not be used to set any of the known parameters
27012    /// which have their own setter method. If done anyway, the request will fail.
27013    ///
27014    /// # Additional Parameters
27015    ///
27016    /// * *alt* (query-string) - Data format for the response.
27017    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27018    /// * *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.
27019    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27020    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27021    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27022    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27023    pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceUpdateCall<'a, C>
27024    where
27025        T: AsRef<str>,
27026    {
27027        self._additional_params
27028            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27029        self
27030    }
27031
27032    /// Identifies the authorization scope for the method you are building.
27033    ///
27034    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27035    /// [`Scope::Edit`].
27036    ///
27037    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27038    /// tokens for more than one scope.
27039    ///
27040    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27041    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27042    /// sufficient, a read-write scope will do as well.
27043    pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceUpdateCall<'a, C>
27044    where
27045        St: AsRef<str>,
27046    {
27047        self._scopes.insert(String::from(scope.as_ref()));
27048        self
27049    }
27050    /// Identifies the authorization scope(s) for the method you are building.
27051    ///
27052    /// See [`Self::add_scope()`] for details.
27053    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceUpdateCall<'a, C>
27054    where
27055        I: IntoIterator<Item = St>,
27056        St: AsRef<str>,
27057    {
27058        self._scopes
27059            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27060        self
27061    }
27062
27063    /// Removes all scopes, and no default scope will be used either.
27064    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27065    /// for details).
27066    pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
27067        self._scopes.clear();
27068        self
27069    }
27070}
27071
27072/// Lists segments to which the user has access.
27073///
27074/// A builder for the *segments.list* method supported by a *management* resource.
27075/// It is not used directly, but through a [`ManagementMethods`] instance.
27076///
27077/// # Example
27078///
27079/// Instantiate a resource method builder
27080///
27081/// ```test_harness,no_run
27082/// # extern crate hyper;
27083/// # extern crate hyper_rustls;
27084/// # extern crate google_analytics3 as analytics3;
27085/// # async fn dox() {
27086/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27087///
27088/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27089/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27090/// #     .with_native_roots()
27091/// #     .unwrap()
27092/// #     .https_only()
27093/// #     .enable_http2()
27094/// #     .build();
27095///
27096/// # let executor = hyper_util::rt::TokioExecutor::new();
27097/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27098/// #     secret,
27099/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27100/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27101/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27102/// #     ),
27103/// # ).build().await.unwrap();
27104///
27105/// # let client = hyper_util::client::legacy::Client::builder(
27106/// #     hyper_util::rt::TokioExecutor::new()
27107/// # )
27108/// # .build(
27109/// #     hyper_rustls::HttpsConnectorBuilder::new()
27110/// #         .with_native_roots()
27111/// #         .unwrap()
27112/// #         .https_or_http()
27113/// #         .enable_http2()
27114/// #         .build()
27115/// # );
27116/// # let mut hub = Analytics::new(client, auth);
27117/// // You can configure optional parameters by calling the respective setters at will, and
27118/// // execute the final call using `doit()`.
27119/// // Values shown here are possibly random and not representative !
27120/// let result = hub.management().segments_list()
27121///              .start_index(-45)
27122///              .max_results(-87)
27123///              .doit().await;
27124/// # }
27125/// ```
27126pub struct ManagementSegmentListCall<'a, C>
27127where
27128    C: 'a,
27129{
27130    hub: &'a Analytics<C>,
27131    _start_index: Option<i32>,
27132    _max_results: Option<i32>,
27133    _delegate: Option<&'a mut dyn common::Delegate>,
27134    _additional_params: HashMap<String, String>,
27135    _scopes: BTreeSet<String>,
27136}
27137
27138impl<'a, C> common::CallBuilder for ManagementSegmentListCall<'a, C> {}
27139
27140impl<'a, C> ManagementSegmentListCall<'a, C>
27141where
27142    C: common::Connector,
27143{
27144    /// Perform the operation you have build so far.
27145    pub async fn doit(mut self) -> common::Result<(common::Response, Segments)> {
27146        use std::borrow::Cow;
27147        use std::io::{Read, Seek};
27148
27149        use common::{url::Params, ToParts};
27150        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27151
27152        let mut dd = common::DefaultDelegate;
27153        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27154        dlg.begin(common::MethodInfo {
27155            id: "analytics.management.segments.list",
27156            http_method: hyper::Method::GET,
27157        });
27158
27159        for &field in ["alt", "start-index", "max-results"].iter() {
27160            if self._additional_params.contains_key(field) {
27161                dlg.finished(false);
27162                return Err(common::Error::FieldClash(field));
27163            }
27164        }
27165
27166        let mut params = Params::with_capacity(4 + self._additional_params.len());
27167        if let Some(value) = self._start_index.as_ref() {
27168            params.push("start-index", value.to_string());
27169        }
27170        if let Some(value) = self._max_results.as_ref() {
27171            params.push("max-results", value.to_string());
27172        }
27173
27174        params.extend(self._additional_params.iter());
27175
27176        params.push("alt", "json");
27177        let mut url = self.hub._base_url.clone() + "management/segments";
27178        if self._scopes.is_empty() {
27179            self._scopes.insert(Scope::Readonly.as_ref().to_string());
27180        }
27181
27182        let url = params.parse_with_url(&url);
27183
27184        loop {
27185            let token = match self
27186                .hub
27187                .auth
27188                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27189                .await
27190            {
27191                Ok(token) => token,
27192                Err(e) => match dlg.token(e) {
27193                    Ok(token) => token,
27194                    Err(e) => {
27195                        dlg.finished(false);
27196                        return Err(common::Error::MissingToken(e));
27197                    }
27198                },
27199            };
27200            let mut req_result = {
27201                let client = &self.hub.client;
27202                dlg.pre_request();
27203                let mut req_builder = hyper::Request::builder()
27204                    .method(hyper::Method::GET)
27205                    .uri(url.as_str())
27206                    .header(USER_AGENT, self.hub._user_agent.clone());
27207
27208                if let Some(token) = token.as_ref() {
27209                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27210                }
27211
27212                let request = req_builder
27213                    .header(CONTENT_LENGTH, 0_u64)
27214                    .body(common::to_body::<String>(None));
27215
27216                client.request(request.unwrap()).await
27217            };
27218
27219            match req_result {
27220                Err(err) => {
27221                    if let common::Retry::After(d) = dlg.http_error(&err) {
27222                        sleep(d).await;
27223                        continue;
27224                    }
27225                    dlg.finished(false);
27226                    return Err(common::Error::HttpError(err));
27227                }
27228                Ok(res) => {
27229                    let (mut parts, body) = res.into_parts();
27230                    let mut body = common::Body::new(body);
27231                    if !parts.status.is_success() {
27232                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27233                        let error = serde_json::from_str(&common::to_string(&bytes));
27234                        let response = common::to_response(parts, bytes.into());
27235
27236                        if let common::Retry::After(d) =
27237                            dlg.http_failure(&response, error.as_ref().ok())
27238                        {
27239                            sleep(d).await;
27240                            continue;
27241                        }
27242
27243                        dlg.finished(false);
27244
27245                        return Err(match error {
27246                            Ok(value) => common::Error::BadRequest(value),
27247                            _ => common::Error::Failure(response),
27248                        });
27249                    }
27250                    let response = {
27251                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27252                        let encoded = common::to_string(&bytes);
27253                        match serde_json::from_str(&encoded) {
27254                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27255                            Err(error) => {
27256                                dlg.response_json_decode_error(&encoded, &error);
27257                                return Err(common::Error::JsonDecodeError(
27258                                    encoded.to_string(),
27259                                    error,
27260                                ));
27261                            }
27262                        }
27263                    };
27264
27265                    dlg.finished(true);
27266                    return Ok(response);
27267                }
27268            }
27269        }
27270    }
27271
27272    /// An index of the first segment to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
27273    ///
27274    /// Sets the *start-index* query property to the given value.
27275    pub fn start_index(mut self, new_value: i32) -> ManagementSegmentListCall<'a, C> {
27276        self._start_index = Some(new_value);
27277        self
27278    }
27279    /// The maximum number of segments to include in this response.
27280    ///
27281    /// Sets the *max-results* query property to the given value.
27282    pub fn max_results(mut self, new_value: i32) -> ManagementSegmentListCall<'a, C> {
27283        self._max_results = Some(new_value);
27284        self
27285    }
27286    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27287    /// while executing the actual API request.
27288    ///
27289    /// ````text
27290    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27291    /// ````
27292    ///
27293    /// Sets the *delegate* property to the given value.
27294    pub fn delegate(
27295        mut self,
27296        new_value: &'a mut dyn common::Delegate,
27297    ) -> ManagementSegmentListCall<'a, C> {
27298        self._delegate = Some(new_value);
27299        self
27300    }
27301
27302    /// Set any additional parameter of the query string used in the request.
27303    /// It should be used to set parameters which are not yet available through their own
27304    /// setters.
27305    ///
27306    /// Please note that this method must not be used to set any of the known parameters
27307    /// which have their own setter method. If done anyway, the request will fail.
27308    ///
27309    /// # Additional Parameters
27310    ///
27311    /// * *alt* (query-string) - Data format for the response.
27312    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27313    /// * *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.
27314    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27315    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27316    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27317    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27318    pub fn param<T>(mut self, name: T, value: T) -> ManagementSegmentListCall<'a, C>
27319    where
27320        T: AsRef<str>,
27321    {
27322        self._additional_params
27323            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27324        self
27325    }
27326
27327    /// Identifies the authorization scope for the method you are building.
27328    ///
27329    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27330    /// [`Scope::Readonly`].
27331    ///
27332    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27333    /// tokens for more than one scope.
27334    ///
27335    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27336    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27337    /// sufficient, a read-write scope will do as well.
27338    pub fn add_scope<St>(mut self, scope: St) -> ManagementSegmentListCall<'a, C>
27339    where
27340        St: AsRef<str>,
27341    {
27342        self._scopes.insert(String::from(scope.as_ref()));
27343        self
27344    }
27345    /// Identifies the authorization scope(s) for the method you are building.
27346    ///
27347    /// See [`Self::add_scope()`] for details.
27348    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementSegmentListCall<'a, C>
27349    where
27350        I: IntoIterator<Item = St>,
27351        St: AsRef<str>,
27352    {
27353        self._scopes
27354            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27355        self
27356    }
27357
27358    /// Removes all scopes, and no default scope will be used either.
27359    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27360    /// for details).
27361    pub fn clear_scopes(mut self) -> ManagementSegmentListCall<'a, C> {
27362        self._scopes.clear();
27363        self
27364    }
27365}
27366
27367/// Deletes an unsampled report.
27368///
27369/// A builder for the *unsampledReports.delete* method supported by a *management* resource.
27370/// It is not used directly, but through a [`ManagementMethods`] instance.
27371///
27372/// # Example
27373///
27374/// Instantiate a resource method builder
27375///
27376/// ```test_harness,no_run
27377/// # extern crate hyper;
27378/// # extern crate hyper_rustls;
27379/// # extern crate google_analytics3 as analytics3;
27380/// # async fn dox() {
27381/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27382///
27383/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27384/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27385/// #     .with_native_roots()
27386/// #     .unwrap()
27387/// #     .https_only()
27388/// #     .enable_http2()
27389/// #     .build();
27390///
27391/// # let executor = hyper_util::rt::TokioExecutor::new();
27392/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27393/// #     secret,
27394/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27395/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27396/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27397/// #     ),
27398/// # ).build().await.unwrap();
27399///
27400/// # let client = hyper_util::client::legacy::Client::builder(
27401/// #     hyper_util::rt::TokioExecutor::new()
27402/// # )
27403/// # .build(
27404/// #     hyper_rustls::HttpsConnectorBuilder::new()
27405/// #         .with_native_roots()
27406/// #         .unwrap()
27407/// #         .https_or_http()
27408/// #         .enable_http2()
27409/// #         .build()
27410/// # );
27411/// # let mut hub = Analytics::new(client, auth);
27412/// // You can configure optional parameters by calling the respective setters at will, and
27413/// // execute the final call using `doit()`.
27414/// // Values shown here are possibly random and not representative !
27415/// let result = hub.management().unsampled_reports_delete("accountId", "webPropertyId", "profileId", "unsampledReportId")
27416///              .doit().await;
27417/// # }
27418/// ```
27419pub struct ManagementUnsampledReportDeleteCall<'a, C>
27420where
27421    C: 'a,
27422{
27423    hub: &'a Analytics<C>,
27424    _account_id: String,
27425    _web_property_id: String,
27426    _profile_id: String,
27427    _unsampled_report_id: String,
27428    _delegate: Option<&'a mut dyn common::Delegate>,
27429    _additional_params: HashMap<String, String>,
27430    _scopes: BTreeSet<String>,
27431}
27432
27433impl<'a, C> common::CallBuilder for ManagementUnsampledReportDeleteCall<'a, C> {}
27434
27435impl<'a, C> ManagementUnsampledReportDeleteCall<'a, C>
27436where
27437    C: common::Connector,
27438{
27439    /// Perform the operation you have build so far.
27440    pub async fn doit(mut self) -> common::Result<common::Response> {
27441        use std::borrow::Cow;
27442        use std::io::{Read, Seek};
27443
27444        use common::{url::Params, ToParts};
27445        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27446
27447        let mut dd = common::DefaultDelegate;
27448        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27449        dlg.begin(common::MethodInfo {
27450            id: "analytics.management.unsampledReports.delete",
27451            http_method: hyper::Method::DELETE,
27452        });
27453
27454        for &field in [
27455            "accountId",
27456            "webPropertyId",
27457            "profileId",
27458            "unsampledReportId",
27459        ]
27460        .iter()
27461        {
27462            if self._additional_params.contains_key(field) {
27463                dlg.finished(false);
27464                return Err(common::Error::FieldClash(field));
27465            }
27466        }
27467
27468        let mut params = Params::with_capacity(5 + self._additional_params.len());
27469        params.push("accountId", self._account_id);
27470        params.push("webPropertyId", self._web_property_id);
27471        params.push("profileId", self._profile_id);
27472        params.push("unsampledReportId", self._unsampled_report_id);
27473
27474        params.extend(self._additional_params.iter());
27475
27476        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports/{unsampledReportId}";
27477        if self._scopes.is_empty() {
27478            self._scopes.insert(Scope::Edit.as_ref().to_string());
27479        }
27480
27481        #[allow(clippy::single_element_loop)]
27482        for &(find_this, param_name) in [
27483            ("{accountId}", "accountId"),
27484            ("{webPropertyId}", "webPropertyId"),
27485            ("{profileId}", "profileId"),
27486            ("{unsampledReportId}", "unsampledReportId"),
27487        ]
27488        .iter()
27489        {
27490            url = params.uri_replacement(url, param_name, find_this, false);
27491        }
27492        {
27493            let to_remove = [
27494                "unsampledReportId",
27495                "profileId",
27496                "webPropertyId",
27497                "accountId",
27498            ];
27499            params.remove_params(&to_remove);
27500        }
27501
27502        let url = params.parse_with_url(&url);
27503
27504        loop {
27505            let token = match self
27506                .hub
27507                .auth
27508                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27509                .await
27510            {
27511                Ok(token) => token,
27512                Err(e) => match dlg.token(e) {
27513                    Ok(token) => token,
27514                    Err(e) => {
27515                        dlg.finished(false);
27516                        return Err(common::Error::MissingToken(e));
27517                    }
27518                },
27519            };
27520            let mut req_result = {
27521                let client = &self.hub.client;
27522                dlg.pre_request();
27523                let mut req_builder = hyper::Request::builder()
27524                    .method(hyper::Method::DELETE)
27525                    .uri(url.as_str())
27526                    .header(USER_AGENT, self.hub._user_agent.clone());
27527
27528                if let Some(token) = token.as_ref() {
27529                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27530                }
27531
27532                let request = req_builder
27533                    .header(CONTENT_LENGTH, 0_u64)
27534                    .body(common::to_body::<String>(None));
27535
27536                client.request(request.unwrap()).await
27537            };
27538
27539            match req_result {
27540                Err(err) => {
27541                    if let common::Retry::After(d) = dlg.http_error(&err) {
27542                        sleep(d).await;
27543                        continue;
27544                    }
27545                    dlg.finished(false);
27546                    return Err(common::Error::HttpError(err));
27547                }
27548                Ok(res) => {
27549                    let (mut parts, body) = res.into_parts();
27550                    let mut body = common::Body::new(body);
27551                    if !parts.status.is_success() {
27552                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27553                        let error = serde_json::from_str(&common::to_string(&bytes));
27554                        let response = common::to_response(parts, bytes.into());
27555
27556                        if let common::Retry::After(d) =
27557                            dlg.http_failure(&response, error.as_ref().ok())
27558                        {
27559                            sleep(d).await;
27560                            continue;
27561                        }
27562
27563                        dlg.finished(false);
27564
27565                        return Err(match error {
27566                            Ok(value) => common::Error::BadRequest(value),
27567                            _ => common::Error::Failure(response),
27568                        });
27569                    }
27570                    let response = common::Response::from_parts(parts, body);
27571
27572                    dlg.finished(true);
27573                    return Ok(response);
27574                }
27575            }
27576        }
27577    }
27578
27579    /// Account ID to delete the unsampled report for.
27580    ///
27581    /// Sets the *account id* path property to the given value.
27582    ///
27583    /// Even though the property as already been set when instantiating this call,
27584    /// we provide this method for API completeness.
27585    pub fn account_id(mut self, new_value: &str) -> ManagementUnsampledReportDeleteCall<'a, C> {
27586        self._account_id = new_value.to_string();
27587        self
27588    }
27589    /// Web property ID to delete the unsampled reports for.
27590    ///
27591    /// Sets the *web property id* path property to the given value.
27592    ///
27593    /// Even though the property as already been set when instantiating this call,
27594    /// we provide this method for API completeness.
27595    pub fn web_property_id(
27596        mut self,
27597        new_value: &str,
27598    ) -> ManagementUnsampledReportDeleteCall<'a, C> {
27599        self._web_property_id = new_value.to_string();
27600        self
27601    }
27602    /// View (Profile) ID to delete the unsampled report for.
27603    ///
27604    /// Sets the *profile id* path property to the given value.
27605    ///
27606    /// Even though the property as already been set when instantiating this call,
27607    /// we provide this method for API completeness.
27608    pub fn profile_id(mut self, new_value: &str) -> ManagementUnsampledReportDeleteCall<'a, C> {
27609        self._profile_id = new_value.to_string();
27610        self
27611    }
27612    /// ID of the unsampled report to be deleted.
27613    ///
27614    /// Sets the *unsampled report id* path property to the given value.
27615    ///
27616    /// Even though the property as already been set when instantiating this call,
27617    /// we provide this method for API completeness.
27618    pub fn unsampled_report_id(
27619        mut self,
27620        new_value: &str,
27621    ) -> ManagementUnsampledReportDeleteCall<'a, C> {
27622        self._unsampled_report_id = new_value.to_string();
27623        self
27624    }
27625    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27626    /// while executing the actual API request.
27627    ///
27628    /// ````text
27629    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27630    /// ````
27631    ///
27632    /// Sets the *delegate* property to the given value.
27633    pub fn delegate(
27634        mut self,
27635        new_value: &'a mut dyn common::Delegate,
27636    ) -> ManagementUnsampledReportDeleteCall<'a, C> {
27637        self._delegate = Some(new_value);
27638        self
27639    }
27640
27641    /// Set any additional parameter of the query string used in the request.
27642    /// It should be used to set parameters which are not yet available through their own
27643    /// setters.
27644    ///
27645    /// Please note that this method must not be used to set any of the known parameters
27646    /// which have their own setter method. If done anyway, the request will fail.
27647    ///
27648    /// # Additional Parameters
27649    ///
27650    /// * *alt* (query-string) - Data format for the response.
27651    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27652    /// * *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.
27653    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27654    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27655    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27656    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27657    pub fn param<T>(mut self, name: T, value: T) -> ManagementUnsampledReportDeleteCall<'a, C>
27658    where
27659        T: AsRef<str>,
27660    {
27661        self._additional_params
27662            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27663        self
27664    }
27665
27666    /// Identifies the authorization scope for the method you are building.
27667    ///
27668    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27669    /// [`Scope::Edit`].
27670    ///
27671    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27672    /// tokens for more than one scope.
27673    ///
27674    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27675    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27676    /// sufficient, a read-write scope will do as well.
27677    pub fn add_scope<St>(mut self, scope: St) -> ManagementUnsampledReportDeleteCall<'a, C>
27678    where
27679        St: AsRef<str>,
27680    {
27681        self._scopes.insert(String::from(scope.as_ref()));
27682        self
27683    }
27684    /// Identifies the authorization scope(s) for the method you are building.
27685    ///
27686    /// See [`Self::add_scope()`] for details.
27687    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUnsampledReportDeleteCall<'a, C>
27688    where
27689        I: IntoIterator<Item = St>,
27690        St: AsRef<str>,
27691    {
27692        self._scopes
27693            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27694        self
27695    }
27696
27697    /// Removes all scopes, and no default scope will be used either.
27698    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27699    /// for details).
27700    pub fn clear_scopes(mut self) -> ManagementUnsampledReportDeleteCall<'a, C> {
27701        self._scopes.clear();
27702        self
27703    }
27704}
27705
27706/// Returns a single unsampled report.
27707///
27708/// A builder for the *unsampledReports.get* method supported by a *management* resource.
27709/// It is not used directly, but through a [`ManagementMethods`] instance.
27710///
27711/// # Example
27712///
27713/// Instantiate a resource method builder
27714///
27715/// ```test_harness,no_run
27716/// # extern crate hyper;
27717/// # extern crate hyper_rustls;
27718/// # extern crate google_analytics3 as analytics3;
27719/// # async fn dox() {
27720/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27721///
27722/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27723/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27724/// #     .with_native_roots()
27725/// #     .unwrap()
27726/// #     .https_only()
27727/// #     .enable_http2()
27728/// #     .build();
27729///
27730/// # let executor = hyper_util::rt::TokioExecutor::new();
27731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27732/// #     secret,
27733/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27734/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27735/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27736/// #     ),
27737/// # ).build().await.unwrap();
27738///
27739/// # let client = hyper_util::client::legacy::Client::builder(
27740/// #     hyper_util::rt::TokioExecutor::new()
27741/// # )
27742/// # .build(
27743/// #     hyper_rustls::HttpsConnectorBuilder::new()
27744/// #         .with_native_roots()
27745/// #         .unwrap()
27746/// #         .https_or_http()
27747/// #         .enable_http2()
27748/// #         .build()
27749/// # );
27750/// # let mut hub = Analytics::new(client, auth);
27751/// // You can configure optional parameters by calling the respective setters at will, and
27752/// // execute the final call using `doit()`.
27753/// // Values shown here are possibly random and not representative !
27754/// let result = hub.management().unsampled_reports_get("accountId", "webPropertyId", "profileId", "unsampledReportId")
27755///              .doit().await;
27756/// # }
27757/// ```
27758pub struct ManagementUnsampledReportGetCall<'a, C>
27759where
27760    C: 'a,
27761{
27762    hub: &'a Analytics<C>,
27763    _account_id: String,
27764    _web_property_id: String,
27765    _profile_id: String,
27766    _unsampled_report_id: String,
27767    _delegate: Option<&'a mut dyn common::Delegate>,
27768    _additional_params: HashMap<String, String>,
27769    _scopes: BTreeSet<String>,
27770}
27771
27772impl<'a, C> common::CallBuilder for ManagementUnsampledReportGetCall<'a, C> {}
27773
27774impl<'a, C> ManagementUnsampledReportGetCall<'a, C>
27775where
27776    C: common::Connector,
27777{
27778    /// Perform the operation you have build so far.
27779    pub async fn doit(mut self) -> common::Result<(common::Response, UnsampledReport)> {
27780        use std::borrow::Cow;
27781        use std::io::{Read, Seek};
27782
27783        use common::{url::Params, ToParts};
27784        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27785
27786        let mut dd = common::DefaultDelegate;
27787        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27788        dlg.begin(common::MethodInfo {
27789            id: "analytics.management.unsampledReports.get",
27790            http_method: hyper::Method::GET,
27791        });
27792
27793        for &field in [
27794            "alt",
27795            "accountId",
27796            "webPropertyId",
27797            "profileId",
27798            "unsampledReportId",
27799        ]
27800        .iter()
27801        {
27802            if self._additional_params.contains_key(field) {
27803                dlg.finished(false);
27804                return Err(common::Error::FieldClash(field));
27805            }
27806        }
27807
27808        let mut params = Params::with_capacity(6 + self._additional_params.len());
27809        params.push("accountId", self._account_id);
27810        params.push("webPropertyId", self._web_property_id);
27811        params.push("profileId", self._profile_id);
27812        params.push("unsampledReportId", self._unsampled_report_id);
27813
27814        params.extend(self._additional_params.iter());
27815
27816        params.push("alt", "json");
27817        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports/{unsampledReportId}";
27818        if self._scopes.is_empty() {
27819            self._scopes.insert(Scope::Readonly.as_ref().to_string());
27820        }
27821
27822        #[allow(clippy::single_element_loop)]
27823        for &(find_this, param_name) in [
27824            ("{accountId}", "accountId"),
27825            ("{webPropertyId}", "webPropertyId"),
27826            ("{profileId}", "profileId"),
27827            ("{unsampledReportId}", "unsampledReportId"),
27828        ]
27829        .iter()
27830        {
27831            url = params.uri_replacement(url, param_name, find_this, false);
27832        }
27833        {
27834            let to_remove = [
27835                "unsampledReportId",
27836                "profileId",
27837                "webPropertyId",
27838                "accountId",
27839            ];
27840            params.remove_params(&to_remove);
27841        }
27842
27843        let url = params.parse_with_url(&url);
27844
27845        loop {
27846            let token = match self
27847                .hub
27848                .auth
27849                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27850                .await
27851            {
27852                Ok(token) => token,
27853                Err(e) => match dlg.token(e) {
27854                    Ok(token) => token,
27855                    Err(e) => {
27856                        dlg.finished(false);
27857                        return Err(common::Error::MissingToken(e));
27858                    }
27859                },
27860            };
27861            let mut req_result = {
27862                let client = &self.hub.client;
27863                dlg.pre_request();
27864                let mut req_builder = hyper::Request::builder()
27865                    .method(hyper::Method::GET)
27866                    .uri(url.as_str())
27867                    .header(USER_AGENT, self.hub._user_agent.clone());
27868
27869                if let Some(token) = token.as_ref() {
27870                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27871                }
27872
27873                let request = req_builder
27874                    .header(CONTENT_LENGTH, 0_u64)
27875                    .body(common::to_body::<String>(None));
27876
27877                client.request(request.unwrap()).await
27878            };
27879
27880            match req_result {
27881                Err(err) => {
27882                    if let common::Retry::After(d) = dlg.http_error(&err) {
27883                        sleep(d).await;
27884                        continue;
27885                    }
27886                    dlg.finished(false);
27887                    return Err(common::Error::HttpError(err));
27888                }
27889                Ok(res) => {
27890                    let (mut parts, body) = res.into_parts();
27891                    let mut body = common::Body::new(body);
27892                    if !parts.status.is_success() {
27893                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27894                        let error = serde_json::from_str(&common::to_string(&bytes));
27895                        let response = common::to_response(parts, bytes.into());
27896
27897                        if let common::Retry::After(d) =
27898                            dlg.http_failure(&response, error.as_ref().ok())
27899                        {
27900                            sleep(d).await;
27901                            continue;
27902                        }
27903
27904                        dlg.finished(false);
27905
27906                        return Err(match error {
27907                            Ok(value) => common::Error::BadRequest(value),
27908                            _ => common::Error::Failure(response),
27909                        });
27910                    }
27911                    let response = {
27912                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27913                        let encoded = common::to_string(&bytes);
27914                        match serde_json::from_str(&encoded) {
27915                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27916                            Err(error) => {
27917                                dlg.response_json_decode_error(&encoded, &error);
27918                                return Err(common::Error::JsonDecodeError(
27919                                    encoded.to_string(),
27920                                    error,
27921                                ));
27922                            }
27923                        }
27924                    };
27925
27926                    dlg.finished(true);
27927                    return Ok(response);
27928                }
27929            }
27930        }
27931    }
27932
27933    /// Account ID to retrieve unsampled report for.
27934    ///
27935    /// Sets the *account id* path property to the given value.
27936    ///
27937    /// Even though the property as already been set when instantiating this call,
27938    /// we provide this method for API completeness.
27939    pub fn account_id(mut self, new_value: &str) -> ManagementUnsampledReportGetCall<'a, C> {
27940        self._account_id = new_value.to_string();
27941        self
27942    }
27943    /// Web property ID to retrieve unsampled reports for.
27944    ///
27945    /// Sets the *web property id* path property to the given value.
27946    ///
27947    /// Even though the property as already been set when instantiating this call,
27948    /// we provide this method for API completeness.
27949    pub fn web_property_id(mut self, new_value: &str) -> ManagementUnsampledReportGetCall<'a, C> {
27950        self._web_property_id = new_value.to_string();
27951        self
27952    }
27953    /// View (Profile) ID to retrieve unsampled report for.
27954    ///
27955    /// Sets the *profile id* path property to the given value.
27956    ///
27957    /// Even though the property as already been set when instantiating this call,
27958    /// we provide this method for API completeness.
27959    pub fn profile_id(mut self, new_value: &str) -> ManagementUnsampledReportGetCall<'a, C> {
27960        self._profile_id = new_value.to_string();
27961        self
27962    }
27963    /// ID of the unsampled report to retrieve.
27964    ///
27965    /// Sets the *unsampled report id* path property to the given value.
27966    ///
27967    /// Even though the property as already been set when instantiating this call,
27968    /// we provide this method for API completeness.
27969    pub fn unsampled_report_id(
27970        mut self,
27971        new_value: &str,
27972    ) -> ManagementUnsampledReportGetCall<'a, C> {
27973        self._unsampled_report_id = new_value.to_string();
27974        self
27975    }
27976    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27977    /// while executing the actual API request.
27978    ///
27979    /// ````text
27980    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27981    /// ````
27982    ///
27983    /// Sets the *delegate* property to the given value.
27984    pub fn delegate(
27985        mut self,
27986        new_value: &'a mut dyn common::Delegate,
27987    ) -> ManagementUnsampledReportGetCall<'a, C> {
27988        self._delegate = Some(new_value);
27989        self
27990    }
27991
27992    /// Set any additional parameter of the query string used in the request.
27993    /// It should be used to set parameters which are not yet available through their own
27994    /// setters.
27995    ///
27996    /// Please note that this method must not be used to set any of the known parameters
27997    /// which have their own setter method. If done anyway, the request will fail.
27998    ///
27999    /// # Additional Parameters
28000    ///
28001    /// * *alt* (query-string) - Data format for the response.
28002    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28003    /// * *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.
28004    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28005    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28006    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28007    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28008    pub fn param<T>(mut self, name: T, value: T) -> ManagementUnsampledReportGetCall<'a, C>
28009    where
28010        T: AsRef<str>,
28011    {
28012        self._additional_params
28013            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28014        self
28015    }
28016
28017    /// Identifies the authorization scope for the method you are building.
28018    ///
28019    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28020    /// [`Scope::Readonly`].
28021    ///
28022    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28023    /// tokens for more than one scope.
28024    ///
28025    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28026    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28027    /// sufficient, a read-write scope will do as well.
28028    pub fn add_scope<St>(mut self, scope: St) -> ManagementUnsampledReportGetCall<'a, C>
28029    where
28030        St: AsRef<str>,
28031    {
28032        self._scopes.insert(String::from(scope.as_ref()));
28033        self
28034    }
28035    /// Identifies the authorization scope(s) for the method you are building.
28036    ///
28037    /// See [`Self::add_scope()`] for details.
28038    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUnsampledReportGetCall<'a, C>
28039    where
28040        I: IntoIterator<Item = St>,
28041        St: AsRef<str>,
28042    {
28043        self._scopes
28044            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28045        self
28046    }
28047
28048    /// Removes all scopes, and no default scope will be used either.
28049    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28050    /// for details).
28051    pub fn clear_scopes(mut self) -> ManagementUnsampledReportGetCall<'a, C> {
28052        self._scopes.clear();
28053        self
28054    }
28055}
28056
28057/// Create a new unsampled report.
28058///
28059/// A builder for the *unsampledReports.insert* method supported by a *management* resource.
28060/// It is not used directly, but through a [`ManagementMethods`] instance.
28061///
28062/// # Example
28063///
28064/// Instantiate a resource method builder
28065///
28066/// ```test_harness,no_run
28067/// # extern crate hyper;
28068/// # extern crate hyper_rustls;
28069/// # extern crate google_analytics3 as analytics3;
28070/// use analytics3::api::UnsampledReport;
28071/// # async fn dox() {
28072/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28073///
28074/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28075/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28076/// #     .with_native_roots()
28077/// #     .unwrap()
28078/// #     .https_only()
28079/// #     .enable_http2()
28080/// #     .build();
28081///
28082/// # let executor = hyper_util::rt::TokioExecutor::new();
28083/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28084/// #     secret,
28085/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28086/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28087/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28088/// #     ),
28089/// # ).build().await.unwrap();
28090///
28091/// # let client = hyper_util::client::legacy::Client::builder(
28092/// #     hyper_util::rt::TokioExecutor::new()
28093/// # )
28094/// # .build(
28095/// #     hyper_rustls::HttpsConnectorBuilder::new()
28096/// #         .with_native_roots()
28097/// #         .unwrap()
28098/// #         .https_or_http()
28099/// #         .enable_http2()
28100/// #         .build()
28101/// # );
28102/// # let mut hub = Analytics::new(client, auth);
28103/// // As the method needs a request, you would usually fill it with the desired information
28104/// // into the respective structure. Some of the parts shown here might not be applicable !
28105/// // Values shown here are possibly random and not representative !
28106/// let mut req = UnsampledReport::default();
28107///
28108/// // You can configure optional parameters by calling the respective setters at will, and
28109/// // execute the final call using `doit()`.
28110/// // Values shown here are possibly random and not representative !
28111/// let result = hub.management().unsampled_reports_insert(req, "accountId", "webPropertyId", "profileId")
28112///              .doit().await;
28113/// # }
28114/// ```
28115pub struct ManagementUnsampledReportInsertCall<'a, C>
28116where
28117    C: 'a,
28118{
28119    hub: &'a Analytics<C>,
28120    _request: UnsampledReport,
28121    _account_id: String,
28122    _web_property_id: String,
28123    _profile_id: String,
28124    _delegate: Option<&'a mut dyn common::Delegate>,
28125    _additional_params: HashMap<String, String>,
28126    _scopes: BTreeSet<String>,
28127}
28128
28129impl<'a, C> common::CallBuilder for ManagementUnsampledReportInsertCall<'a, C> {}
28130
28131impl<'a, C> ManagementUnsampledReportInsertCall<'a, C>
28132where
28133    C: common::Connector,
28134{
28135    /// Perform the operation you have build so far.
28136    pub async fn doit(mut self) -> common::Result<(common::Response, UnsampledReport)> {
28137        use std::borrow::Cow;
28138        use std::io::{Read, Seek};
28139
28140        use common::{url::Params, ToParts};
28141        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28142
28143        let mut dd = common::DefaultDelegate;
28144        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28145        dlg.begin(common::MethodInfo {
28146            id: "analytics.management.unsampledReports.insert",
28147            http_method: hyper::Method::POST,
28148        });
28149
28150        for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
28151            if self._additional_params.contains_key(field) {
28152                dlg.finished(false);
28153                return Err(common::Error::FieldClash(field));
28154            }
28155        }
28156
28157        let mut params = Params::with_capacity(6 + self._additional_params.len());
28158        params.push("accountId", self._account_id);
28159        params.push("webPropertyId", self._web_property_id);
28160        params.push("profileId", self._profile_id);
28161
28162        params.extend(self._additional_params.iter());
28163
28164        params.push("alt", "json");
28165        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports";
28166        if self._scopes.is_empty() {
28167            self._scopes.insert(Scope::Full.as_ref().to_string());
28168        }
28169
28170        #[allow(clippy::single_element_loop)]
28171        for &(find_this, param_name) in [
28172            ("{accountId}", "accountId"),
28173            ("{webPropertyId}", "webPropertyId"),
28174            ("{profileId}", "profileId"),
28175        ]
28176        .iter()
28177        {
28178            url = params.uri_replacement(url, param_name, find_this, false);
28179        }
28180        {
28181            let to_remove = ["profileId", "webPropertyId", "accountId"];
28182            params.remove_params(&to_remove);
28183        }
28184
28185        let url = params.parse_with_url(&url);
28186
28187        let mut json_mime_type = mime::APPLICATION_JSON;
28188        let mut request_value_reader = {
28189            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28190            common::remove_json_null_values(&mut value);
28191            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28192            serde_json::to_writer(&mut dst, &value).unwrap();
28193            dst
28194        };
28195        let request_size = request_value_reader
28196            .seek(std::io::SeekFrom::End(0))
28197            .unwrap();
28198        request_value_reader
28199            .seek(std::io::SeekFrom::Start(0))
28200            .unwrap();
28201
28202        loop {
28203            let token = match self
28204                .hub
28205                .auth
28206                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28207                .await
28208            {
28209                Ok(token) => token,
28210                Err(e) => match dlg.token(e) {
28211                    Ok(token) => token,
28212                    Err(e) => {
28213                        dlg.finished(false);
28214                        return Err(common::Error::MissingToken(e));
28215                    }
28216                },
28217            };
28218            request_value_reader
28219                .seek(std::io::SeekFrom::Start(0))
28220                .unwrap();
28221            let mut req_result = {
28222                let client = &self.hub.client;
28223                dlg.pre_request();
28224                let mut req_builder = hyper::Request::builder()
28225                    .method(hyper::Method::POST)
28226                    .uri(url.as_str())
28227                    .header(USER_AGENT, self.hub._user_agent.clone());
28228
28229                if let Some(token) = token.as_ref() {
28230                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28231                }
28232
28233                let request = req_builder
28234                    .header(CONTENT_TYPE, json_mime_type.to_string())
28235                    .header(CONTENT_LENGTH, request_size as u64)
28236                    .body(common::to_body(
28237                        request_value_reader.get_ref().clone().into(),
28238                    ));
28239
28240                client.request(request.unwrap()).await
28241            };
28242
28243            match req_result {
28244                Err(err) => {
28245                    if let common::Retry::After(d) = dlg.http_error(&err) {
28246                        sleep(d).await;
28247                        continue;
28248                    }
28249                    dlg.finished(false);
28250                    return Err(common::Error::HttpError(err));
28251                }
28252                Ok(res) => {
28253                    let (mut parts, body) = res.into_parts();
28254                    let mut body = common::Body::new(body);
28255                    if !parts.status.is_success() {
28256                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28257                        let error = serde_json::from_str(&common::to_string(&bytes));
28258                        let response = common::to_response(parts, bytes.into());
28259
28260                        if let common::Retry::After(d) =
28261                            dlg.http_failure(&response, error.as_ref().ok())
28262                        {
28263                            sleep(d).await;
28264                            continue;
28265                        }
28266
28267                        dlg.finished(false);
28268
28269                        return Err(match error {
28270                            Ok(value) => common::Error::BadRequest(value),
28271                            _ => common::Error::Failure(response),
28272                        });
28273                    }
28274                    let response = {
28275                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28276                        let encoded = common::to_string(&bytes);
28277                        match serde_json::from_str(&encoded) {
28278                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28279                            Err(error) => {
28280                                dlg.response_json_decode_error(&encoded, &error);
28281                                return Err(common::Error::JsonDecodeError(
28282                                    encoded.to_string(),
28283                                    error,
28284                                ));
28285                            }
28286                        }
28287                    };
28288
28289                    dlg.finished(true);
28290                    return Ok(response);
28291                }
28292            }
28293        }
28294    }
28295
28296    ///
28297    /// Sets the *request* property to the given value.
28298    ///
28299    /// Even though the property as already been set when instantiating this call,
28300    /// we provide this method for API completeness.
28301    pub fn request(
28302        mut self,
28303        new_value: UnsampledReport,
28304    ) -> ManagementUnsampledReportInsertCall<'a, C> {
28305        self._request = new_value;
28306        self
28307    }
28308    /// Account ID to create the unsampled report for.
28309    ///
28310    /// Sets the *account id* path property to the given value.
28311    ///
28312    /// Even though the property as already been set when instantiating this call,
28313    /// we provide this method for API completeness.
28314    pub fn account_id(mut self, new_value: &str) -> ManagementUnsampledReportInsertCall<'a, C> {
28315        self._account_id = new_value.to_string();
28316        self
28317    }
28318    /// Web property ID to create the unsampled report for.
28319    ///
28320    /// Sets the *web property id* path property to the given value.
28321    ///
28322    /// Even though the property as already been set when instantiating this call,
28323    /// we provide this method for API completeness.
28324    pub fn web_property_id(
28325        mut self,
28326        new_value: &str,
28327    ) -> ManagementUnsampledReportInsertCall<'a, C> {
28328        self._web_property_id = new_value.to_string();
28329        self
28330    }
28331    /// View (Profile) ID to create the unsampled report for.
28332    ///
28333    /// Sets the *profile id* path property to the given value.
28334    ///
28335    /// Even though the property as already been set when instantiating this call,
28336    /// we provide this method for API completeness.
28337    pub fn profile_id(mut self, new_value: &str) -> ManagementUnsampledReportInsertCall<'a, C> {
28338        self._profile_id = new_value.to_string();
28339        self
28340    }
28341    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28342    /// while executing the actual API request.
28343    ///
28344    /// ````text
28345    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28346    /// ````
28347    ///
28348    /// Sets the *delegate* property to the given value.
28349    pub fn delegate(
28350        mut self,
28351        new_value: &'a mut dyn common::Delegate,
28352    ) -> ManagementUnsampledReportInsertCall<'a, C> {
28353        self._delegate = Some(new_value);
28354        self
28355    }
28356
28357    /// Set any additional parameter of the query string used in the request.
28358    /// It should be used to set parameters which are not yet available through their own
28359    /// setters.
28360    ///
28361    /// Please note that this method must not be used to set any of the known parameters
28362    /// which have their own setter method. If done anyway, the request will fail.
28363    ///
28364    /// # Additional Parameters
28365    ///
28366    /// * *alt* (query-string) - Data format for the response.
28367    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28368    /// * *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.
28369    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28370    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28371    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28372    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28373    pub fn param<T>(mut self, name: T, value: T) -> ManagementUnsampledReportInsertCall<'a, C>
28374    where
28375        T: AsRef<str>,
28376    {
28377        self._additional_params
28378            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28379        self
28380    }
28381
28382    /// Identifies the authorization scope for the method you are building.
28383    ///
28384    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28385    /// [`Scope::Full`].
28386    ///
28387    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28388    /// tokens for more than one scope.
28389    ///
28390    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28391    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28392    /// sufficient, a read-write scope will do as well.
28393    pub fn add_scope<St>(mut self, scope: St) -> ManagementUnsampledReportInsertCall<'a, C>
28394    where
28395        St: AsRef<str>,
28396    {
28397        self._scopes.insert(String::from(scope.as_ref()));
28398        self
28399    }
28400    /// Identifies the authorization scope(s) for the method you are building.
28401    ///
28402    /// See [`Self::add_scope()`] for details.
28403    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUnsampledReportInsertCall<'a, C>
28404    where
28405        I: IntoIterator<Item = St>,
28406        St: AsRef<str>,
28407    {
28408        self._scopes
28409            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28410        self
28411    }
28412
28413    /// Removes all scopes, and no default scope will be used either.
28414    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28415    /// for details).
28416    pub fn clear_scopes(mut self) -> ManagementUnsampledReportInsertCall<'a, C> {
28417        self._scopes.clear();
28418        self
28419    }
28420}
28421
28422/// Lists unsampled reports to which the user has access.
28423///
28424/// A builder for the *unsampledReports.list* method supported by a *management* resource.
28425/// It is not used directly, but through a [`ManagementMethods`] instance.
28426///
28427/// # Example
28428///
28429/// Instantiate a resource method builder
28430///
28431/// ```test_harness,no_run
28432/// # extern crate hyper;
28433/// # extern crate hyper_rustls;
28434/// # extern crate google_analytics3 as analytics3;
28435/// # async fn dox() {
28436/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28437///
28438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28439/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28440/// #     .with_native_roots()
28441/// #     .unwrap()
28442/// #     .https_only()
28443/// #     .enable_http2()
28444/// #     .build();
28445///
28446/// # let executor = hyper_util::rt::TokioExecutor::new();
28447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28448/// #     secret,
28449/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28450/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28451/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28452/// #     ),
28453/// # ).build().await.unwrap();
28454///
28455/// # let client = hyper_util::client::legacy::Client::builder(
28456/// #     hyper_util::rt::TokioExecutor::new()
28457/// # )
28458/// # .build(
28459/// #     hyper_rustls::HttpsConnectorBuilder::new()
28460/// #         .with_native_roots()
28461/// #         .unwrap()
28462/// #         .https_or_http()
28463/// #         .enable_http2()
28464/// #         .build()
28465/// # );
28466/// # let mut hub = Analytics::new(client, auth);
28467/// // You can configure optional parameters by calling the respective setters at will, and
28468/// // execute the final call using `doit()`.
28469/// // Values shown here are possibly random and not representative !
28470/// let result = hub.management().unsampled_reports_list("accountId", "webPropertyId", "profileId")
28471///              .start_index(-15)
28472///              .max_results(-82)
28473///              .doit().await;
28474/// # }
28475/// ```
28476pub struct ManagementUnsampledReportListCall<'a, C>
28477where
28478    C: 'a,
28479{
28480    hub: &'a Analytics<C>,
28481    _account_id: String,
28482    _web_property_id: String,
28483    _profile_id: String,
28484    _start_index: Option<i32>,
28485    _max_results: Option<i32>,
28486    _delegate: Option<&'a mut dyn common::Delegate>,
28487    _additional_params: HashMap<String, String>,
28488    _scopes: BTreeSet<String>,
28489}
28490
28491impl<'a, C> common::CallBuilder for ManagementUnsampledReportListCall<'a, C> {}
28492
28493impl<'a, C> ManagementUnsampledReportListCall<'a, C>
28494where
28495    C: common::Connector,
28496{
28497    /// Perform the operation you have build so far.
28498    pub async fn doit(mut self) -> common::Result<(common::Response, UnsampledReports)> {
28499        use std::borrow::Cow;
28500        use std::io::{Read, Seek};
28501
28502        use common::{url::Params, ToParts};
28503        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28504
28505        let mut dd = common::DefaultDelegate;
28506        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28507        dlg.begin(common::MethodInfo {
28508            id: "analytics.management.unsampledReports.list",
28509            http_method: hyper::Method::GET,
28510        });
28511
28512        for &field in [
28513            "alt",
28514            "accountId",
28515            "webPropertyId",
28516            "profileId",
28517            "start-index",
28518            "max-results",
28519        ]
28520        .iter()
28521        {
28522            if self._additional_params.contains_key(field) {
28523                dlg.finished(false);
28524                return Err(common::Error::FieldClash(field));
28525            }
28526        }
28527
28528        let mut params = Params::with_capacity(7 + self._additional_params.len());
28529        params.push("accountId", self._account_id);
28530        params.push("webPropertyId", self._web_property_id);
28531        params.push("profileId", self._profile_id);
28532        if let Some(value) = self._start_index.as_ref() {
28533            params.push("start-index", value.to_string());
28534        }
28535        if let Some(value) = self._max_results.as_ref() {
28536            params.push("max-results", value.to_string());
28537        }
28538
28539        params.extend(self._additional_params.iter());
28540
28541        params.push("alt", "json");
28542        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports";
28543        if self._scopes.is_empty() {
28544            self._scopes.insert(Scope::Readonly.as_ref().to_string());
28545        }
28546
28547        #[allow(clippy::single_element_loop)]
28548        for &(find_this, param_name) in [
28549            ("{accountId}", "accountId"),
28550            ("{webPropertyId}", "webPropertyId"),
28551            ("{profileId}", "profileId"),
28552        ]
28553        .iter()
28554        {
28555            url = params.uri_replacement(url, param_name, find_this, false);
28556        }
28557        {
28558            let to_remove = ["profileId", "webPropertyId", "accountId"];
28559            params.remove_params(&to_remove);
28560        }
28561
28562        let url = params.parse_with_url(&url);
28563
28564        loop {
28565            let token = match self
28566                .hub
28567                .auth
28568                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28569                .await
28570            {
28571                Ok(token) => token,
28572                Err(e) => match dlg.token(e) {
28573                    Ok(token) => token,
28574                    Err(e) => {
28575                        dlg.finished(false);
28576                        return Err(common::Error::MissingToken(e));
28577                    }
28578                },
28579            };
28580            let mut req_result = {
28581                let client = &self.hub.client;
28582                dlg.pre_request();
28583                let mut req_builder = hyper::Request::builder()
28584                    .method(hyper::Method::GET)
28585                    .uri(url.as_str())
28586                    .header(USER_AGENT, self.hub._user_agent.clone());
28587
28588                if let Some(token) = token.as_ref() {
28589                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28590                }
28591
28592                let request = req_builder
28593                    .header(CONTENT_LENGTH, 0_u64)
28594                    .body(common::to_body::<String>(None));
28595
28596                client.request(request.unwrap()).await
28597            };
28598
28599            match req_result {
28600                Err(err) => {
28601                    if let common::Retry::After(d) = dlg.http_error(&err) {
28602                        sleep(d).await;
28603                        continue;
28604                    }
28605                    dlg.finished(false);
28606                    return Err(common::Error::HttpError(err));
28607                }
28608                Ok(res) => {
28609                    let (mut parts, body) = res.into_parts();
28610                    let mut body = common::Body::new(body);
28611                    if !parts.status.is_success() {
28612                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28613                        let error = serde_json::from_str(&common::to_string(&bytes));
28614                        let response = common::to_response(parts, bytes.into());
28615
28616                        if let common::Retry::After(d) =
28617                            dlg.http_failure(&response, error.as_ref().ok())
28618                        {
28619                            sleep(d).await;
28620                            continue;
28621                        }
28622
28623                        dlg.finished(false);
28624
28625                        return Err(match error {
28626                            Ok(value) => common::Error::BadRequest(value),
28627                            _ => common::Error::Failure(response),
28628                        });
28629                    }
28630                    let response = {
28631                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28632                        let encoded = common::to_string(&bytes);
28633                        match serde_json::from_str(&encoded) {
28634                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28635                            Err(error) => {
28636                                dlg.response_json_decode_error(&encoded, &error);
28637                                return Err(common::Error::JsonDecodeError(
28638                                    encoded.to_string(),
28639                                    error,
28640                                ));
28641                            }
28642                        }
28643                    };
28644
28645                    dlg.finished(true);
28646                    return Ok(response);
28647                }
28648            }
28649        }
28650    }
28651
28652    /// Account ID to retrieve unsampled reports for. Must be a specific account ID, ~all is not supported.
28653    ///
28654    /// Sets the *account id* path property to the given value.
28655    ///
28656    /// Even though the property as already been set when instantiating this call,
28657    /// we provide this method for API completeness.
28658    pub fn account_id(mut self, new_value: &str) -> ManagementUnsampledReportListCall<'a, C> {
28659        self._account_id = new_value.to_string();
28660        self
28661    }
28662    /// Web property ID to retrieve unsampled reports for. Must be a specific web property ID, ~all is not supported.
28663    ///
28664    /// Sets the *web property id* path property to the given value.
28665    ///
28666    /// Even though the property as already been set when instantiating this call,
28667    /// we provide this method for API completeness.
28668    pub fn web_property_id(mut self, new_value: &str) -> ManagementUnsampledReportListCall<'a, C> {
28669        self._web_property_id = new_value.to_string();
28670        self
28671    }
28672    /// View (Profile) ID to retrieve unsampled reports for. Must be a specific view (profile) ID, ~all is not supported.
28673    ///
28674    /// Sets the *profile id* path property to the given value.
28675    ///
28676    /// Even though the property as already been set when instantiating this call,
28677    /// we provide this method for API completeness.
28678    pub fn profile_id(mut self, new_value: &str) -> ManagementUnsampledReportListCall<'a, C> {
28679        self._profile_id = new_value.to_string();
28680        self
28681    }
28682    /// An index of the first unsampled report to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
28683    ///
28684    /// Sets the *start-index* query property to the given value.
28685    pub fn start_index(mut self, new_value: i32) -> ManagementUnsampledReportListCall<'a, C> {
28686        self._start_index = Some(new_value);
28687        self
28688    }
28689    /// The maximum number of unsampled reports to include in this response.
28690    ///
28691    /// Sets the *max-results* query property to the given value.
28692    pub fn max_results(mut self, new_value: i32) -> ManagementUnsampledReportListCall<'a, C> {
28693        self._max_results = Some(new_value);
28694        self
28695    }
28696    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28697    /// while executing the actual API request.
28698    ///
28699    /// ````text
28700    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28701    /// ````
28702    ///
28703    /// Sets the *delegate* property to the given value.
28704    pub fn delegate(
28705        mut self,
28706        new_value: &'a mut dyn common::Delegate,
28707    ) -> ManagementUnsampledReportListCall<'a, C> {
28708        self._delegate = Some(new_value);
28709        self
28710    }
28711
28712    /// Set any additional parameter of the query string used in the request.
28713    /// It should be used to set parameters which are not yet available through their own
28714    /// setters.
28715    ///
28716    /// Please note that this method must not be used to set any of the known parameters
28717    /// which have their own setter method. If done anyway, the request will fail.
28718    ///
28719    /// # Additional Parameters
28720    ///
28721    /// * *alt* (query-string) - Data format for the response.
28722    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28723    /// * *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.
28724    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28725    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28726    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28727    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28728    pub fn param<T>(mut self, name: T, value: T) -> ManagementUnsampledReportListCall<'a, C>
28729    where
28730        T: AsRef<str>,
28731    {
28732        self._additional_params
28733            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28734        self
28735    }
28736
28737    /// Identifies the authorization scope for the method you are building.
28738    ///
28739    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28740    /// [`Scope::Readonly`].
28741    ///
28742    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28743    /// tokens for more than one scope.
28744    ///
28745    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28746    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28747    /// sufficient, a read-write scope will do as well.
28748    pub fn add_scope<St>(mut self, scope: St) -> ManagementUnsampledReportListCall<'a, C>
28749    where
28750        St: AsRef<str>,
28751    {
28752        self._scopes.insert(String::from(scope.as_ref()));
28753        self
28754    }
28755    /// Identifies the authorization scope(s) for the method you are building.
28756    ///
28757    /// See [`Self::add_scope()`] for details.
28758    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUnsampledReportListCall<'a, C>
28759    where
28760        I: IntoIterator<Item = St>,
28761        St: AsRef<str>,
28762    {
28763        self._scopes
28764            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28765        self
28766    }
28767
28768    /// Removes all scopes, and no default scope will be used either.
28769    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28770    /// for details).
28771    pub fn clear_scopes(mut self) -> ManagementUnsampledReportListCall<'a, C> {
28772        self._scopes.clear();
28773        self
28774    }
28775}
28776
28777/// Delete data associated with a previous upload.
28778///
28779/// A builder for the *uploads.deleteUploadData* method supported by a *management* resource.
28780/// It is not used directly, but through a [`ManagementMethods`] instance.
28781///
28782/// # Example
28783///
28784/// Instantiate a resource method builder
28785///
28786/// ```test_harness,no_run
28787/// # extern crate hyper;
28788/// # extern crate hyper_rustls;
28789/// # extern crate google_analytics3 as analytics3;
28790/// use analytics3::api::AnalyticsDataimportDeleteUploadDataRequest;
28791/// # async fn dox() {
28792/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28793///
28794/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28795/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28796/// #     .with_native_roots()
28797/// #     .unwrap()
28798/// #     .https_only()
28799/// #     .enable_http2()
28800/// #     .build();
28801///
28802/// # let executor = hyper_util::rt::TokioExecutor::new();
28803/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28804/// #     secret,
28805/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28806/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28807/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28808/// #     ),
28809/// # ).build().await.unwrap();
28810///
28811/// # let client = hyper_util::client::legacy::Client::builder(
28812/// #     hyper_util::rt::TokioExecutor::new()
28813/// # )
28814/// # .build(
28815/// #     hyper_rustls::HttpsConnectorBuilder::new()
28816/// #         .with_native_roots()
28817/// #         .unwrap()
28818/// #         .https_or_http()
28819/// #         .enable_http2()
28820/// #         .build()
28821/// # );
28822/// # let mut hub = Analytics::new(client, auth);
28823/// // As the method needs a request, you would usually fill it with the desired information
28824/// // into the respective structure. Some of the parts shown here might not be applicable !
28825/// // Values shown here are possibly random and not representative !
28826/// let mut req = AnalyticsDataimportDeleteUploadDataRequest::default();
28827///
28828/// // You can configure optional parameters by calling the respective setters at will, and
28829/// // execute the final call using `doit()`.
28830/// // Values shown here are possibly random and not representative !
28831/// let result = hub.management().uploads_delete_upload_data(req, "accountId", "webPropertyId", "customDataSourceId")
28832///              .doit().await;
28833/// # }
28834/// ```
28835pub struct ManagementUploadDeleteUploadDataCall<'a, C>
28836where
28837    C: 'a,
28838{
28839    hub: &'a Analytics<C>,
28840    _request: AnalyticsDataimportDeleteUploadDataRequest,
28841    _account_id: String,
28842    _web_property_id: String,
28843    _custom_data_source_id: String,
28844    _delegate: Option<&'a mut dyn common::Delegate>,
28845    _additional_params: HashMap<String, String>,
28846    _scopes: BTreeSet<String>,
28847}
28848
28849impl<'a, C> common::CallBuilder for ManagementUploadDeleteUploadDataCall<'a, C> {}
28850
28851impl<'a, C> ManagementUploadDeleteUploadDataCall<'a, C>
28852where
28853    C: common::Connector,
28854{
28855    /// Perform the operation you have build so far.
28856    pub async fn doit(mut self) -> common::Result<common::Response> {
28857        use std::borrow::Cow;
28858        use std::io::{Read, Seek};
28859
28860        use common::{url::Params, ToParts};
28861        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28862
28863        let mut dd = common::DefaultDelegate;
28864        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28865        dlg.begin(common::MethodInfo {
28866            id: "analytics.management.uploads.deleteUploadData",
28867            http_method: hyper::Method::POST,
28868        });
28869
28870        for &field in ["accountId", "webPropertyId", "customDataSourceId"].iter() {
28871            if self._additional_params.contains_key(field) {
28872                dlg.finished(false);
28873                return Err(common::Error::FieldClash(field));
28874            }
28875        }
28876
28877        let mut params = Params::with_capacity(5 + self._additional_params.len());
28878        params.push("accountId", self._account_id);
28879        params.push("webPropertyId", self._web_property_id);
28880        params.push("customDataSourceId", self._custom_data_source_id);
28881
28882        params.extend(self._additional_params.iter());
28883
28884        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/deleteUploadData";
28885        if self._scopes.is_empty() {
28886            self._scopes.insert(Scope::Full.as_ref().to_string());
28887        }
28888
28889        #[allow(clippy::single_element_loop)]
28890        for &(find_this, param_name) in [
28891            ("{accountId}", "accountId"),
28892            ("{webPropertyId}", "webPropertyId"),
28893            ("{customDataSourceId}", "customDataSourceId"),
28894        ]
28895        .iter()
28896        {
28897            url = params.uri_replacement(url, param_name, find_this, false);
28898        }
28899        {
28900            let to_remove = ["customDataSourceId", "webPropertyId", "accountId"];
28901            params.remove_params(&to_remove);
28902        }
28903
28904        let url = params.parse_with_url(&url);
28905
28906        let mut json_mime_type = mime::APPLICATION_JSON;
28907        let mut request_value_reader = {
28908            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28909            common::remove_json_null_values(&mut value);
28910            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28911            serde_json::to_writer(&mut dst, &value).unwrap();
28912            dst
28913        };
28914        let request_size = request_value_reader
28915            .seek(std::io::SeekFrom::End(0))
28916            .unwrap();
28917        request_value_reader
28918            .seek(std::io::SeekFrom::Start(0))
28919            .unwrap();
28920
28921        loop {
28922            let token = match self
28923                .hub
28924                .auth
28925                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28926                .await
28927            {
28928                Ok(token) => token,
28929                Err(e) => match dlg.token(e) {
28930                    Ok(token) => token,
28931                    Err(e) => {
28932                        dlg.finished(false);
28933                        return Err(common::Error::MissingToken(e));
28934                    }
28935                },
28936            };
28937            request_value_reader
28938                .seek(std::io::SeekFrom::Start(0))
28939                .unwrap();
28940            let mut req_result = {
28941                let client = &self.hub.client;
28942                dlg.pre_request();
28943                let mut req_builder = hyper::Request::builder()
28944                    .method(hyper::Method::POST)
28945                    .uri(url.as_str())
28946                    .header(USER_AGENT, self.hub._user_agent.clone());
28947
28948                if let Some(token) = token.as_ref() {
28949                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28950                }
28951
28952                let request = req_builder
28953                    .header(CONTENT_TYPE, json_mime_type.to_string())
28954                    .header(CONTENT_LENGTH, request_size as u64)
28955                    .body(common::to_body(
28956                        request_value_reader.get_ref().clone().into(),
28957                    ));
28958
28959                client.request(request.unwrap()).await
28960            };
28961
28962            match req_result {
28963                Err(err) => {
28964                    if let common::Retry::After(d) = dlg.http_error(&err) {
28965                        sleep(d).await;
28966                        continue;
28967                    }
28968                    dlg.finished(false);
28969                    return Err(common::Error::HttpError(err));
28970                }
28971                Ok(res) => {
28972                    let (mut parts, body) = res.into_parts();
28973                    let mut body = common::Body::new(body);
28974                    if !parts.status.is_success() {
28975                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28976                        let error = serde_json::from_str(&common::to_string(&bytes));
28977                        let response = common::to_response(parts, bytes.into());
28978
28979                        if let common::Retry::After(d) =
28980                            dlg.http_failure(&response, error.as_ref().ok())
28981                        {
28982                            sleep(d).await;
28983                            continue;
28984                        }
28985
28986                        dlg.finished(false);
28987
28988                        return Err(match error {
28989                            Ok(value) => common::Error::BadRequest(value),
28990                            _ => common::Error::Failure(response),
28991                        });
28992                    }
28993                    let response = common::Response::from_parts(parts, body);
28994
28995                    dlg.finished(true);
28996                    return Ok(response);
28997                }
28998            }
28999        }
29000    }
29001
29002    ///
29003    /// Sets the *request* property to the given value.
29004    ///
29005    /// Even though the property as already been set when instantiating this call,
29006    /// we provide this method for API completeness.
29007    pub fn request(
29008        mut self,
29009        new_value: AnalyticsDataimportDeleteUploadDataRequest,
29010    ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
29011        self._request = new_value;
29012        self
29013    }
29014    /// Account Id for the uploads to be deleted.
29015    ///
29016    /// Sets the *account id* path property to the given value.
29017    ///
29018    /// Even though the property as already been set when instantiating this call,
29019    /// we provide this method for API completeness.
29020    pub fn account_id(mut self, new_value: &str) -> ManagementUploadDeleteUploadDataCall<'a, C> {
29021        self._account_id = new_value.to_string();
29022        self
29023    }
29024    /// Web property Id for the uploads to be deleted.
29025    ///
29026    /// Sets the *web property id* path property to the given value.
29027    ///
29028    /// Even though the property as already been set when instantiating this call,
29029    /// we provide this method for API completeness.
29030    pub fn web_property_id(
29031        mut self,
29032        new_value: &str,
29033    ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
29034        self._web_property_id = new_value.to_string();
29035        self
29036    }
29037    /// Custom data source Id for the uploads to be deleted.
29038    ///
29039    /// Sets the *custom data source id* path property to the given value.
29040    ///
29041    /// Even though the property as already been set when instantiating this call,
29042    /// we provide this method for API completeness.
29043    pub fn custom_data_source_id(
29044        mut self,
29045        new_value: &str,
29046    ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
29047        self._custom_data_source_id = new_value.to_string();
29048        self
29049    }
29050    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29051    /// while executing the actual API request.
29052    ///
29053    /// ````text
29054    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29055    /// ````
29056    ///
29057    /// Sets the *delegate* property to the given value.
29058    pub fn delegate(
29059        mut self,
29060        new_value: &'a mut dyn common::Delegate,
29061    ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
29062        self._delegate = Some(new_value);
29063        self
29064    }
29065
29066    /// Set any additional parameter of the query string used in the request.
29067    /// It should be used to set parameters which are not yet available through their own
29068    /// setters.
29069    ///
29070    /// Please note that this method must not be used to set any of the known parameters
29071    /// which have their own setter method. If done anyway, the request will fail.
29072    ///
29073    /// # Additional Parameters
29074    ///
29075    /// * *alt* (query-string) - Data format for the response.
29076    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29077    /// * *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.
29078    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29079    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29080    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29081    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29082    pub fn param<T>(mut self, name: T, value: T) -> ManagementUploadDeleteUploadDataCall<'a, C>
29083    where
29084        T: AsRef<str>,
29085    {
29086        self._additional_params
29087            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29088        self
29089    }
29090
29091    /// Identifies the authorization scope for the method you are building.
29092    ///
29093    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29094    /// [`Scope::Full`].
29095    ///
29096    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29097    /// tokens for more than one scope.
29098    ///
29099    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29100    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29101    /// sufficient, a read-write scope will do as well.
29102    pub fn add_scope<St>(mut self, scope: St) -> ManagementUploadDeleteUploadDataCall<'a, C>
29103    where
29104        St: AsRef<str>,
29105    {
29106        self._scopes.insert(String::from(scope.as_ref()));
29107        self
29108    }
29109    /// Identifies the authorization scope(s) for the method you are building.
29110    ///
29111    /// See [`Self::add_scope()`] for details.
29112    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUploadDeleteUploadDataCall<'a, C>
29113    where
29114        I: IntoIterator<Item = St>,
29115        St: AsRef<str>,
29116    {
29117        self._scopes
29118            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29119        self
29120    }
29121
29122    /// Removes all scopes, and no default scope will be used either.
29123    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29124    /// for details).
29125    pub fn clear_scopes(mut self) -> ManagementUploadDeleteUploadDataCall<'a, C> {
29126        self._scopes.clear();
29127        self
29128    }
29129}
29130
29131/// List uploads to which the user has access.
29132///
29133/// A builder for the *uploads.get* method supported by a *management* resource.
29134/// It is not used directly, but through a [`ManagementMethods`] instance.
29135///
29136/// # Example
29137///
29138/// Instantiate a resource method builder
29139///
29140/// ```test_harness,no_run
29141/// # extern crate hyper;
29142/// # extern crate hyper_rustls;
29143/// # extern crate google_analytics3 as analytics3;
29144/// # async fn dox() {
29145/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29146///
29147/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29148/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29149/// #     .with_native_roots()
29150/// #     .unwrap()
29151/// #     .https_only()
29152/// #     .enable_http2()
29153/// #     .build();
29154///
29155/// # let executor = hyper_util::rt::TokioExecutor::new();
29156/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29157/// #     secret,
29158/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29159/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29160/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29161/// #     ),
29162/// # ).build().await.unwrap();
29163///
29164/// # let client = hyper_util::client::legacy::Client::builder(
29165/// #     hyper_util::rt::TokioExecutor::new()
29166/// # )
29167/// # .build(
29168/// #     hyper_rustls::HttpsConnectorBuilder::new()
29169/// #         .with_native_roots()
29170/// #         .unwrap()
29171/// #         .https_or_http()
29172/// #         .enable_http2()
29173/// #         .build()
29174/// # );
29175/// # let mut hub = Analytics::new(client, auth);
29176/// // You can configure optional parameters by calling the respective setters at will, and
29177/// // execute the final call using `doit()`.
29178/// // Values shown here are possibly random and not representative !
29179/// let result = hub.management().uploads_get("accountId", "webPropertyId", "customDataSourceId", "uploadId")
29180///              .doit().await;
29181/// # }
29182/// ```
29183pub struct ManagementUploadGetCall<'a, C>
29184where
29185    C: 'a,
29186{
29187    hub: &'a Analytics<C>,
29188    _account_id: String,
29189    _web_property_id: String,
29190    _custom_data_source_id: String,
29191    _upload_id: String,
29192    _delegate: Option<&'a mut dyn common::Delegate>,
29193    _additional_params: HashMap<String, String>,
29194    _scopes: BTreeSet<String>,
29195}
29196
29197impl<'a, C> common::CallBuilder for ManagementUploadGetCall<'a, C> {}
29198
29199impl<'a, C> ManagementUploadGetCall<'a, C>
29200where
29201    C: common::Connector,
29202{
29203    /// Perform the operation you have build so far.
29204    pub async fn doit(mut self) -> common::Result<(common::Response, Upload)> {
29205        use std::borrow::Cow;
29206        use std::io::{Read, Seek};
29207
29208        use common::{url::Params, ToParts};
29209        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29210
29211        let mut dd = common::DefaultDelegate;
29212        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29213        dlg.begin(common::MethodInfo {
29214            id: "analytics.management.uploads.get",
29215            http_method: hyper::Method::GET,
29216        });
29217
29218        for &field in [
29219            "alt",
29220            "accountId",
29221            "webPropertyId",
29222            "customDataSourceId",
29223            "uploadId",
29224        ]
29225        .iter()
29226        {
29227            if self._additional_params.contains_key(field) {
29228                dlg.finished(false);
29229                return Err(common::Error::FieldClash(field));
29230            }
29231        }
29232
29233        let mut params = Params::with_capacity(6 + self._additional_params.len());
29234        params.push("accountId", self._account_id);
29235        params.push("webPropertyId", self._web_property_id);
29236        params.push("customDataSourceId", self._custom_data_source_id);
29237        params.push("uploadId", self._upload_id);
29238
29239        params.extend(self._additional_params.iter());
29240
29241        params.push("alt", "json");
29242        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads/{uploadId}";
29243        if self._scopes.is_empty() {
29244            self._scopes.insert(Scope::Readonly.as_ref().to_string());
29245        }
29246
29247        #[allow(clippy::single_element_loop)]
29248        for &(find_this, param_name) in [
29249            ("{accountId}", "accountId"),
29250            ("{webPropertyId}", "webPropertyId"),
29251            ("{customDataSourceId}", "customDataSourceId"),
29252            ("{uploadId}", "uploadId"),
29253        ]
29254        .iter()
29255        {
29256            url = params.uri_replacement(url, param_name, find_this, false);
29257        }
29258        {
29259            let to_remove = [
29260                "uploadId",
29261                "customDataSourceId",
29262                "webPropertyId",
29263                "accountId",
29264            ];
29265            params.remove_params(&to_remove);
29266        }
29267
29268        let url = params.parse_with_url(&url);
29269
29270        loop {
29271            let token = match self
29272                .hub
29273                .auth
29274                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29275                .await
29276            {
29277                Ok(token) => token,
29278                Err(e) => match dlg.token(e) {
29279                    Ok(token) => token,
29280                    Err(e) => {
29281                        dlg.finished(false);
29282                        return Err(common::Error::MissingToken(e));
29283                    }
29284                },
29285            };
29286            let mut req_result = {
29287                let client = &self.hub.client;
29288                dlg.pre_request();
29289                let mut req_builder = hyper::Request::builder()
29290                    .method(hyper::Method::GET)
29291                    .uri(url.as_str())
29292                    .header(USER_AGENT, self.hub._user_agent.clone());
29293
29294                if let Some(token) = token.as_ref() {
29295                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29296                }
29297
29298                let request = req_builder
29299                    .header(CONTENT_LENGTH, 0_u64)
29300                    .body(common::to_body::<String>(None));
29301
29302                client.request(request.unwrap()).await
29303            };
29304
29305            match req_result {
29306                Err(err) => {
29307                    if let common::Retry::After(d) = dlg.http_error(&err) {
29308                        sleep(d).await;
29309                        continue;
29310                    }
29311                    dlg.finished(false);
29312                    return Err(common::Error::HttpError(err));
29313                }
29314                Ok(res) => {
29315                    let (mut parts, body) = res.into_parts();
29316                    let mut body = common::Body::new(body);
29317                    if !parts.status.is_success() {
29318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29319                        let error = serde_json::from_str(&common::to_string(&bytes));
29320                        let response = common::to_response(parts, bytes.into());
29321
29322                        if let common::Retry::After(d) =
29323                            dlg.http_failure(&response, error.as_ref().ok())
29324                        {
29325                            sleep(d).await;
29326                            continue;
29327                        }
29328
29329                        dlg.finished(false);
29330
29331                        return Err(match error {
29332                            Ok(value) => common::Error::BadRequest(value),
29333                            _ => common::Error::Failure(response),
29334                        });
29335                    }
29336                    let response = {
29337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29338                        let encoded = common::to_string(&bytes);
29339                        match serde_json::from_str(&encoded) {
29340                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29341                            Err(error) => {
29342                                dlg.response_json_decode_error(&encoded, &error);
29343                                return Err(common::Error::JsonDecodeError(
29344                                    encoded.to_string(),
29345                                    error,
29346                                ));
29347                            }
29348                        }
29349                    };
29350
29351                    dlg.finished(true);
29352                    return Ok(response);
29353                }
29354            }
29355        }
29356    }
29357
29358    /// Account Id for the upload to retrieve.
29359    ///
29360    /// Sets the *account id* path property to the given value.
29361    ///
29362    /// Even though the property as already been set when instantiating this call,
29363    /// we provide this method for API completeness.
29364    pub fn account_id(mut self, new_value: &str) -> ManagementUploadGetCall<'a, C> {
29365        self._account_id = new_value.to_string();
29366        self
29367    }
29368    /// Web property Id for the upload to retrieve.
29369    ///
29370    /// Sets the *web property id* path property to the given value.
29371    ///
29372    /// Even though the property as already been set when instantiating this call,
29373    /// we provide this method for API completeness.
29374    pub fn web_property_id(mut self, new_value: &str) -> ManagementUploadGetCall<'a, C> {
29375        self._web_property_id = new_value.to_string();
29376        self
29377    }
29378    /// Custom data source Id for upload to retrieve.
29379    ///
29380    /// Sets the *custom data source id* path property to the given value.
29381    ///
29382    /// Even though the property as already been set when instantiating this call,
29383    /// we provide this method for API completeness.
29384    pub fn custom_data_source_id(mut self, new_value: &str) -> ManagementUploadGetCall<'a, C> {
29385        self._custom_data_source_id = new_value.to_string();
29386        self
29387    }
29388    /// Upload Id to retrieve.
29389    ///
29390    /// Sets the *upload id* path property to the given value.
29391    ///
29392    /// Even though the property as already been set when instantiating this call,
29393    /// we provide this method for API completeness.
29394    pub fn upload_id(mut self, new_value: &str) -> ManagementUploadGetCall<'a, C> {
29395        self._upload_id = new_value.to_string();
29396        self
29397    }
29398    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29399    /// while executing the actual API request.
29400    ///
29401    /// ````text
29402    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29403    /// ````
29404    ///
29405    /// Sets the *delegate* property to the given value.
29406    pub fn delegate(
29407        mut self,
29408        new_value: &'a mut dyn common::Delegate,
29409    ) -> ManagementUploadGetCall<'a, C> {
29410        self._delegate = Some(new_value);
29411        self
29412    }
29413
29414    /// Set any additional parameter of the query string used in the request.
29415    /// It should be used to set parameters which are not yet available through their own
29416    /// setters.
29417    ///
29418    /// Please note that this method must not be used to set any of the known parameters
29419    /// which have their own setter method. If done anyway, the request will fail.
29420    ///
29421    /// # Additional Parameters
29422    ///
29423    /// * *alt* (query-string) - Data format for the response.
29424    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29425    /// * *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.
29426    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29427    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29428    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29429    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29430    pub fn param<T>(mut self, name: T, value: T) -> ManagementUploadGetCall<'a, C>
29431    where
29432        T: AsRef<str>,
29433    {
29434        self._additional_params
29435            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29436        self
29437    }
29438
29439    /// Identifies the authorization scope for the method you are building.
29440    ///
29441    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29442    /// [`Scope::Readonly`].
29443    ///
29444    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29445    /// tokens for more than one scope.
29446    ///
29447    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29448    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29449    /// sufficient, a read-write scope will do as well.
29450    pub fn add_scope<St>(mut self, scope: St) -> ManagementUploadGetCall<'a, C>
29451    where
29452        St: AsRef<str>,
29453    {
29454        self._scopes.insert(String::from(scope.as_ref()));
29455        self
29456    }
29457    /// Identifies the authorization scope(s) for the method you are building.
29458    ///
29459    /// See [`Self::add_scope()`] for details.
29460    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUploadGetCall<'a, C>
29461    where
29462        I: IntoIterator<Item = St>,
29463        St: AsRef<str>,
29464    {
29465        self._scopes
29466            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29467        self
29468    }
29469
29470    /// Removes all scopes, and no default scope will be used either.
29471    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29472    /// for details).
29473    pub fn clear_scopes(mut self) -> ManagementUploadGetCall<'a, C> {
29474        self._scopes.clear();
29475        self
29476    }
29477}
29478
29479/// List uploads to which the user has access.
29480///
29481/// A builder for the *uploads.list* method supported by a *management* resource.
29482/// It is not used directly, but through a [`ManagementMethods`] instance.
29483///
29484/// # Example
29485///
29486/// Instantiate a resource method builder
29487///
29488/// ```test_harness,no_run
29489/// # extern crate hyper;
29490/// # extern crate hyper_rustls;
29491/// # extern crate google_analytics3 as analytics3;
29492/// # async fn dox() {
29493/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29494///
29495/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29496/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29497/// #     .with_native_roots()
29498/// #     .unwrap()
29499/// #     .https_only()
29500/// #     .enable_http2()
29501/// #     .build();
29502///
29503/// # let executor = hyper_util::rt::TokioExecutor::new();
29504/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29505/// #     secret,
29506/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29507/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29508/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29509/// #     ),
29510/// # ).build().await.unwrap();
29511///
29512/// # let client = hyper_util::client::legacy::Client::builder(
29513/// #     hyper_util::rt::TokioExecutor::new()
29514/// # )
29515/// # .build(
29516/// #     hyper_rustls::HttpsConnectorBuilder::new()
29517/// #         .with_native_roots()
29518/// #         .unwrap()
29519/// #         .https_or_http()
29520/// #         .enable_http2()
29521/// #         .build()
29522/// # );
29523/// # let mut hub = Analytics::new(client, auth);
29524/// // You can configure optional parameters by calling the respective setters at will, and
29525/// // execute the final call using `doit()`.
29526/// // Values shown here are possibly random and not representative !
29527/// let result = hub.management().uploads_list("accountId", "webPropertyId", "customDataSourceId")
29528///              .start_index(-99)
29529///              .max_results(-82)
29530///              .doit().await;
29531/// # }
29532/// ```
29533pub struct ManagementUploadListCall<'a, C>
29534where
29535    C: 'a,
29536{
29537    hub: &'a Analytics<C>,
29538    _account_id: String,
29539    _web_property_id: String,
29540    _custom_data_source_id: String,
29541    _start_index: Option<i32>,
29542    _max_results: Option<i32>,
29543    _delegate: Option<&'a mut dyn common::Delegate>,
29544    _additional_params: HashMap<String, String>,
29545    _scopes: BTreeSet<String>,
29546}
29547
29548impl<'a, C> common::CallBuilder for ManagementUploadListCall<'a, C> {}
29549
29550impl<'a, C> ManagementUploadListCall<'a, C>
29551where
29552    C: common::Connector,
29553{
29554    /// Perform the operation you have build so far.
29555    pub async fn doit(mut self) -> common::Result<(common::Response, Uploads)> {
29556        use std::borrow::Cow;
29557        use std::io::{Read, Seek};
29558
29559        use common::{url::Params, ToParts};
29560        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29561
29562        let mut dd = common::DefaultDelegate;
29563        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29564        dlg.begin(common::MethodInfo {
29565            id: "analytics.management.uploads.list",
29566            http_method: hyper::Method::GET,
29567        });
29568
29569        for &field in [
29570            "alt",
29571            "accountId",
29572            "webPropertyId",
29573            "customDataSourceId",
29574            "start-index",
29575            "max-results",
29576        ]
29577        .iter()
29578        {
29579            if self._additional_params.contains_key(field) {
29580                dlg.finished(false);
29581                return Err(common::Error::FieldClash(field));
29582            }
29583        }
29584
29585        let mut params = Params::with_capacity(7 + self._additional_params.len());
29586        params.push("accountId", self._account_id);
29587        params.push("webPropertyId", self._web_property_id);
29588        params.push("customDataSourceId", self._custom_data_source_id);
29589        if let Some(value) = self._start_index.as_ref() {
29590            params.push("start-index", value.to_string());
29591        }
29592        if let Some(value) = self._max_results.as_ref() {
29593            params.push("max-results", value.to_string());
29594        }
29595
29596        params.extend(self._additional_params.iter());
29597
29598        params.push("alt", "json");
29599        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads";
29600        if self._scopes.is_empty() {
29601            self._scopes.insert(Scope::Readonly.as_ref().to_string());
29602        }
29603
29604        #[allow(clippy::single_element_loop)]
29605        for &(find_this, param_name) in [
29606            ("{accountId}", "accountId"),
29607            ("{webPropertyId}", "webPropertyId"),
29608            ("{customDataSourceId}", "customDataSourceId"),
29609        ]
29610        .iter()
29611        {
29612            url = params.uri_replacement(url, param_name, find_this, false);
29613        }
29614        {
29615            let to_remove = ["customDataSourceId", "webPropertyId", "accountId"];
29616            params.remove_params(&to_remove);
29617        }
29618
29619        let url = params.parse_with_url(&url);
29620
29621        loop {
29622            let token = match self
29623                .hub
29624                .auth
29625                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29626                .await
29627            {
29628                Ok(token) => token,
29629                Err(e) => match dlg.token(e) {
29630                    Ok(token) => token,
29631                    Err(e) => {
29632                        dlg.finished(false);
29633                        return Err(common::Error::MissingToken(e));
29634                    }
29635                },
29636            };
29637            let mut req_result = {
29638                let client = &self.hub.client;
29639                dlg.pre_request();
29640                let mut req_builder = hyper::Request::builder()
29641                    .method(hyper::Method::GET)
29642                    .uri(url.as_str())
29643                    .header(USER_AGENT, self.hub._user_agent.clone());
29644
29645                if let Some(token) = token.as_ref() {
29646                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29647                }
29648
29649                let request = req_builder
29650                    .header(CONTENT_LENGTH, 0_u64)
29651                    .body(common::to_body::<String>(None));
29652
29653                client.request(request.unwrap()).await
29654            };
29655
29656            match req_result {
29657                Err(err) => {
29658                    if let common::Retry::After(d) = dlg.http_error(&err) {
29659                        sleep(d).await;
29660                        continue;
29661                    }
29662                    dlg.finished(false);
29663                    return Err(common::Error::HttpError(err));
29664                }
29665                Ok(res) => {
29666                    let (mut parts, body) = res.into_parts();
29667                    let mut body = common::Body::new(body);
29668                    if !parts.status.is_success() {
29669                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29670                        let error = serde_json::from_str(&common::to_string(&bytes));
29671                        let response = common::to_response(parts, bytes.into());
29672
29673                        if let common::Retry::After(d) =
29674                            dlg.http_failure(&response, error.as_ref().ok())
29675                        {
29676                            sleep(d).await;
29677                            continue;
29678                        }
29679
29680                        dlg.finished(false);
29681
29682                        return Err(match error {
29683                            Ok(value) => common::Error::BadRequest(value),
29684                            _ => common::Error::Failure(response),
29685                        });
29686                    }
29687                    let response = {
29688                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29689                        let encoded = common::to_string(&bytes);
29690                        match serde_json::from_str(&encoded) {
29691                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29692                            Err(error) => {
29693                                dlg.response_json_decode_error(&encoded, &error);
29694                                return Err(common::Error::JsonDecodeError(
29695                                    encoded.to_string(),
29696                                    error,
29697                                ));
29698                            }
29699                        }
29700                    };
29701
29702                    dlg.finished(true);
29703                    return Ok(response);
29704                }
29705            }
29706        }
29707    }
29708
29709    /// Account Id for the uploads to retrieve.
29710    ///
29711    /// Sets the *account id* path property to the given value.
29712    ///
29713    /// Even though the property as already been set when instantiating this call,
29714    /// we provide this method for API completeness.
29715    pub fn account_id(mut self, new_value: &str) -> ManagementUploadListCall<'a, C> {
29716        self._account_id = new_value.to_string();
29717        self
29718    }
29719    /// Web property Id for the uploads to retrieve.
29720    ///
29721    /// Sets the *web property id* path property to the given value.
29722    ///
29723    /// Even though the property as already been set when instantiating this call,
29724    /// we provide this method for API completeness.
29725    pub fn web_property_id(mut self, new_value: &str) -> ManagementUploadListCall<'a, C> {
29726        self._web_property_id = new_value.to_string();
29727        self
29728    }
29729    /// Custom data source Id for uploads to retrieve.
29730    ///
29731    /// Sets the *custom data source id* path property to the given value.
29732    ///
29733    /// Even though the property as already been set when instantiating this call,
29734    /// we provide this method for API completeness.
29735    pub fn custom_data_source_id(mut self, new_value: &str) -> ManagementUploadListCall<'a, C> {
29736        self._custom_data_source_id = new_value.to_string();
29737        self
29738    }
29739    /// A 1-based index of the first upload to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
29740    ///
29741    /// Sets the *start-index* query property to the given value.
29742    pub fn start_index(mut self, new_value: i32) -> ManagementUploadListCall<'a, C> {
29743        self._start_index = Some(new_value);
29744        self
29745    }
29746    /// The maximum number of uploads to include in this response.
29747    ///
29748    /// Sets the *max-results* query property to the given value.
29749    pub fn max_results(mut self, new_value: i32) -> ManagementUploadListCall<'a, C> {
29750        self._max_results = Some(new_value);
29751        self
29752    }
29753    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29754    /// while executing the actual API request.
29755    ///
29756    /// ````text
29757    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29758    /// ````
29759    ///
29760    /// Sets the *delegate* property to the given value.
29761    pub fn delegate(
29762        mut self,
29763        new_value: &'a mut dyn common::Delegate,
29764    ) -> ManagementUploadListCall<'a, C> {
29765        self._delegate = Some(new_value);
29766        self
29767    }
29768
29769    /// Set any additional parameter of the query string used in the request.
29770    /// It should be used to set parameters which are not yet available through their own
29771    /// setters.
29772    ///
29773    /// Please note that this method must not be used to set any of the known parameters
29774    /// which have their own setter method. If done anyway, the request will fail.
29775    ///
29776    /// # Additional Parameters
29777    ///
29778    /// * *alt* (query-string) - Data format for the response.
29779    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29780    /// * *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.
29781    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29782    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29783    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29784    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29785    pub fn param<T>(mut self, name: T, value: T) -> ManagementUploadListCall<'a, C>
29786    where
29787        T: AsRef<str>,
29788    {
29789        self._additional_params
29790            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29791        self
29792    }
29793
29794    /// Identifies the authorization scope for the method you are building.
29795    ///
29796    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29797    /// [`Scope::Readonly`].
29798    ///
29799    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29800    /// tokens for more than one scope.
29801    ///
29802    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29803    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29804    /// sufficient, a read-write scope will do as well.
29805    pub fn add_scope<St>(mut self, scope: St) -> ManagementUploadListCall<'a, C>
29806    where
29807        St: AsRef<str>,
29808    {
29809        self._scopes.insert(String::from(scope.as_ref()));
29810        self
29811    }
29812    /// Identifies the authorization scope(s) for the method you are building.
29813    ///
29814    /// See [`Self::add_scope()`] for details.
29815    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUploadListCall<'a, C>
29816    where
29817        I: IntoIterator<Item = St>,
29818        St: AsRef<str>,
29819    {
29820        self._scopes
29821            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29822        self
29823    }
29824
29825    /// Removes all scopes, and no default scope will be used either.
29826    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29827    /// for details).
29828    pub fn clear_scopes(mut self) -> ManagementUploadListCall<'a, C> {
29829        self._scopes.clear();
29830        self
29831    }
29832}
29833
29834/// Upload data for a custom data source.
29835///
29836/// A builder for the *uploads.uploadData* method supported by a *management* resource.
29837/// It is not used directly, but through a [`ManagementMethods`] instance.
29838///
29839/// # Example
29840///
29841/// Instantiate a resource method builder
29842///
29843/// ```test_harness,no_run
29844/// # extern crate hyper;
29845/// # extern crate hyper_rustls;
29846/// # extern crate google_analytics3 as analytics3;
29847/// use std::fs;
29848/// # async fn dox() {
29849/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29850///
29851/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29852/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29853/// #     .with_native_roots()
29854/// #     .unwrap()
29855/// #     .https_only()
29856/// #     .enable_http2()
29857/// #     .build();
29858///
29859/// # let executor = hyper_util::rt::TokioExecutor::new();
29860/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29861/// #     secret,
29862/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29863/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29864/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29865/// #     ),
29866/// # ).build().await.unwrap();
29867///
29868/// # let client = hyper_util::client::legacy::Client::builder(
29869/// #     hyper_util::rt::TokioExecutor::new()
29870/// # )
29871/// # .build(
29872/// #     hyper_rustls::HttpsConnectorBuilder::new()
29873/// #         .with_native_roots()
29874/// #         .unwrap()
29875/// #         .https_or_http()
29876/// #         .enable_http2()
29877/// #         .build()
29878/// # );
29879/// # let mut hub = Analytics::new(client, auth);
29880/// // You can configure optional parameters by calling the respective setters at will, and
29881/// // execute the final call using `upload(...)`.
29882/// // Values shown here are possibly random and not representative !
29883/// let result = hub.management().uploads_upload_data("accountId", "webPropertyId", "customDataSourceId")
29884///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
29885/// # }
29886/// ```
29887pub struct ManagementUploadUploadDataCall<'a, C>
29888where
29889    C: 'a,
29890{
29891    hub: &'a Analytics<C>,
29892    _account_id: String,
29893    _web_property_id: String,
29894    _custom_data_source_id: String,
29895    _delegate: Option<&'a mut dyn common::Delegate>,
29896    _additional_params: HashMap<String, String>,
29897    _scopes: BTreeSet<String>,
29898}
29899
29900impl<'a, C> common::CallBuilder for ManagementUploadUploadDataCall<'a, C> {}
29901
29902impl<'a, C> ManagementUploadUploadDataCall<'a, C>
29903where
29904    C: common::Connector,
29905{
29906    /// Perform the operation you have build so far.
29907    async fn doit<RS>(
29908        mut self,
29909        mut reader: RS,
29910        reader_mime_type: mime::Mime,
29911        protocol: common::UploadProtocol,
29912    ) -> common::Result<(common::Response, Upload)>
29913    where
29914        RS: common::ReadSeek,
29915    {
29916        use std::borrow::Cow;
29917        use std::io::{Read, Seek};
29918
29919        use common::{url::Params, ToParts};
29920        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29921
29922        let mut dd = common::DefaultDelegate;
29923        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29924        dlg.begin(common::MethodInfo {
29925            id: "analytics.management.uploads.uploadData",
29926            http_method: hyper::Method::POST,
29927        });
29928
29929        for &field in ["alt", "accountId", "webPropertyId", "customDataSourceId"].iter() {
29930            if self._additional_params.contains_key(field) {
29931                dlg.finished(false);
29932                return Err(common::Error::FieldClash(field));
29933            }
29934        }
29935
29936        let mut params = Params::with_capacity(5 + self._additional_params.len());
29937        params.push("accountId", self._account_id);
29938        params.push("webPropertyId", self._web_property_id);
29939        params.push("customDataSourceId", self._custom_data_source_id);
29940
29941        params.extend(self._additional_params.iter());
29942
29943        params.push("alt", "json");
29944        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
29945            (self.hub._root_url.clone() + "resumable/upload/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads", "resumable")
29946        } else if protocol == common::UploadProtocol::Simple {
29947            (self.hub._root_url.clone() + "upload/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads", "multipart")
29948        } else {
29949            unreachable!()
29950        };
29951        params.push("uploadType", upload_type);
29952        if self._scopes.is_empty() {
29953            self._scopes.insert(Scope::Full.as_ref().to_string());
29954        }
29955
29956        #[allow(clippy::single_element_loop)]
29957        for &(find_this, param_name) in [
29958            ("{accountId}", "accountId"),
29959            ("{webPropertyId}", "webPropertyId"),
29960            ("{customDataSourceId}", "customDataSourceId"),
29961        ]
29962        .iter()
29963        {
29964            url = params.uri_replacement(url, param_name, find_this, false);
29965        }
29966        {
29967            let to_remove = ["customDataSourceId", "webPropertyId", "accountId"];
29968            params.remove_params(&to_remove);
29969        }
29970
29971        let url = params.parse_with_url(&url);
29972
29973        let mut upload_url_from_server;
29974
29975        loop {
29976            let token = match self
29977                .hub
29978                .auth
29979                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29980                .await
29981            {
29982                Ok(token) => token,
29983                Err(e) => match dlg.token(e) {
29984                    Ok(token) => token,
29985                    Err(e) => {
29986                        dlg.finished(false);
29987                        return Err(common::Error::MissingToken(e));
29988                    }
29989                },
29990            };
29991            let mut req_result = {
29992                let client = &self.hub.client;
29993                dlg.pre_request();
29994                let mut req_builder = hyper::Request::builder()
29995                    .method(hyper::Method::POST)
29996                    .uri(url.as_str())
29997                    .header(USER_AGENT, self.hub._user_agent.clone());
29998
29999                if let Some(token) = token.as_ref() {
30000                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30001                }
30002
30003                upload_url_from_server = true;
30004                if protocol == common::UploadProtocol::Resumable {
30005                    req_builder = req_builder
30006                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
30007                }
30008
30009                let request = if protocol == common::UploadProtocol::Simple {
30010                    let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
30011                    reader.seek(std::io::SeekFrom::Start(0)).unwrap();
30012                    if size > 1073741824 {
30013                        return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
30014                    }
30015                    let mut bytes = Vec::with_capacity(size as usize);
30016                    reader.read_to_end(&mut bytes)?;
30017                    req_builder
30018                        .header(CONTENT_TYPE, reader_mime_type.to_string())
30019                        .header(CONTENT_LENGTH, size)
30020                        .body(common::to_body(bytes.into()))
30021                } else {
30022                    req_builder.body(common::to_body::<String>(None))
30023                };
30024
30025                client.request(request.unwrap()).await
30026            };
30027
30028            match req_result {
30029                Err(err) => {
30030                    if let common::Retry::After(d) = dlg.http_error(&err) {
30031                        sleep(d).await;
30032                        continue;
30033                    }
30034                    dlg.finished(false);
30035                    return Err(common::Error::HttpError(err));
30036                }
30037                Ok(res) => {
30038                    let (mut parts, body) = res.into_parts();
30039                    let mut body = common::Body::new(body);
30040                    if !parts.status.is_success() {
30041                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30042                        let error = serde_json::from_str(&common::to_string(&bytes));
30043                        let response = common::to_response(parts, bytes.into());
30044
30045                        if let common::Retry::After(d) =
30046                            dlg.http_failure(&response, error.as_ref().ok())
30047                        {
30048                            sleep(d).await;
30049                            continue;
30050                        }
30051
30052                        dlg.finished(false);
30053
30054                        return Err(match error {
30055                            Ok(value) => common::Error::BadRequest(value),
30056                            _ => common::Error::Failure(response),
30057                        });
30058                    }
30059                    if protocol == common::UploadProtocol::Resumable {
30060                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
30061                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
30062                        if size > 1073741824 {
30063                            return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
30064                        }
30065                        let upload_result = {
30066                            let url_str = &parts
30067                                .headers
30068                                .get("Location")
30069                                .expect("LOCATION header is part of protocol")
30070                                .to_str()
30071                                .unwrap();
30072                            if upload_url_from_server {
30073                                dlg.store_upload_url(Some(url_str));
30074                            }
30075
30076                            common::ResumableUploadHelper {
30077                                client: &self.hub.client,
30078                                delegate: dlg,
30079                                start_at: if upload_url_from_server {
30080                                    Some(0)
30081                                } else {
30082                                    None
30083                                },
30084                                auth: &self.hub.auth,
30085                                user_agent: &self.hub._user_agent,
30086                                // TODO: Check this assumption
30087                                auth_header: format!(
30088                                    "Bearer {}",
30089                                    token
30090                                        .ok_or_else(|| common::Error::MissingToken(
30091                                            "resumable upload requires token".into()
30092                                        ))?
30093                                        .as_str()
30094                                ),
30095                                url: url_str,
30096                                reader: &mut reader,
30097                                media_type: reader_mime_type.clone(),
30098                                content_length: size,
30099                            }
30100                            .upload()
30101                            .await
30102                        };
30103                        match upload_result {
30104                            None => {
30105                                dlg.finished(false);
30106                                return Err(common::Error::Cancelled);
30107                            }
30108                            Some(Err(err)) => {
30109                                dlg.finished(false);
30110                                return Err(common::Error::HttpError(err));
30111                            }
30112                            Some(Ok(response)) => {
30113                                (parts, body) = response.into_parts();
30114                                if !parts.status.is_success() {
30115                                    dlg.store_upload_url(None);
30116                                    dlg.finished(false);
30117                                    return Err(common::Error::Failure(
30118                                        common::Response::from_parts(parts, body),
30119                                    ));
30120                                }
30121                            }
30122                        }
30123                    }
30124                    let response = {
30125                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30126                        let encoded = common::to_string(&bytes);
30127                        match serde_json::from_str(&encoded) {
30128                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30129                            Err(error) => {
30130                                dlg.response_json_decode_error(&encoded, &error);
30131                                return Err(common::Error::JsonDecodeError(
30132                                    encoded.to_string(),
30133                                    error,
30134                                ));
30135                            }
30136                        }
30137                    };
30138
30139                    dlg.finished(true);
30140                    return Ok(response);
30141                }
30142            }
30143        }
30144    }
30145
30146    /// Upload media in a resumable fashion.
30147    /// Even if the upload fails or is interrupted, it can be resumed for a
30148    /// certain amount of time as the server maintains state temporarily.
30149    ///
30150    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
30151    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
30152    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
30153    /// `cancel_chunk_upload(...)`.
30154    ///
30155    /// * *multipart*: yes
30156    /// * *max size*: 1GB
30157    /// * *valid mime types*: 'application/octet-stream'
30158    pub async fn upload_resumable<RS>(
30159        self,
30160        resumeable_stream: RS,
30161        mime_type: mime::Mime,
30162    ) -> common::Result<(common::Response, Upload)>
30163    where
30164        RS: common::ReadSeek,
30165    {
30166        self.doit(
30167            resumeable_stream,
30168            mime_type,
30169            common::UploadProtocol::Resumable,
30170        )
30171        .await
30172    }
30173    /// Upload media all at once.
30174    /// If the upload fails for whichever reason, all progress is lost.
30175    ///
30176    /// * *multipart*: yes
30177    /// * *max size*: 1GB
30178    /// * *valid mime types*: 'application/octet-stream'
30179    pub async fn upload<RS>(
30180        self,
30181        stream: RS,
30182        mime_type: mime::Mime,
30183    ) -> common::Result<(common::Response, Upload)>
30184    where
30185        RS: common::ReadSeek,
30186    {
30187        self.doit(stream, mime_type, common::UploadProtocol::Simple)
30188            .await
30189    }
30190
30191    /// Account Id associated with the upload.
30192    ///
30193    /// Sets the *account id* path property to the given value.
30194    ///
30195    /// Even though the property as already been set when instantiating this call,
30196    /// we provide this method for API completeness.
30197    pub fn account_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C> {
30198        self._account_id = new_value.to_string();
30199        self
30200    }
30201    /// Web property UA-string associated with the upload.
30202    ///
30203    /// Sets the *web property id* path property to the given value.
30204    ///
30205    /// Even though the property as already been set when instantiating this call,
30206    /// we provide this method for API completeness.
30207    pub fn web_property_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C> {
30208        self._web_property_id = new_value.to_string();
30209        self
30210    }
30211    /// Custom data source Id to which the data being uploaded belongs.
30212    ///
30213    /// Sets the *custom data source id* path property to the given value.
30214    ///
30215    /// Even though the property as already been set when instantiating this call,
30216    /// we provide this method for API completeness.
30217    pub fn custom_data_source_id(
30218        mut self,
30219        new_value: &str,
30220    ) -> ManagementUploadUploadDataCall<'a, C> {
30221        self._custom_data_source_id = new_value.to_string();
30222        self
30223    }
30224    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30225    /// while executing the actual API request.
30226    ///
30227    /// ````text
30228    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30229    /// ````
30230    ///
30231    /// Sets the *delegate* property to the given value.
30232    pub fn delegate(
30233        mut self,
30234        new_value: &'a mut dyn common::Delegate,
30235    ) -> ManagementUploadUploadDataCall<'a, C> {
30236        self._delegate = Some(new_value);
30237        self
30238    }
30239
30240    /// Set any additional parameter of the query string used in the request.
30241    /// It should be used to set parameters which are not yet available through their own
30242    /// setters.
30243    ///
30244    /// Please note that this method must not be used to set any of the known parameters
30245    /// which have their own setter method. If done anyway, the request will fail.
30246    ///
30247    /// # Additional Parameters
30248    ///
30249    /// * *alt* (query-string) - Data format for the response.
30250    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30251    /// * *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.
30252    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30253    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30254    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30255    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30256    pub fn param<T>(mut self, name: T, value: T) -> ManagementUploadUploadDataCall<'a, C>
30257    where
30258        T: AsRef<str>,
30259    {
30260        self._additional_params
30261            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30262        self
30263    }
30264
30265    /// Identifies the authorization scope for the method you are building.
30266    ///
30267    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30268    /// [`Scope::Full`].
30269    ///
30270    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30271    /// tokens for more than one scope.
30272    ///
30273    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30274    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30275    /// sufficient, a read-write scope will do as well.
30276    pub fn add_scope<St>(mut self, scope: St) -> ManagementUploadUploadDataCall<'a, C>
30277    where
30278        St: AsRef<str>,
30279    {
30280        self._scopes.insert(String::from(scope.as_ref()));
30281        self
30282    }
30283    /// Identifies the authorization scope(s) for the method you are building.
30284    ///
30285    /// See [`Self::add_scope()`] for details.
30286    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUploadUploadDataCall<'a, C>
30287    where
30288        I: IntoIterator<Item = St>,
30289        St: AsRef<str>,
30290    {
30291        self._scopes
30292            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30293        self
30294    }
30295
30296    /// Removes all scopes, and no default scope will be used either.
30297    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30298    /// for details).
30299    pub fn clear_scopes(mut self) -> ManagementUploadUploadDataCall<'a, C> {
30300        self._scopes.clear();
30301        self
30302    }
30303}
30304
30305/// Deletes a web property-Google Ads link.
30306///
30307/// A builder for the *webPropertyAdWordsLinks.delete* method supported by a *management* resource.
30308/// It is not used directly, but through a [`ManagementMethods`] instance.
30309///
30310/// # Example
30311///
30312/// Instantiate a resource method builder
30313///
30314/// ```test_harness,no_run
30315/// # extern crate hyper;
30316/// # extern crate hyper_rustls;
30317/// # extern crate google_analytics3 as analytics3;
30318/// # async fn dox() {
30319/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30320///
30321/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30322/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30323/// #     .with_native_roots()
30324/// #     .unwrap()
30325/// #     .https_only()
30326/// #     .enable_http2()
30327/// #     .build();
30328///
30329/// # let executor = hyper_util::rt::TokioExecutor::new();
30330/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30331/// #     secret,
30332/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30333/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
30334/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
30335/// #     ),
30336/// # ).build().await.unwrap();
30337///
30338/// # let client = hyper_util::client::legacy::Client::builder(
30339/// #     hyper_util::rt::TokioExecutor::new()
30340/// # )
30341/// # .build(
30342/// #     hyper_rustls::HttpsConnectorBuilder::new()
30343/// #         .with_native_roots()
30344/// #         .unwrap()
30345/// #         .https_or_http()
30346/// #         .enable_http2()
30347/// #         .build()
30348/// # );
30349/// # let mut hub = Analytics::new(client, auth);
30350/// // You can configure optional parameters by calling the respective setters at will, and
30351/// // execute the final call using `doit()`.
30352/// // Values shown here are possibly random and not representative !
30353/// let result = hub.management().web_property_ad_words_links_delete("accountId", "webPropertyId", "webPropertyAdWordsLinkId")
30354///              .doit().await;
30355/// # }
30356/// ```
30357pub struct ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
30358where
30359    C: 'a,
30360{
30361    hub: &'a Analytics<C>,
30362    _account_id: String,
30363    _web_property_id: String,
30364    _web_property_ad_words_link_id: String,
30365    _delegate: Option<&'a mut dyn common::Delegate>,
30366    _additional_params: HashMap<String, String>,
30367    _scopes: BTreeSet<String>,
30368}
30369
30370impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {}
30371
30372impl<'a, C> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
30373where
30374    C: common::Connector,
30375{
30376    /// Perform the operation you have build so far.
30377    pub async fn doit(mut self) -> common::Result<common::Response> {
30378        use std::borrow::Cow;
30379        use std::io::{Read, Seek};
30380
30381        use common::{url::Params, ToParts};
30382        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30383
30384        let mut dd = common::DefaultDelegate;
30385        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30386        dlg.begin(common::MethodInfo {
30387            id: "analytics.management.webPropertyAdWordsLinks.delete",
30388            http_method: hyper::Method::DELETE,
30389        });
30390
30391        for &field in ["accountId", "webPropertyId", "webPropertyAdWordsLinkId"].iter() {
30392            if self._additional_params.contains_key(field) {
30393                dlg.finished(false);
30394                return Err(common::Error::FieldClash(field));
30395            }
30396        }
30397
30398        let mut params = Params::with_capacity(4 + self._additional_params.len());
30399        params.push("accountId", self._account_id);
30400        params.push("webPropertyId", self._web_property_id);
30401        params.push(
30402            "webPropertyAdWordsLinkId",
30403            self._web_property_ad_words_link_id,
30404        );
30405
30406        params.extend(self._additional_params.iter());
30407
30408        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}";
30409        if self._scopes.is_empty() {
30410            self._scopes.insert(Scope::Edit.as_ref().to_string());
30411        }
30412
30413        #[allow(clippy::single_element_loop)]
30414        for &(find_this, param_name) in [
30415            ("{accountId}", "accountId"),
30416            ("{webPropertyId}", "webPropertyId"),
30417            ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId"),
30418        ]
30419        .iter()
30420        {
30421            url = params.uri_replacement(url, param_name, find_this, false);
30422        }
30423        {
30424            let to_remove = ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"];
30425            params.remove_params(&to_remove);
30426        }
30427
30428        let url = params.parse_with_url(&url);
30429
30430        loop {
30431            let token = match self
30432                .hub
30433                .auth
30434                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30435                .await
30436            {
30437                Ok(token) => token,
30438                Err(e) => match dlg.token(e) {
30439                    Ok(token) => token,
30440                    Err(e) => {
30441                        dlg.finished(false);
30442                        return Err(common::Error::MissingToken(e));
30443                    }
30444                },
30445            };
30446            let mut req_result = {
30447                let client = &self.hub.client;
30448                dlg.pre_request();
30449                let mut req_builder = hyper::Request::builder()
30450                    .method(hyper::Method::DELETE)
30451                    .uri(url.as_str())
30452                    .header(USER_AGENT, self.hub._user_agent.clone());
30453
30454                if let Some(token) = token.as_ref() {
30455                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30456                }
30457
30458                let request = req_builder
30459                    .header(CONTENT_LENGTH, 0_u64)
30460                    .body(common::to_body::<String>(None));
30461
30462                client.request(request.unwrap()).await
30463            };
30464
30465            match req_result {
30466                Err(err) => {
30467                    if let common::Retry::After(d) = dlg.http_error(&err) {
30468                        sleep(d).await;
30469                        continue;
30470                    }
30471                    dlg.finished(false);
30472                    return Err(common::Error::HttpError(err));
30473                }
30474                Ok(res) => {
30475                    let (mut parts, body) = res.into_parts();
30476                    let mut body = common::Body::new(body);
30477                    if !parts.status.is_success() {
30478                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30479                        let error = serde_json::from_str(&common::to_string(&bytes));
30480                        let response = common::to_response(parts, bytes.into());
30481
30482                        if let common::Retry::After(d) =
30483                            dlg.http_failure(&response, error.as_ref().ok())
30484                        {
30485                            sleep(d).await;
30486                            continue;
30487                        }
30488
30489                        dlg.finished(false);
30490
30491                        return Err(match error {
30492                            Ok(value) => common::Error::BadRequest(value),
30493                            _ => common::Error::Failure(response),
30494                        });
30495                    }
30496                    let response = common::Response::from_parts(parts, body);
30497
30498                    dlg.finished(true);
30499                    return Ok(response);
30500                }
30501            }
30502        }
30503    }
30504
30505    /// ID of the account which the given web property belongs to.
30506    ///
30507    /// Sets the *account id* path property to the given value.
30508    ///
30509    /// Even though the property as already been set when instantiating this call,
30510    /// we provide this method for API completeness.
30511    pub fn account_id(
30512        mut self,
30513        new_value: &str,
30514    ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
30515        self._account_id = new_value.to_string();
30516        self
30517    }
30518    /// Web property ID to delete the Google Ads link for.
30519    ///
30520    /// Sets the *web property id* path property to the given value.
30521    ///
30522    /// Even though the property as already been set when instantiating this call,
30523    /// we provide this method for API completeness.
30524    pub fn web_property_id(
30525        mut self,
30526        new_value: &str,
30527    ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
30528        self._web_property_id = new_value.to_string();
30529        self
30530    }
30531    /// Web property Google Ads link ID.
30532    ///
30533    /// Sets the *web property ad words link id* path property to the given value.
30534    ///
30535    /// Even though the property as already been set when instantiating this call,
30536    /// we provide this method for API completeness.
30537    pub fn web_property_ad_words_link_id(
30538        mut self,
30539        new_value: &str,
30540    ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
30541        self._web_property_ad_words_link_id = new_value.to_string();
30542        self
30543    }
30544    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30545    /// while executing the actual API request.
30546    ///
30547    /// ````text
30548    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30549    /// ````
30550    ///
30551    /// Sets the *delegate* property to the given value.
30552    pub fn delegate(
30553        mut self,
30554        new_value: &'a mut dyn common::Delegate,
30555    ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
30556        self._delegate = Some(new_value);
30557        self
30558    }
30559
30560    /// Set any additional parameter of the query string used in the request.
30561    /// It should be used to set parameters which are not yet available through their own
30562    /// setters.
30563    ///
30564    /// Please note that this method must not be used to set any of the known parameters
30565    /// which have their own setter method. If done anyway, the request will fail.
30566    ///
30567    /// # Additional Parameters
30568    ///
30569    /// * *alt* (query-string) - Data format for the response.
30570    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30571    /// * *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.
30572    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30573    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30574    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30575    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30576    pub fn param<T>(
30577        mut self,
30578        name: T,
30579        value: T,
30580    ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
30581    where
30582        T: AsRef<str>,
30583    {
30584        self._additional_params
30585            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30586        self
30587    }
30588
30589    /// Identifies the authorization scope for the method you are building.
30590    ///
30591    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30592    /// [`Scope::Edit`].
30593    ///
30594    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30595    /// tokens for more than one scope.
30596    ///
30597    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30598    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30599    /// sufficient, a read-write scope will do as well.
30600    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
30601    where
30602        St: AsRef<str>,
30603    {
30604        self._scopes.insert(String::from(scope.as_ref()));
30605        self
30606    }
30607    /// Identifies the authorization scope(s) for the method you are building.
30608    ///
30609    /// See [`Self::add_scope()`] for details.
30610    pub fn add_scopes<I, St>(
30611        mut self,
30612        scopes: I,
30613    ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
30614    where
30615        I: IntoIterator<Item = St>,
30616        St: AsRef<str>,
30617    {
30618        self._scopes
30619            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30620        self
30621    }
30622
30623    /// Removes all scopes, and no default scope will be used either.
30624    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30625    /// for details).
30626    pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
30627        self._scopes.clear();
30628        self
30629    }
30630}
30631
30632/// Returns a web property-Google Ads link to which the user has access.
30633///
30634/// A builder for the *webPropertyAdWordsLinks.get* method supported by a *management* resource.
30635/// It is not used directly, but through a [`ManagementMethods`] instance.
30636///
30637/// # Example
30638///
30639/// Instantiate a resource method builder
30640///
30641/// ```test_harness,no_run
30642/// # extern crate hyper;
30643/// # extern crate hyper_rustls;
30644/// # extern crate google_analytics3 as analytics3;
30645/// # async fn dox() {
30646/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30647///
30648/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30649/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30650/// #     .with_native_roots()
30651/// #     .unwrap()
30652/// #     .https_only()
30653/// #     .enable_http2()
30654/// #     .build();
30655///
30656/// # let executor = hyper_util::rt::TokioExecutor::new();
30657/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30658/// #     secret,
30659/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30660/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
30661/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
30662/// #     ),
30663/// # ).build().await.unwrap();
30664///
30665/// # let client = hyper_util::client::legacy::Client::builder(
30666/// #     hyper_util::rt::TokioExecutor::new()
30667/// # )
30668/// # .build(
30669/// #     hyper_rustls::HttpsConnectorBuilder::new()
30670/// #         .with_native_roots()
30671/// #         .unwrap()
30672/// #         .https_or_http()
30673/// #         .enable_http2()
30674/// #         .build()
30675/// # );
30676/// # let mut hub = Analytics::new(client, auth);
30677/// // You can configure optional parameters by calling the respective setters at will, and
30678/// // execute the final call using `doit()`.
30679/// // Values shown here are possibly random and not representative !
30680/// let result = hub.management().web_property_ad_words_links_get("accountId", "webPropertyId", "webPropertyAdWordsLinkId")
30681///              .doit().await;
30682/// # }
30683/// ```
30684pub struct ManagementWebPropertyAdWordsLinkGetCall<'a, C>
30685where
30686    C: 'a,
30687{
30688    hub: &'a Analytics<C>,
30689    _account_id: String,
30690    _web_property_id: String,
30691    _web_property_ad_words_link_id: String,
30692    _delegate: Option<&'a mut dyn common::Delegate>,
30693    _additional_params: HashMap<String, String>,
30694    _scopes: BTreeSet<String>,
30695}
30696
30697impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkGetCall<'a, C> {}
30698
30699impl<'a, C> ManagementWebPropertyAdWordsLinkGetCall<'a, C>
30700where
30701    C: common::Connector,
30702{
30703    /// Perform the operation you have build so far.
30704    pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLink)> {
30705        use std::borrow::Cow;
30706        use std::io::{Read, Seek};
30707
30708        use common::{url::Params, ToParts};
30709        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30710
30711        let mut dd = common::DefaultDelegate;
30712        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30713        dlg.begin(common::MethodInfo {
30714            id: "analytics.management.webPropertyAdWordsLinks.get",
30715            http_method: hyper::Method::GET,
30716        });
30717
30718        for &field in [
30719            "alt",
30720            "accountId",
30721            "webPropertyId",
30722            "webPropertyAdWordsLinkId",
30723        ]
30724        .iter()
30725        {
30726            if self._additional_params.contains_key(field) {
30727                dlg.finished(false);
30728                return Err(common::Error::FieldClash(field));
30729            }
30730        }
30731
30732        let mut params = Params::with_capacity(5 + self._additional_params.len());
30733        params.push("accountId", self._account_id);
30734        params.push("webPropertyId", self._web_property_id);
30735        params.push(
30736            "webPropertyAdWordsLinkId",
30737            self._web_property_ad_words_link_id,
30738        );
30739
30740        params.extend(self._additional_params.iter());
30741
30742        params.push("alt", "json");
30743        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}";
30744        if self._scopes.is_empty() {
30745            self._scopes.insert(Scope::Readonly.as_ref().to_string());
30746        }
30747
30748        #[allow(clippy::single_element_loop)]
30749        for &(find_this, param_name) in [
30750            ("{accountId}", "accountId"),
30751            ("{webPropertyId}", "webPropertyId"),
30752            ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId"),
30753        ]
30754        .iter()
30755        {
30756            url = params.uri_replacement(url, param_name, find_this, false);
30757        }
30758        {
30759            let to_remove = ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"];
30760            params.remove_params(&to_remove);
30761        }
30762
30763        let url = params.parse_with_url(&url);
30764
30765        loop {
30766            let token = match self
30767                .hub
30768                .auth
30769                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30770                .await
30771            {
30772                Ok(token) => token,
30773                Err(e) => match dlg.token(e) {
30774                    Ok(token) => token,
30775                    Err(e) => {
30776                        dlg.finished(false);
30777                        return Err(common::Error::MissingToken(e));
30778                    }
30779                },
30780            };
30781            let mut req_result = {
30782                let client = &self.hub.client;
30783                dlg.pre_request();
30784                let mut req_builder = hyper::Request::builder()
30785                    .method(hyper::Method::GET)
30786                    .uri(url.as_str())
30787                    .header(USER_AGENT, self.hub._user_agent.clone());
30788
30789                if let Some(token) = token.as_ref() {
30790                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30791                }
30792
30793                let request = req_builder
30794                    .header(CONTENT_LENGTH, 0_u64)
30795                    .body(common::to_body::<String>(None));
30796
30797                client.request(request.unwrap()).await
30798            };
30799
30800            match req_result {
30801                Err(err) => {
30802                    if let common::Retry::After(d) = dlg.http_error(&err) {
30803                        sleep(d).await;
30804                        continue;
30805                    }
30806                    dlg.finished(false);
30807                    return Err(common::Error::HttpError(err));
30808                }
30809                Ok(res) => {
30810                    let (mut parts, body) = res.into_parts();
30811                    let mut body = common::Body::new(body);
30812                    if !parts.status.is_success() {
30813                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30814                        let error = serde_json::from_str(&common::to_string(&bytes));
30815                        let response = common::to_response(parts, bytes.into());
30816
30817                        if let common::Retry::After(d) =
30818                            dlg.http_failure(&response, error.as_ref().ok())
30819                        {
30820                            sleep(d).await;
30821                            continue;
30822                        }
30823
30824                        dlg.finished(false);
30825
30826                        return Err(match error {
30827                            Ok(value) => common::Error::BadRequest(value),
30828                            _ => common::Error::Failure(response),
30829                        });
30830                    }
30831                    let response = {
30832                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30833                        let encoded = common::to_string(&bytes);
30834                        match serde_json::from_str(&encoded) {
30835                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30836                            Err(error) => {
30837                                dlg.response_json_decode_error(&encoded, &error);
30838                                return Err(common::Error::JsonDecodeError(
30839                                    encoded.to_string(),
30840                                    error,
30841                                ));
30842                            }
30843                        }
30844                    };
30845
30846                    dlg.finished(true);
30847                    return Ok(response);
30848                }
30849            }
30850        }
30851    }
30852
30853    /// ID of the account which the given web property belongs to.
30854    ///
30855    /// Sets the *account id* path property to the given value.
30856    ///
30857    /// Even though the property as already been set when instantiating this call,
30858    /// we provide this method for API completeness.
30859    pub fn account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30860        self._account_id = new_value.to_string();
30861        self
30862    }
30863    /// Web property ID to retrieve the Google Ads link for.
30864    ///
30865    /// Sets the *web property id* path property to the given value.
30866    ///
30867    /// Even though the property as already been set when instantiating this call,
30868    /// we provide this method for API completeness.
30869    pub fn web_property_id(
30870        mut self,
30871        new_value: &str,
30872    ) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30873        self._web_property_id = new_value.to_string();
30874        self
30875    }
30876    /// Web property-Google Ads link ID.
30877    ///
30878    /// Sets the *web property ad words link id* path property to the given value.
30879    ///
30880    /// Even though the property as already been set when instantiating this call,
30881    /// we provide this method for API completeness.
30882    pub fn web_property_ad_words_link_id(
30883        mut self,
30884        new_value: &str,
30885    ) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30886        self._web_property_ad_words_link_id = new_value.to_string();
30887        self
30888    }
30889    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30890    /// while executing the actual API request.
30891    ///
30892    /// ````text
30893    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30894    /// ````
30895    ///
30896    /// Sets the *delegate* property to the given value.
30897    pub fn delegate(
30898        mut self,
30899        new_value: &'a mut dyn common::Delegate,
30900    ) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30901        self._delegate = Some(new_value);
30902        self
30903    }
30904
30905    /// Set any additional parameter of the query string used in the request.
30906    /// It should be used to set parameters which are not yet available through their own
30907    /// setters.
30908    ///
30909    /// Please note that this method must not be used to set any of the known parameters
30910    /// which have their own setter method. If done anyway, the request will fail.
30911    ///
30912    /// # Additional Parameters
30913    ///
30914    /// * *alt* (query-string) - Data format for the response.
30915    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30916    /// * *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.
30917    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30918    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30919    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30920    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30921    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C>
30922    where
30923        T: AsRef<str>,
30924    {
30925        self._additional_params
30926            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30927        self
30928    }
30929
30930    /// Identifies the authorization scope for the method you are building.
30931    ///
30932    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30933    /// [`Scope::Readonly`].
30934    ///
30935    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30936    /// tokens for more than one scope.
30937    ///
30938    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30939    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30940    /// sufficient, a read-write scope will do as well.
30941    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C>
30942    where
30943        St: AsRef<str>,
30944    {
30945        self._scopes.insert(String::from(scope.as_ref()));
30946        self
30947    }
30948    /// Identifies the authorization scope(s) for the method you are building.
30949    ///
30950    /// See [`Self::add_scope()`] for details.
30951    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C>
30952    where
30953        I: IntoIterator<Item = St>,
30954        St: AsRef<str>,
30955    {
30956        self._scopes
30957            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30958        self
30959    }
30960
30961    /// Removes all scopes, and no default scope will be used either.
30962    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30963    /// for details).
30964    pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30965        self._scopes.clear();
30966        self
30967    }
30968}
30969
30970/// Creates a webProperty-Google Ads link.
30971///
30972/// A builder for the *webPropertyAdWordsLinks.insert* method supported by a *management* resource.
30973/// It is not used directly, but through a [`ManagementMethods`] instance.
30974///
30975/// # Example
30976///
30977/// Instantiate a resource method builder
30978///
30979/// ```test_harness,no_run
30980/// # extern crate hyper;
30981/// # extern crate hyper_rustls;
30982/// # extern crate google_analytics3 as analytics3;
30983/// use analytics3::api::EntityAdWordsLink;
30984/// # async fn dox() {
30985/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30986///
30987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30988/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30989/// #     .with_native_roots()
30990/// #     .unwrap()
30991/// #     .https_only()
30992/// #     .enable_http2()
30993/// #     .build();
30994///
30995/// # let executor = hyper_util::rt::TokioExecutor::new();
30996/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30997/// #     secret,
30998/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30999/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
31000/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
31001/// #     ),
31002/// # ).build().await.unwrap();
31003///
31004/// # let client = hyper_util::client::legacy::Client::builder(
31005/// #     hyper_util::rt::TokioExecutor::new()
31006/// # )
31007/// # .build(
31008/// #     hyper_rustls::HttpsConnectorBuilder::new()
31009/// #         .with_native_roots()
31010/// #         .unwrap()
31011/// #         .https_or_http()
31012/// #         .enable_http2()
31013/// #         .build()
31014/// # );
31015/// # let mut hub = Analytics::new(client, auth);
31016/// // As the method needs a request, you would usually fill it with the desired information
31017/// // into the respective structure. Some of the parts shown here might not be applicable !
31018/// // Values shown here are possibly random and not representative !
31019/// let mut req = EntityAdWordsLink::default();
31020///
31021/// // You can configure optional parameters by calling the respective setters at will, and
31022/// // execute the final call using `doit()`.
31023/// // Values shown here are possibly random and not representative !
31024/// let result = hub.management().web_property_ad_words_links_insert(req, "accountId", "webPropertyId")
31025///              .doit().await;
31026/// # }
31027/// ```
31028pub struct ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
31029where
31030    C: 'a,
31031{
31032    hub: &'a Analytics<C>,
31033    _request: EntityAdWordsLink,
31034    _account_id: String,
31035    _web_property_id: String,
31036    _delegate: Option<&'a mut dyn common::Delegate>,
31037    _additional_params: HashMap<String, String>,
31038    _scopes: BTreeSet<String>,
31039}
31040
31041impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {}
31042
31043impl<'a, C> ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
31044where
31045    C: common::Connector,
31046{
31047    /// Perform the operation you have build so far.
31048    pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLink)> {
31049        use std::borrow::Cow;
31050        use std::io::{Read, Seek};
31051
31052        use common::{url::Params, ToParts};
31053        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31054
31055        let mut dd = common::DefaultDelegate;
31056        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31057        dlg.begin(common::MethodInfo {
31058            id: "analytics.management.webPropertyAdWordsLinks.insert",
31059            http_method: hyper::Method::POST,
31060        });
31061
31062        for &field in ["alt", "accountId", "webPropertyId"].iter() {
31063            if self._additional_params.contains_key(field) {
31064                dlg.finished(false);
31065                return Err(common::Error::FieldClash(field));
31066            }
31067        }
31068
31069        let mut params = Params::with_capacity(5 + self._additional_params.len());
31070        params.push("accountId", self._account_id);
31071        params.push("webPropertyId", self._web_property_id);
31072
31073        params.extend(self._additional_params.iter());
31074
31075        params.push("alt", "json");
31076        let mut url = self.hub._base_url.clone()
31077            + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks";
31078        if self._scopes.is_empty() {
31079            self._scopes.insert(Scope::Edit.as_ref().to_string());
31080        }
31081
31082        #[allow(clippy::single_element_loop)]
31083        for &(find_this, param_name) in [
31084            ("{accountId}", "accountId"),
31085            ("{webPropertyId}", "webPropertyId"),
31086        ]
31087        .iter()
31088        {
31089            url = params.uri_replacement(url, param_name, find_this, false);
31090        }
31091        {
31092            let to_remove = ["webPropertyId", "accountId"];
31093            params.remove_params(&to_remove);
31094        }
31095
31096        let url = params.parse_with_url(&url);
31097
31098        let mut json_mime_type = mime::APPLICATION_JSON;
31099        let mut request_value_reader = {
31100            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31101            common::remove_json_null_values(&mut value);
31102            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31103            serde_json::to_writer(&mut dst, &value).unwrap();
31104            dst
31105        };
31106        let request_size = request_value_reader
31107            .seek(std::io::SeekFrom::End(0))
31108            .unwrap();
31109        request_value_reader
31110            .seek(std::io::SeekFrom::Start(0))
31111            .unwrap();
31112
31113        loop {
31114            let token = match self
31115                .hub
31116                .auth
31117                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31118                .await
31119            {
31120                Ok(token) => token,
31121                Err(e) => match dlg.token(e) {
31122                    Ok(token) => token,
31123                    Err(e) => {
31124                        dlg.finished(false);
31125                        return Err(common::Error::MissingToken(e));
31126                    }
31127                },
31128            };
31129            request_value_reader
31130                .seek(std::io::SeekFrom::Start(0))
31131                .unwrap();
31132            let mut req_result = {
31133                let client = &self.hub.client;
31134                dlg.pre_request();
31135                let mut req_builder = hyper::Request::builder()
31136                    .method(hyper::Method::POST)
31137                    .uri(url.as_str())
31138                    .header(USER_AGENT, self.hub._user_agent.clone());
31139
31140                if let Some(token) = token.as_ref() {
31141                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31142                }
31143
31144                let request = req_builder
31145                    .header(CONTENT_TYPE, json_mime_type.to_string())
31146                    .header(CONTENT_LENGTH, request_size as u64)
31147                    .body(common::to_body(
31148                        request_value_reader.get_ref().clone().into(),
31149                    ));
31150
31151                client.request(request.unwrap()).await
31152            };
31153
31154            match req_result {
31155                Err(err) => {
31156                    if let common::Retry::After(d) = dlg.http_error(&err) {
31157                        sleep(d).await;
31158                        continue;
31159                    }
31160                    dlg.finished(false);
31161                    return Err(common::Error::HttpError(err));
31162                }
31163                Ok(res) => {
31164                    let (mut parts, body) = res.into_parts();
31165                    let mut body = common::Body::new(body);
31166                    if !parts.status.is_success() {
31167                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31168                        let error = serde_json::from_str(&common::to_string(&bytes));
31169                        let response = common::to_response(parts, bytes.into());
31170
31171                        if let common::Retry::After(d) =
31172                            dlg.http_failure(&response, error.as_ref().ok())
31173                        {
31174                            sleep(d).await;
31175                            continue;
31176                        }
31177
31178                        dlg.finished(false);
31179
31180                        return Err(match error {
31181                            Ok(value) => common::Error::BadRequest(value),
31182                            _ => common::Error::Failure(response),
31183                        });
31184                    }
31185                    let response = {
31186                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31187                        let encoded = common::to_string(&bytes);
31188                        match serde_json::from_str(&encoded) {
31189                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31190                            Err(error) => {
31191                                dlg.response_json_decode_error(&encoded, &error);
31192                                return Err(common::Error::JsonDecodeError(
31193                                    encoded.to_string(),
31194                                    error,
31195                                ));
31196                            }
31197                        }
31198                    };
31199
31200                    dlg.finished(true);
31201                    return Ok(response);
31202                }
31203            }
31204        }
31205    }
31206
31207    ///
31208    /// Sets the *request* property to the given value.
31209    ///
31210    /// Even though the property as already been set when instantiating this call,
31211    /// we provide this method for API completeness.
31212    pub fn request(
31213        mut self,
31214        new_value: EntityAdWordsLink,
31215    ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
31216        self._request = new_value;
31217        self
31218    }
31219    /// ID of the Google Analytics account to create the link for.
31220    ///
31221    /// Sets the *account id* path property to the given value.
31222    ///
31223    /// Even though the property as already been set when instantiating this call,
31224    /// we provide this method for API completeness.
31225    pub fn account_id(
31226        mut self,
31227        new_value: &str,
31228    ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
31229        self._account_id = new_value.to_string();
31230        self
31231    }
31232    /// Web property ID to create the link for.
31233    ///
31234    /// Sets the *web property id* path property to the given value.
31235    ///
31236    /// Even though the property as already been set when instantiating this call,
31237    /// we provide this method for API completeness.
31238    pub fn web_property_id(
31239        mut self,
31240        new_value: &str,
31241    ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
31242        self._web_property_id = new_value.to_string();
31243        self
31244    }
31245    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31246    /// while executing the actual API request.
31247    ///
31248    /// ````text
31249    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31250    /// ````
31251    ///
31252    /// Sets the *delegate* property to the given value.
31253    pub fn delegate(
31254        mut self,
31255        new_value: &'a mut dyn common::Delegate,
31256    ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
31257        self._delegate = Some(new_value);
31258        self
31259    }
31260
31261    /// Set any additional parameter of the query string used in the request.
31262    /// It should be used to set parameters which are not yet available through their own
31263    /// setters.
31264    ///
31265    /// Please note that this method must not be used to set any of the known parameters
31266    /// which have their own setter method. If done anyway, the request will fail.
31267    ///
31268    /// # Additional Parameters
31269    ///
31270    /// * *alt* (query-string) - Data format for the response.
31271    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31272    /// * *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.
31273    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31274    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31275    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31276    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31277    pub fn param<T>(
31278        mut self,
31279        name: T,
31280        value: T,
31281    ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
31282    where
31283        T: AsRef<str>,
31284    {
31285        self._additional_params
31286            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31287        self
31288    }
31289
31290    /// Identifies the authorization scope for the method you are building.
31291    ///
31292    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31293    /// [`Scope::Edit`].
31294    ///
31295    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31296    /// tokens for more than one scope.
31297    ///
31298    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31299    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31300    /// sufficient, a read-write scope will do as well.
31301    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
31302    where
31303        St: AsRef<str>,
31304    {
31305        self._scopes.insert(String::from(scope.as_ref()));
31306        self
31307    }
31308    /// Identifies the authorization scope(s) for the method you are building.
31309    ///
31310    /// See [`Self::add_scope()`] for details.
31311    pub fn add_scopes<I, St>(
31312        mut self,
31313        scopes: I,
31314    ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
31315    where
31316        I: IntoIterator<Item = St>,
31317        St: AsRef<str>,
31318    {
31319        self._scopes
31320            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31321        self
31322    }
31323
31324    /// Removes all scopes, and no default scope will be used either.
31325    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31326    /// for details).
31327    pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
31328        self._scopes.clear();
31329        self
31330    }
31331}
31332
31333/// Lists webProperty-Google Ads links for a given web property.
31334///
31335/// A builder for the *webPropertyAdWordsLinks.list* method supported by a *management* resource.
31336/// It is not used directly, but through a [`ManagementMethods`] instance.
31337///
31338/// # Example
31339///
31340/// Instantiate a resource method builder
31341///
31342/// ```test_harness,no_run
31343/// # extern crate hyper;
31344/// # extern crate hyper_rustls;
31345/// # extern crate google_analytics3 as analytics3;
31346/// # async fn dox() {
31347/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31348///
31349/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31350/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31351/// #     .with_native_roots()
31352/// #     .unwrap()
31353/// #     .https_only()
31354/// #     .enable_http2()
31355/// #     .build();
31356///
31357/// # let executor = hyper_util::rt::TokioExecutor::new();
31358/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31359/// #     secret,
31360/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31361/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
31362/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
31363/// #     ),
31364/// # ).build().await.unwrap();
31365///
31366/// # let client = hyper_util::client::legacy::Client::builder(
31367/// #     hyper_util::rt::TokioExecutor::new()
31368/// # )
31369/// # .build(
31370/// #     hyper_rustls::HttpsConnectorBuilder::new()
31371/// #         .with_native_roots()
31372/// #         .unwrap()
31373/// #         .https_or_http()
31374/// #         .enable_http2()
31375/// #         .build()
31376/// # );
31377/// # let mut hub = Analytics::new(client, auth);
31378/// // You can configure optional parameters by calling the respective setters at will, and
31379/// // execute the final call using `doit()`.
31380/// // Values shown here are possibly random and not representative !
31381/// let result = hub.management().web_property_ad_words_links_list("accountId", "webPropertyId")
31382///              .start_index(-81)
31383///              .max_results(-71)
31384///              .doit().await;
31385/// # }
31386/// ```
31387pub struct ManagementWebPropertyAdWordsLinkListCall<'a, C>
31388where
31389    C: 'a,
31390{
31391    hub: &'a Analytics<C>,
31392    _account_id: String,
31393    _web_property_id: String,
31394    _start_index: Option<i32>,
31395    _max_results: Option<i32>,
31396    _delegate: Option<&'a mut dyn common::Delegate>,
31397    _additional_params: HashMap<String, String>,
31398    _scopes: BTreeSet<String>,
31399}
31400
31401impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkListCall<'a, C> {}
31402
31403impl<'a, C> ManagementWebPropertyAdWordsLinkListCall<'a, C>
31404where
31405    C: common::Connector,
31406{
31407    /// Perform the operation you have build so far.
31408    pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLinks)> {
31409        use std::borrow::Cow;
31410        use std::io::{Read, Seek};
31411
31412        use common::{url::Params, ToParts};
31413        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31414
31415        let mut dd = common::DefaultDelegate;
31416        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31417        dlg.begin(common::MethodInfo {
31418            id: "analytics.management.webPropertyAdWordsLinks.list",
31419            http_method: hyper::Method::GET,
31420        });
31421
31422        for &field in [
31423            "alt",
31424            "accountId",
31425            "webPropertyId",
31426            "start-index",
31427            "max-results",
31428        ]
31429        .iter()
31430        {
31431            if self._additional_params.contains_key(field) {
31432                dlg.finished(false);
31433                return Err(common::Error::FieldClash(field));
31434            }
31435        }
31436
31437        let mut params = Params::with_capacity(6 + self._additional_params.len());
31438        params.push("accountId", self._account_id);
31439        params.push("webPropertyId", self._web_property_id);
31440        if let Some(value) = self._start_index.as_ref() {
31441            params.push("start-index", value.to_string());
31442        }
31443        if let Some(value) = self._max_results.as_ref() {
31444            params.push("max-results", value.to_string());
31445        }
31446
31447        params.extend(self._additional_params.iter());
31448
31449        params.push("alt", "json");
31450        let mut url = self.hub._base_url.clone()
31451            + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks";
31452        if self._scopes.is_empty() {
31453            self._scopes.insert(Scope::Readonly.as_ref().to_string());
31454        }
31455
31456        #[allow(clippy::single_element_loop)]
31457        for &(find_this, param_name) in [
31458            ("{accountId}", "accountId"),
31459            ("{webPropertyId}", "webPropertyId"),
31460        ]
31461        .iter()
31462        {
31463            url = params.uri_replacement(url, param_name, find_this, false);
31464        }
31465        {
31466            let to_remove = ["webPropertyId", "accountId"];
31467            params.remove_params(&to_remove);
31468        }
31469
31470        let url = params.parse_with_url(&url);
31471
31472        loop {
31473            let token = match self
31474                .hub
31475                .auth
31476                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31477                .await
31478            {
31479                Ok(token) => token,
31480                Err(e) => match dlg.token(e) {
31481                    Ok(token) => token,
31482                    Err(e) => {
31483                        dlg.finished(false);
31484                        return Err(common::Error::MissingToken(e));
31485                    }
31486                },
31487            };
31488            let mut req_result = {
31489                let client = &self.hub.client;
31490                dlg.pre_request();
31491                let mut req_builder = hyper::Request::builder()
31492                    .method(hyper::Method::GET)
31493                    .uri(url.as_str())
31494                    .header(USER_AGENT, self.hub._user_agent.clone());
31495
31496                if let Some(token) = token.as_ref() {
31497                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31498                }
31499
31500                let request = req_builder
31501                    .header(CONTENT_LENGTH, 0_u64)
31502                    .body(common::to_body::<String>(None));
31503
31504                client.request(request.unwrap()).await
31505            };
31506
31507            match req_result {
31508                Err(err) => {
31509                    if let common::Retry::After(d) = dlg.http_error(&err) {
31510                        sleep(d).await;
31511                        continue;
31512                    }
31513                    dlg.finished(false);
31514                    return Err(common::Error::HttpError(err));
31515                }
31516                Ok(res) => {
31517                    let (mut parts, body) = res.into_parts();
31518                    let mut body = common::Body::new(body);
31519                    if !parts.status.is_success() {
31520                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31521                        let error = serde_json::from_str(&common::to_string(&bytes));
31522                        let response = common::to_response(parts, bytes.into());
31523
31524                        if let common::Retry::After(d) =
31525                            dlg.http_failure(&response, error.as_ref().ok())
31526                        {
31527                            sleep(d).await;
31528                            continue;
31529                        }
31530
31531                        dlg.finished(false);
31532
31533                        return Err(match error {
31534                            Ok(value) => common::Error::BadRequest(value),
31535                            _ => common::Error::Failure(response),
31536                        });
31537                    }
31538                    let response = {
31539                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31540                        let encoded = common::to_string(&bytes);
31541                        match serde_json::from_str(&encoded) {
31542                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31543                            Err(error) => {
31544                                dlg.response_json_decode_error(&encoded, &error);
31545                                return Err(common::Error::JsonDecodeError(
31546                                    encoded.to_string(),
31547                                    error,
31548                                ));
31549                            }
31550                        }
31551                    };
31552
31553                    dlg.finished(true);
31554                    return Ok(response);
31555                }
31556            }
31557        }
31558    }
31559
31560    /// ID of the account which the given web property belongs to.
31561    ///
31562    /// Sets the *account id* path property to the given value.
31563    ///
31564    /// Even though the property as already been set when instantiating this call,
31565    /// we provide this method for API completeness.
31566    pub fn account_id(
31567        mut self,
31568        new_value: &str,
31569    ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
31570        self._account_id = new_value.to_string();
31571        self
31572    }
31573    /// Web property ID to retrieve the Google Ads links for.
31574    ///
31575    /// Sets the *web property id* path property to the given value.
31576    ///
31577    /// Even though the property as already been set when instantiating this call,
31578    /// we provide this method for API completeness.
31579    pub fn web_property_id(
31580        mut self,
31581        new_value: &str,
31582    ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
31583        self._web_property_id = new_value.to_string();
31584        self
31585    }
31586    /// An index of the first webProperty-Google Ads link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
31587    ///
31588    /// Sets the *start-index* query property to the given value.
31589    pub fn start_index(
31590        mut self,
31591        new_value: i32,
31592    ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
31593        self._start_index = Some(new_value);
31594        self
31595    }
31596    /// The maximum number of webProperty-Google Ads links to include in this response.
31597    ///
31598    /// Sets the *max-results* query property to the given value.
31599    pub fn max_results(
31600        mut self,
31601        new_value: i32,
31602    ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
31603        self._max_results = Some(new_value);
31604        self
31605    }
31606    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31607    /// while executing the actual API request.
31608    ///
31609    /// ````text
31610    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31611    /// ````
31612    ///
31613    /// Sets the *delegate* property to the given value.
31614    pub fn delegate(
31615        mut self,
31616        new_value: &'a mut dyn common::Delegate,
31617    ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
31618        self._delegate = Some(new_value);
31619        self
31620    }
31621
31622    /// Set any additional parameter of the query string used in the request.
31623    /// It should be used to set parameters which are not yet available through their own
31624    /// setters.
31625    ///
31626    /// Please note that this method must not be used to set any of the known parameters
31627    /// which have their own setter method. If done anyway, the request will fail.
31628    ///
31629    /// # Additional Parameters
31630    ///
31631    /// * *alt* (query-string) - Data format for the response.
31632    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31633    /// * *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.
31634    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31635    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31636    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31637    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31638    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkListCall<'a, C>
31639    where
31640        T: AsRef<str>,
31641    {
31642        self._additional_params
31643            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31644        self
31645    }
31646
31647    /// Identifies the authorization scope for the method you are building.
31648    ///
31649    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31650    /// [`Scope::Readonly`].
31651    ///
31652    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31653    /// tokens for more than one scope.
31654    ///
31655    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31656    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31657    /// sufficient, a read-write scope will do as well.
31658    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkListCall<'a, C>
31659    where
31660        St: AsRef<str>,
31661    {
31662        self._scopes.insert(String::from(scope.as_ref()));
31663        self
31664    }
31665    /// Identifies the authorization scope(s) for the method you are building.
31666    ///
31667    /// See [`Self::add_scope()`] for details.
31668    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebPropertyAdWordsLinkListCall<'a, C>
31669    where
31670        I: IntoIterator<Item = St>,
31671        St: AsRef<str>,
31672    {
31673        self._scopes
31674            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31675        self
31676    }
31677
31678    /// Removes all scopes, and no default scope will be used either.
31679    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31680    /// for details).
31681    pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
31682        self._scopes.clear();
31683        self
31684    }
31685}
31686
31687/// Updates an existing webProperty-Google Ads link. This method supports patch semantics.
31688///
31689/// A builder for the *webPropertyAdWordsLinks.patch* method supported by a *management* resource.
31690/// It is not used directly, but through a [`ManagementMethods`] instance.
31691///
31692/// # Example
31693///
31694/// Instantiate a resource method builder
31695///
31696/// ```test_harness,no_run
31697/// # extern crate hyper;
31698/// # extern crate hyper_rustls;
31699/// # extern crate google_analytics3 as analytics3;
31700/// use analytics3::api::EntityAdWordsLink;
31701/// # async fn dox() {
31702/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31703///
31704/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31705/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31706/// #     .with_native_roots()
31707/// #     .unwrap()
31708/// #     .https_only()
31709/// #     .enable_http2()
31710/// #     .build();
31711///
31712/// # let executor = hyper_util::rt::TokioExecutor::new();
31713/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31714/// #     secret,
31715/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31716/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
31717/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
31718/// #     ),
31719/// # ).build().await.unwrap();
31720///
31721/// # let client = hyper_util::client::legacy::Client::builder(
31722/// #     hyper_util::rt::TokioExecutor::new()
31723/// # )
31724/// # .build(
31725/// #     hyper_rustls::HttpsConnectorBuilder::new()
31726/// #         .with_native_roots()
31727/// #         .unwrap()
31728/// #         .https_or_http()
31729/// #         .enable_http2()
31730/// #         .build()
31731/// # );
31732/// # let mut hub = Analytics::new(client, auth);
31733/// // As the method needs a request, you would usually fill it with the desired information
31734/// // into the respective structure. Some of the parts shown here might not be applicable !
31735/// // Values shown here are possibly random and not representative !
31736/// let mut req = EntityAdWordsLink::default();
31737///
31738/// // You can configure optional parameters by calling the respective setters at will, and
31739/// // execute the final call using `doit()`.
31740/// // Values shown here are possibly random and not representative !
31741/// let result = hub.management().web_property_ad_words_links_patch(req, "accountId", "webPropertyId", "webPropertyAdWordsLinkId")
31742///              .doit().await;
31743/// # }
31744/// ```
31745pub struct ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
31746where
31747    C: 'a,
31748{
31749    hub: &'a Analytics<C>,
31750    _request: EntityAdWordsLink,
31751    _account_id: String,
31752    _web_property_id: String,
31753    _web_property_ad_words_link_id: String,
31754    _delegate: Option<&'a mut dyn common::Delegate>,
31755    _additional_params: HashMap<String, String>,
31756    _scopes: BTreeSet<String>,
31757}
31758
31759impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {}
31760
31761impl<'a, C> ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
31762where
31763    C: common::Connector,
31764{
31765    /// Perform the operation you have build so far.
31766    pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLink)> {
31767        use std::borrow::Cow;
31768        use std::io::{Read, Seek};
31769
31770        use common::{url::Params, ToParts};
31771        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31772
31773        let mut dd = common::DefaultDelegate;
31774        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31775        dlg.begin(common::MethodInfo {
31776            id: "analytics.management.webPropertyAdWordsLinks.patch",
31777            http_method: hyper::Method::PATCH,
31778        });
31779
31780        for &field in [
31781            "alt",
31782            "accountId",
31783            "webPropertyId",
31784            "webPropertyAdWordsLinkId",
31785        ]
31786        .iter()
31787        {
31788            if self._additional_params.contains_key(field) {
31789                dlg.finished(false);
31790                return Err(common::Error::FieldClash(field));
31791            }
31792        }
31793
31794        let mut params = Params::with_capacity(6 + self._additional_params.len());
31795        params.push("accountId", self._account_id);
31796        params.push("webPropertyId", self._web_property_id);
31797        params.push(
31798            "webPropertyAdWordsLinkId",
31799            self._web_property_ad_words_link_id,
31800        );
31801
31802        params.extend(self._additional_params.iter());
31803
31804        params.push("alt", "json");
31805        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}";
31806        if self._scopes.is_empty() {
31807            self._scopes.insert(Scope::Edit.as_ref().to_string());
31808        }
31809
31810        #[allow(clippy::single_element_loop)]
31811        for &(find_this, param_name) in [
31812            ("{accountId}", "accountId"),
31813            ("{webPropertyId}", "webPropertyId"),
31814            ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId"),
31815        ]
31816        .iter()
31817        {
31818            url = params.uri_replacement(url, param_name, find_this, false);
31819        }
31820        {
31821            let to_remove = ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"];
31822            params.remove_params(&to_remove);
31823        }
31824
31825        let url = params.parse_with_url(&url);
31826
31827        let mut json_mime_type = mime::APPLICATION_JSON;
31828        let mut request_value_reader = {
31829            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31830            common::remove_json_null_values(&mut value);
31831            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31832            serde_json::to_writer(&mut dst, &value).unwrap();
31833            dst
31834        };
31835        let request_size = request_value_reader
31836            .seek(std::io::SeekFrom::End(0))
31837            .unwrap();
31838        request_value_reader
31839            .seek(std::io::SeekFrom::Start(0))
31840            .unwrap();
31841
31842        loop {
31843            let token = match self
31844                .hub
31845                .auth
31846                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31847                .await
31848            {
31849                Ok(token) => token,
31850                Err(e) => match dlg.token(e) {
31851                    Ok(token) => token,
31852                    Err(e) => {
31853                        dlg.finished(false);
31854                        return Err(common::Error::MissingToken(e));
31855                    }
31856                },
31857            };
31858            request_value_reader
31859                .seek(std::io::SeekFrom::Start(0))
31860                .unwrap();
31861            let mut req_result = {
31862                let client = &self.hub.client;
31863                dlg.pre_request();
31864                let mut req_builder = hyper::Request::builder()
31865                    .method(hyper::Method::PATCH)
31866                    .uri(url.as_str())
31867                    .header(USER_AGENT, self.hub._user_agent.clone());
31868
31869                if let Some(token) = token.as_ref() {
31870                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31871                }
31872
31873                let request = req_builder
31874                    .header(CONTENT_TYPE, json_mime_type.to_string())
31875                    .header(CONTENT_LENGTH, request_size as u64)
31876                    .body(common::to_body(
31877                        request_value_reader.get_ref().clone().into(),
31878                    ));
31879
31880                client.request(request.unwrap()).await
31881            };
31882
31883            match req_result {
31884                Err(err) => {
31885                    if let common::Retry::After(d) = dlg.http_error(&err) {
31886                        sleep(d).await;
31887                        continue;
31888                    }
31889                    dlg.finished(false);
31890                    return Err(common::Error::HttpError(err));
31891                }
31892                Ok(res) => {
31893                    let (mut parts, body) = res.into_parts();
31894                    let mut body = common::Body::new(body);
31895                    if !parts.status.is_success() {
31896                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31897                        let error = serde_json::from_str(&common::to_string(&bytes));
31898                        let response = common::to_response(parts, bytes.into());
31899
31900                        if let common::Retry::After(d) =
31901                            dlg.http_failure(&response, error.as_ref().ok())
31902                        {
31903                            sleep(d).await;
31904                            continue;
31905                        }
31906
31907                        dlg.finished(false);
31908
31909                        return Err(match error {
31910                            Ok(value) => common::Error::BadRequest(value),
31911                            _ => common::Error::Failure(response),
31912                        });
31913                    }
31914                    let response = {
31915                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31916                        let encoded = common::to_string(&bytes);
31917                        match serde_json::from_str(&encoded) {
31918                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31919                            Err(error) => {
31920                                dlg.response_json_decode_error(&encoded, &error);
31921                                return Err(common::Error::JsonDecodeError(
31922                                    encoded.to_string(),
31923                                    error,
31924                                ));
31925                            }
31926                        }
31927                    };
31928
31929                    dlg.finished(true);
31930                    return Ok(response);
31931                }
31932            }
31933        }
31934    }
31935
31936    ///
31937    /// Sets the *request* property to the given value.
31938    ///
31939    /// Even though the property as already been set when instantiating this call,
31940    /// we provide this method for API completeness.
31941    pub fn request(
31942        mut self,
31943        new_value: EntityAdWordsLink,
31944    ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31945        self._request = new_value;
31946        self
31947    }
31948    /// ID of the account which the given web property belongs to.
31949    ///
31950    /// Sets the *account id* path property to the given value.
31951    ///
31952    /// Even though the property as already been set when instantiating this call,
31953    /// we provide this method for API completeness.
31954    pub fn account_id(
31955        mut self,
31956        new_value: &str,
31957    ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31958        self._account_id = new_value.to_string();
31959        self
31960    }
31961    /// Web property ID to retrieve the Google Ads link for.
31962    ///
31963    /// Sets the *web property id* path property to the given value.
31964    ///
31965    /// Even though the property as already been set when instantiating this call,
31966    /// we provide this method for API completeness.
31967    pub fn web_property_id(
31968        mut self,
31969        new_value: &str,
31970    ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31971        self._web_property_id = new_value.to_string();
31972        self
31973    }
31974    /// Web property-Google Ads link ID.
31975    ///
31976    /// Sets the *web property ad words link id* path property to the given value.
31977    ///
31978    /// Even though the property as already been set when instantiating this call,
31979    /// we provide this method for API completeness.
31980    pub fn web_property_ad_words_link_id(
31981        mut self,
31982        new_value: &str,
31983    ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31984        self._web_property_ad_words_link_id = new_value.to_string();
31985        self
31986    }
31987    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31988    /// while executing the actual API request.
31989    ///
31990    /// ````text
31991    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31992    /// ````
31993    ///
31994    /// Sets the *delegate* property to the given value.
31995    pub fn delegate(
31996        mut self,
31997        new_value: &'a mut dyn common::Delegate,
31998    ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31999        self._delegate = Some(new_value);
32000        self
32001    }
32002
32003    /// Set any additional parameter of the query string used in the request.
32004    /// It should be used to set parameters which are not yet available through their own
32005    /// setters.
32006    ///
32007    /// Please note that this method must not be used to set any of the known parameters
32008    /// which have their own setter method. If done anyway, the request will fail.
32009    ///
32010    /// # Additional Parameters
32011    ///
32012    /// * *alt* (query-string) - Data format for the response.
32013    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32014    /// * *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.
32015    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32016    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32017    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32018    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32019    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
32020    where
32021        T: AsRef<str>,
32022    {
32023        self._additional_params
32024            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32025        self
32026    }
32027
32028    /// Identifies the authorization scope for the method you are building.
32029    ///
32030    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32031    /// [`Scope::Edit`].
32032    ///
32033    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32034    /// tokens for more than one scope.
32035    ///
32036    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32037    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32038    /// sufficient, a read-write scope will do as well.
32039    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
32040    where
32041        St: AsRef<str>,
32042    {
32043        self._scopes.insert(String::from(scope.as_ref()));
32044        self
32045    }
32046    /// Identifies the authorization scope(s) for the method you are building.
32047    ///
32048    /// See [`Self::add_scope()`] for details.
32049    pub fn add_scopes<I, St>(
32050        mut self,
32051        scopes: I,
32052    ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
32053    where
32054        I: IntoIterator<Item = St>,
32055        St: AsRef<str>,
32056    {
32057        self._scopes
32058            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32059        self
32060    }
32061
32062    /// Removes all scopes, and no default scope will be used either.
32063    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32064    /// for details).
32065    pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
32066        self._scopes.clear();
32067        self
32068    }
32069}
32070
32071/// Updates an existing webProperty-Google Ads link.
32072///
32073/// A builder for the *webPropertyAdWordsLinks.update* method supported by a *management* resource.
32074/// It is not used directly, but through a [`ManagementMethods`] instance.
32075///
32076/// # Example
32077///
32078/// Instantiate a resource method builder
32079///
32080/// ```test_harness,no_run
32081/// # extern crate hyper;
32082/// # extern crate hyper_rustls;
32083/// # extern crate google_analytics3 as analytics3;
32084/// use analytics3::api::EntityAdWordsLink;
32085/// # async fn dox() {
32086/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32087///
32088/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32089/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32090/// #     .with_native_roots()
32091/// #     .unwrap()
32092/// #     .https_only()
32093/// #     .enable_http2()
32094/// #     .build();
32095///
32096/// # let executor = hyper_util::rt::TokioExecutor::new();
32097/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32098/// #     secret,
32099/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32100/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
32101/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
32102/// #     ),
32103/// # ).build().await.unwrap();
32104///
32105/// # let client = hyper_util::client::legacy::Client::builder(
32106/// #     hyper_util::rt::TokioExecutor::new()
32107/// # )
32108/// # .build(
32109/// #     hyper_rustls::HttpsConnectorBuilder::new()
32110/// #         .with_native_roots()
32111/// #         .unwrap()
32112/// #         .https_or_http()
32113/// #         .enable_http2()
32114/// #         .build()
32115/// # );
32116/// # let mut hub = Analytics::new(client, auth);
32117/// // As the method needs a request, you would usually fill it with the desired information
32118/// // into the respective structure. Some of the parts shown here might not be applicable !
32119/// // Values shown here are possibly random and not representative !
32120/// let mut req = EntityAdWordsLink::default();
32121///
32122/// // You can configure optional parameters by calling the respective setters at will, and
32123/// // execute the final call using `doit()`.
32124/// // Values shown here are possibly random and not representative !
32125/// let result = hub.management().web_property_ad_words_links_update(req, "accountId", "webPropertyId", "webPropertyAdWordsLinkId")
32126///              .doit().await;
32127/// # }
32128/// ```
32129pub struct ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
32130where
32131    C: 'a,
32132{
32133    hub: &'a Analytics<C>,
32134    _request: EntityAdWordsLink,
32135    _account_id: String,
32136    _web_property_id: String,
32137    _web_property_ad_words_link_id: String,
32138    _delegate: Option<&'a mut dyn common::Delegate>,
32139    _additional_params: HashMap<String, String>,
32140    _scopes: BTreeSet<String>,
32141}
32142
32143impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {}
32144
32145impl<'a, C> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
32146where
32147    C: common::Connector,
32148{
32149    /// Perform the operation you have build so far.
32150    pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLink)> {
32151        use std::borrow::Cow;
32152        use std::io::{Read, Seek};
32153
32154        use common::{url::Params, ToParts};
32155        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32156
32157        let mut dd = common::DefaultDelegate;
32158        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32159        dlg.begin(common::MethodInfo {
32160            id: "analytics.management.webPropertyAdWordsLinks.update",
32161            http_method: hyper::Method::PUT,
32162        });
32163
32164        for &field in [
32165            "alt",
32166            "accountId",
32167            "webPropertyId",
32168            "webPropertyAdWordsLinkId",
32169        ]
32170        .iter()
32171        {
32172            if self._additional_params.contains_key(field) {
32173                dlg.finished(false);
32174                return Err(common::Error::FieldClash(field));
32175            }
32176        }
32177
32178        let mut params = Params::with_capacity(6 + self._additional_params.len());
32179        params.push("accountId", self._account_id);
32180        params.push("webPropertyId", self._web_property_id);
32181        params.push(
32182            "webPropertyAdWordsLinkId",
32183            self._web_property_ad_words_link_id,
32184        );
32185
32186        params.extend(self._additional_params.iter());
32187
32188        params.push("alt", "json");
32189        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}";
32190        if self._scopes.is_empty() {
32191            self._scopes.insert(Scope::Edit.as_ref().to_string());
32192        }
32193
32194        #[allow(clippy::single_element_loop)]
32195        for &(find_this, param_name) in [
32196            ("{accountId}", "accountId"),
32197            ("{webPropertyId}", "webPropertyId"),
32198            ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId"),
32199        ]
32200        .iter()
32201        {
32202            url = params.uri_replacement(url, param_name, find_this, false);
32203        }
32204        {
32205            let to_remove = ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"];
32206            params.remove_params(&to_remove);
32207        }
32208
32209        let url = params.parse_with_url(&url);
32210
32211        let mut json_mime_type = mime::APPLICATION_JSON;
32212        let mut request_value_reader = {
32213            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32214            common::remove_json_null_values(&mut value);
32215            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32216            serde_json::to_writer(&mut dst, &value).unwrap();
32217            dst
32218        };
32219        let request_size = request_value_reader
32220            .seek(std::io::SeekFrom::End(0))
32221            .unwrap();
32222        request_value_reader
32223            .seek(std::io::SeekFrom::Start(0))
32224            .unwrap();
32225
32226        loop {
32227            let token = match self
32228                .hub
32229                .auth
32230                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32231                .await
32232            {
32233                Ok(token) => token,
32234                Err(e) => match dlg.token(e) {
32235                    Ok(token) => token,
32236                    Err(e) => {
32237                        dlg.finished(false);
32238                        return Err(common::Error::MissingToken(e));
32239                    }
32240                },
32241            };
32242            request_value_reader
32243                .seek(std::io::SeekFrom::Start(0))
32244                .unwrap();
32245            let mut req_result = {
32246                let client = &self.hub.client;
32247                dlg.pre_request();
32248                let mut req_builder = hyper::Request::builder()
32249                    .method(hyper::Method::PUT)
32250                    .uri(url.as_str())
32251                    .header(USER_AGENT, self.hub._user_agent.clone());
32252
32253                if let Some(token) = token.as_ref() {
32254                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32255                }
32256
32257                let request = req_builder
32258                    .header(CONTENT_TYPE, json_mime_type.to_string())
32259                    .header(CONTENT_LENGTH, request_size as u64)
32260                    .body(common::to_body(
32261                        request_value_reader.get_ref().clone().into(),
32262                    ));
32263
32264                client.request(request.unwrap()).await
32265            };
32266
32267            match req_result {
32268                Err(err) => {
32269                    if let common::Retry::After(d) = dlg.http_error(&err) {
32270                        sleep(d).await;
32271                        continue;
32272                    }
32273                    dlg.finished(false);
32274                    return Err(common::Error::HttpError(err));
32275                }
32276                Ok(res) => {
32277                    let (mut parts, body) = res.into_parts();
32278                    let mut body = common::Body::new(body);
32279                    if !parts.status.is_success() {
32280                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32281                        let error = serde_json::from_str(&common::to_string(&bytes));
32282                        let response = common::to_response(parts, bytes.into());
32283
32284                        if let common::Retry::After(d) =
32285                            dlg.http_failure(&response, error.as_ref().ok())
32286                        {
32287                            sleep(d).await;
32288                            continue;
32289                        }
32290
32291                        dlg.finished(false);
32292
32293                        return Err(match error {
32294                            Ok(value) => common::Error::BadRequest(value),
32295                            _ => common::Error::Failure(response),
32296                        });
32297                    }
32298                    let response = {
32299                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32300                        let encoded = common::to_string(&bytes);
32301                        match serde_json::from_str(&encoded) {
32302                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32303                            Err(error) => {
32304                                dlg.response_json_decode_error(&encoded, &error);
32305                                return Err(common::Error::JsonDecodeError(
32306                                    encoded.to_string(),
32307                                    error,
32308                                ));
32309                            }
32310                        }
32311                    };
32312
32313                    dlg.finished(true);
32314                    return Ok(response);
32315                }
32316            }
32317        }
32318    }
32319
32320    ///
32321    /// Sets the *request* property to the given value.
32322    ///
32323    /// Even though the property as already been set when instantiating this call,
32324    /// we provide this method for API completeness.
32325    pub fn request(
32326        mut self,
32327        new_value: EntityAdWordsLink,
32328    ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
32329        self._request = new_value;
32330        self
32331    }
32332    /// ID of the account which the given web property belongs to.
32333    ///
32334    /// Sets the *account id* path property to the given value.
32335    ///
32336    /// Even though the property as already been set when instantiating this call,
32337    /// we provide this method for API completeness.
32338    pub fn account_id(
32339        mut self,
32340        new_value: &str,
32341    ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
32342        self._account_id = new_value.to_string();
32343        self
32344    }
32345    /// Web property ID to retrieve the Google Ads link for.
32346    ///
32347    /// Sets the *web property id* path property to the given value.
32348    ///
32349    /// Even though the property as already been set when instantiating this call,
32350    /// we provide this method for API completeness.
32351    pub fn web_property_id(
32352        mut self,
32353        new_value: &str,
32354    ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
32355        self._web_property_id = new_value.to_string();
32356        self
32357    }
32358    /// Web property-Google Ads link ID.
32359    ///
32360    /// Sets the *web property ad words link id* path property to the given value.
32361    ///
32362    /// Even though the property as already been set when instantiating this call,
32363    /// we provide this method for API completeness.
32364    pub fn web_property_ad_words_link_id(
32365        mut self,
32366        new_value: &str,
32367    ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
32368        self._web_property_ad_words_link_id = new_value.to_string();
32369        self
32370    }
32371    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32372    /// while executing the actual API request.
32373    ///
32374    /// ````text
32375    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32376    /// ````
32377    ///
32378    /// Sets the *delegate* property to the given value.
32379    pub fn delegate(
32380        mut self,
32381        new_value: &'a mut dyn common::Delegate,
32382    ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
32383        self._delegate = Some(new_value);
32384        self
32385    }
32386
32387    /// Set any additional parameter of the query string used in the request.
32388    /// It should be used to set parameters which are not yet available through their own
32389    /// setters.
32390    ///
32391    /// Please note that this method must not be used to set any of the known parameters
32392    /// which have their own setter method. If done anyway, the request will fail.
32393    ///
32394    /// # Additional Parameters
32395    ///
32396    /// * *alt* (query-string) - Data format for the response.
32397    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32398    /// * *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.
32399    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32400    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32401    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32402    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32403    pub fn param<T>(
32404        mut self,
32405        name: T,
32406        value: T,
32407    ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
32408    where
32409        T: AsRef<str>,
32410    {
32411        self._additional_params
32412            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32413        self
32414    }
32415
32416    /// Identifies the authorization scope for the method you are building.
32417    ///
32418    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32419    /// [`Scope::Edit`].
32420    ///
32421    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32422    /// tokens for more than one scope.
32423    ///
32424    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32425    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32426    /// sufficient, a read-write scope will do as well.
32427    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
32428    where
32429        St: AsRef<str>,
32430    {
32431        self._scopes.insert(String::from(scope.as_ref()));
32432        self
32433    }
32434    /// Identifies the authorization scope(s) for the method you are building.
32435    ///
32436    /// See [`Self::add_scope()`] for details.
32437    pub fn add_scopes<I, St>(
32438        mut self,
32439        scopes: I,
32440    ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
32441    where
32442        I: IntoIterator<Item = St>,
32443        St: AsRef<str>,
32444    {
32445        self._scopes
32446            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32447        self
32448    }
32449
32450    /// Removes all scopes, and no default scope will be used either.
32451    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32452    /// for details).
32453    pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
32454        self._scopes.clear();
32455        self
32456    }
32457}
32458
32459/// Gets a web property to which the user has access.
32460///
32461/// A builder for the *webproperties.get* method supported by a *management* resource.
32462/// It is not used directly, but through a [`ManagementMethods`] instance.
32463///
32464/// # Example
32465///
32466/// Instantiate a resource method builder
32467///
32468/// ```test_harness,no_run
32469/// # extern crate hyper;
32470/// # extern crate hyper_rustls;
32471/// # extern crate google_analytics3 as analytics3;
32472/// # async fn dox() {
32473/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32474///
32475/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32476/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32477/// #     .with_native_roots()
32478/// #     .unwrap()
32479/// #     .https_only()
32480/// #     .enable_http2()
32481/// #     .build();
32482///
32483/// # let executor = hyper_util::rt::TokioExecutor::new();
32484/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32485/// #     secret,
32486/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32487/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
32488/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
32489/// #     ),
32490/// # ).build().await.unwrap();
32491///
32492/// # let client = hyper_util::client::legacy::Client::builder(
32493/// #     hyper_util::rt::TokioExecutor::new()
32494/// # )
32495/// # .build(
32496/// #     hyper_rustls::HttpsConnectorBuilder::new()
32497/// #         .with_native_roots()
32498/// #         .unwrap()
32499/// #         .https_or_http()
32500/// #         .enable_http2()
32501/// #         .build()
32502/// # );
32503/// # let mut hub = Analytics::new(client, auth);
32504/// // You can configure optional parameters by calling the respective setters at will, and
32505/// // execute the final call using `doit()`.
32506/// // Values shown here are possibly random and not representative !
32507/// let result = hub.management().webproperties_get("accountId", "webPropertyId")
32508///              .doit().await;
32509/// # }
32510/// ```
32511pub struct ManagementWebpropertyGetCall<'a, C>
32512where
32513    C: 'a,
32514{
32515    hub: &'a Analytics<C>,
32516    _account_id: String,
32517    _web_property_id: String,
32518    _delegate: Option<&'a mut dyn common::Delegate>,
32519    _additional_params: HashMap<String, String>,
32520    _scopes: BTreeSet<String>,
32521}
32522
32523impl<'a, C> common::CallBuilder for ManagementWebpropertyGetCall<'a, C> {}
32524
32525impl<'a, C> ManagementWebpropertyGetCall<'a, C>
32526where
32527    C: common::Connector,
32528{
32529    /// Perform the operation you have build so far.
32530    pub async fn doit(mut self) -> common::Result<(common::Response, Webproperty)> {
32531        use std::borrow::Cow;
32532        use std::io::{Read, Seek};
32533
32534        use common::{url::Params, ToParts};
32535        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32536
32537        let mut dd = common::DefaultDelegate;
32538        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32539        dlg.begin(common::MethodInfo {
32540            id: "analytics.management.webproperties.get",
32541            http_method: hyper::Method::GET,
32542        });
32543
32544        for &field in ["alt", "accountId", "webPropertyId"].iter() {
32545            if self._additional_params.contains_key(field) {
32546                dlg.finished(false);
32547                return Err(common::Error::FieldClash(field));
32548            }
32549        }
32550
32551        let mut params = Params::with_capacity(4 + self._additional_params.len());
32552        params.push("accountId", self._account_id);
32553        params.push("webPropertyId", self._web_property_id);
32554
32555        params.extend(self._additional_params.iter());
32556
32557        params.push("alt", "json");
32558        let mut url = self.hub._base_url.clone()
32559            + "management/accounts/{accountId}/webproperties/{webPropertyId}";
32560        if self._scopes.is_empty() {
32561            self._scopes.insert(Scope::Readonly.as_ref().to_string());
32562        }
32563
32564        #[allow(clippy::single_element_loop)]
32565        for &(find_this, param_name) in [
32566            ("{accountId}", "accountId"),
32567            ("{webPropertyId}", "webPropertyId"),
32568        ]
32569        .iter()
32570        {
32571            url = params.uri_replacement(url, param_name, find_this, false);
32572        }
32573        {
32574            let to_remove = ["webPropertyId", "accountId"];
32575            params.remove_params(&to_remove);
32576        }
32577
32578        let url = params.parse_with_url(&url);
32579
32580        loop {
32581            let token = match self
32582                .hub
32583                .auth
32584                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32585                .await
32586            {
32587                Ok(token) => token,
32588                Err(e) => match dlg.token(e) {
32589                    Ok(token) => token,
32590                    Err(e) => {
32591                        dlg.finished(false);
32592                        return Err(common::Error::MissingToken(e));
32593                    }
32594                },
32595            };
32596            let mut req_result = {
32597                let client = &self.hub.client;
32598                dlg.pre_request();
32599                let mut req_builder = hyper::Request::builder()
32600                    .method(hyper::Method::GET)
32601                    .uri(url.as_str())
32602                    .header(USER_AGENT, self.hub._user_agent.clone());
32603
32604                if let Some(token) = token.as_ref() {
32605                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32606                }
32607
32608                let request = req_builder
32609                    .header(CONTENT_LENGTH, 0_u64)
32610                    .body(common::to_body::<String>(None));
32611
32612                client.request(request.unwrap()).await
32613            };
32614
32615            match req_result {
32616                Err(err) => {
32617                    if let common::Retry::After(d) = dlg.http_error(&err) {
32618                        sleep(d).await;
32619                        continue;
32620                    }
32621                    dlg.finished(false);
32622                    return Err(common::Error::HttpError(err));
32623                }
32624                Ok(res) => {
32625                    let (mut parts, body) = res.into_parts();
32626                    let mut body = common::Body::new(body);
32627                    if !parts.status.is_success() {
32628                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32629                        let error = serde_json::from_str(&common::to_string(&bytes));
32630                        let response = common::to_response(parts, bytes.into());
32631
32632                        if let common::Retry::After(d) =
32633                            dlg.http_failure(&response, error.as_ref().ok())
32634                        {
32635                            sleep(d).await;
32636                            continue;
32637                        }
32638
32639                        dlg.finished(false);
32640
32641                        return Err(match error {
32642                            Ok(value) => common::Error::BadRequest(value),
32643                            _ => common::Error::Failure(response),
32644                        });
32645                    }
32646                    let response = {
32647                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32648                        let encoded = common::to_string(&bytes);
32649                        match serde_json::from_str(&encoded) {
32650                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32651                            Err(error) => {
32652                                dlg.response_json_decode_error(&encoded, &error);
32653                                return Err(common::Error::JsonDecodeError(
32654                                    encoded.to_string(),
32655                                    error,
32656                                ));
32657                            }
32658                        }
32659                    };
32660
32661                    dlg.finished(true);
32662                    return Ok(response);
32663                }
32664            }
32665        }
32666    }
32667
32668    /// Account ID to retrieve the web property for.
32669    ///
32670    /// Sets the *account id* path property to the given value.
32671    ///
32672    /// Even though the property as already been set when instantiating this call,
32673    /// we provide this method for API completeness.
32674    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyGetCall<'a, C> {
32675        self._account_id = new_value.to_string();
32676        self
32677    }
32678    /// ID to retrieve the web property for.
32679    ///
32680    /// Sets the *web property id* path property to the given value.
32681    ///
32682    /// Even though the property as already been set when instantiating this call,
32683    /// we provide this method for API completeness.
32684    pub fn web_property_id(mut self, new_value: &str) -> ManagementWebpropertyGetCall<'a, C> {
32685        self._web_property_id = new_value.to_string();
32686        self
32687    }
32688    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32689    /// while executing the actual API request.
32690    ///
32691    /// ````text
32692    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32693    /// ````
32694    ///
32695    /// Sets the *delegate* property to the given value.
32696    pub fn delegate(
32697        mut self,
32698        new_value: &'a mut dyn common::Delegate,
32699    ) -> ManagementWebpropertyGetCall<'a, C> {
32700        self._delegate = Some(new_value);
32701        self
32702    }
32703
32704    /// Set any additional parameter of the query string used in the request.
32705    /// It should be used to set parameters which are not yet available through their own
32706    /// setters.
32707    ///
32708    /// Please note that this method must not be used to set any of the known parameters
32709    /// which have their own setter method. If done anyway, the request will fail.
32710    ///
32711    /// # Additional Parameters
32712    ///
32713    /// * *alt* (query-string) - Data format for the response.
32714    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32715    /// * *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.
32716    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32717    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32718    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32719    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32720    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyGetCall<'a, C>
32721    where
32722        T: AsRef<str>,
32723    {
32724        self._additional_params
32725            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32726        self
32727    }
32728
32729    /// Identifies the authorization scope for the method you are building.
32730    ///
32731    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32732    /// [`Scope::Readonly`].
32733    ///
32734    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32735    /// tokens for more than one scope.
32736    ///
32737    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32738    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32739    /// sufficient, a read-write scope will do as well.
32740    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyGetCall<'a, C>
32741    where
32742        St: AsRef<str>,
32743    {
32744        self._scopes.insert(String::from(scope.as_ref()));
32745        self
32746    }
32747    /// Identifies the authorization scope(s) for the method you are building.
32748    ///
32749    /// See [`Self::add_scope()`] for details.
32750    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyGetCall<'a, C>
32751    where
32752        I: IntoIterator<Item = St>,
32753        St: AsRef<str>,
32754    {
32755        self._scopes
32756            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32757        self
32758    }
32759
32760    /// Removes all scopes, and no default scope will be used either.
32761    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32762    /// for details).
32763    pub fn clear_scopes(mut self) -> ManagementWebpropertyGetCall<'a, C> {
32764        self._scopes.clear();
32765        self
32766    }
32767}
32768
32769/// Create a new property if the account has fewer than 20 properties. Web properties are visible in the Google Analytics interface only if they have at least one profile.
32770///
32771/// A builder for the *webproperties.insert* method supported by a *management* resource.
32772/// It is not used directly, but through a [`ManagementMethods`] instance.
32773///
32774/// # Example
32775///
32776/// Instantiate a resource method builder
32777///
32778/// ```test_harness,no_run
32779/// # extern crate hyper;
32780/// # extern crate hyper_rustls;
32781/// # extern crate google_analytics3 as analytics3;
32782/// use analytics3::api::Webproperty;
32783/// # async fn dox() {
32784/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32785///
32786/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32787/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32788/// #     .with_native_roots()
32789/// #     .unwrap()
32790/// #     .https_only()
32791/// #     .enable_http2()
32792/// #     .build();
32793///
32794/// # let executor = hyper_util::rt::TokioExecutor::new();
32795/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32796/// #     secret,
32797/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32798/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
32799/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
32800/// #     ),
32801/// # ).build().await.unwrap();
32802///
32803/// # let client = hyper_util::client::legacy::Client::builder(
32804/// #     hyper_util::rt::TokioExecutor::new()
32805/// # )
32806/// # .build(
32807/// #     hyper_rustls::HttpsConnectorBuilder::new()
32808/// #         .with_native_roots()
32809/// #         .unwrap()
32810/// #         .https_or_http()
32811/// #         .enable_http2()
32812/// #         .build()
32813/// # );
32814/// # let mut hub = Analytics::new(client, auth);
32815/// // As the method needs a request, you would usually fill it with the desired information
32816/// // into the respective structure. Some of the parts shown here might not be applicable !
32817/// // Values shown here are possibly random and not representative !
32818/// let mut req = Webproperty::default();
32819///
32820/// // You can configure optional parameters by calling the respective setters at will, and
32821/// // execute the final call using `doit()`.
32822/// // Values shown here are possibly random and not representative !
32823/// let result = hub.management().webproperties_insert(req, "accountId")
32824///              .doit().await;
32825/// # }
32826/// ```
32827pub struct ManagementWebpropertyInsertCall<'a, C>
32828where
32829    C: 'a,
32830{
32831    hub: &'a Analytics<C>,
32832    _request: Webproperty,
32833    _account_id: String,
32834    _delegate: Option<&'a mut dyn common::Delegate>,
32835    _additional_params: HashMap<String, String>,
32836    _scopes: BTreeSet<String>,
32837}
32838
32839impl<'a, C> common::CallBuilder for ManagementWebpropertyInsertCall<'a, C> {}
32840
32841impl<'a, C> ManagementWebpropertyInsertCall<'a, C>
32842where
32843    C: common::Connector,
32844{
32845    /// Perform the operation you have build so far.
32846    pub async fn doit(mut self) -> common::Result<(common::Response, Webproperty)> {
32847        use std::borrow::Cow;
32848        use std::io::{Read, Seek};
32849
32850        use common::{url::Params, ToParts};
32851        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32852
32853        let mut dd = common::DefaultDelegate;
32854        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32855        dlg.begin(common::MethodInfo {
32856            id: "analytics.management.webproperties.insert",
32857            http_method: hyper::Method::POST,
32858        });
32859
32860        for &field in ["alt", "accountId"].iter() {
32861            if self._additional_params.contains_key(field) {
32862                dlg.finished(false);
32863                return Err(common::Error::FieldClash(field));
32864            }
32865        }
32866
32867        let mut params = Params::with_capacity(4 + self._additional_params.len());
32868        params.push("accountId", self._account_id);
32869
32870        params.extend(self._additional_params.iter());
32871
32872        params.push("alt", "json");
32873        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties";
32874        if self._scopes.is_empty() {
32875            self._scopes.insert(Scope::Edit.as_ref().to_string());
32876        }
32877
32878        #[allow(clippy::single_element_loop)]
32879        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
32880            url = params.uri_replacement(url, param_name, find_this, false);
32881        }
32882        {
32883            let to_remove = ["accountId"];
32884            params.remove_params(&to_remove);
32885        }
32886
32887        let url = params.parse_with_url(&url);
32888
32889        let mut json_mime_type = mime::APPLICATION_JSON;
32890        let mut request_value_reader = {
32891            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32892            common::remove_json_null_values(&mut value);
32893            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32894            serde_json::to_writer(&mut dst, &value).unwrap();
32895            dst
32896        };
32897        let request_size = request_value_reader
32898            .seek(std::io::SeekFrom::End(0))
32899            .unwrap();
32900        request_value_reader
32901            .seek(std::io::SeekFrom::Start(0))
32902            .unwrap();
32903
32904        loop {
32905            let token = match self
32906                .hub
32907                .auth
32908                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32909                .await
32910            {
32911                Ok(token) => token,
32912                Err(e) => match dlg.token(e) {
32913                    Ok(token) => token,
32914                    Err(e) => {
32915                        dlg.finished(false);
32916                        return Err(common::Error::MissingToken(e));
32917                    }
32918                },
32919            };
32920            request_value_reader
32921                .seek(std::io::SeekFrom::Start(0))
32922                .unwrap();
32923            let mut req_result = {
32924                let client = &self.hub.client;
32925                dlg.pre_request();
32926                let mut req_builder = hyper::Request::builder()
32927                    .method(hyper::Method::POST)
32928                    .uri(url.as_str())
32929                    .header(USER_AGENT, self.hub._user_agent.clone());
32930
32931                if let Some(token) = token.as_ref() {
32932                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32933                }
32934
32935                let request = req_builder
32936                    .header(CONTENT_TYPE, json_mime_type.to_string())
32937                    .header(CONTENT_LENGTH, request_size as u64)
32938                    .body(common::to_body(
32939                        request_value_reader.get_ref().clone().into(),
32940                    ));
32941
32942                client.request(request.unwrap()).await
32943            };
32944
32945            match req_result {
32946                Err(err) => {
32947                    if let common::Retry::After(d) = dlg.http_error(&err) {
32948                        sleep(d).await;
32949                        continue;
32950                    }
32951                    dlg.finished(false);
32952                    return Err(common::Error::HttpError(err));
32953                }
32954                Ok(res) => {
32955                    let (mut parts, body) = res.into_parts();
32956                    let mut body = common::Body::new(body);
32957                    if !parts.status.is_success() {
32958                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32959                        let error = serde_json::from_str(&common::to_string(&bytes));
32960                        let response = common::to_response(parts, bytes.into());
32961
32962                        if let common::Retry::After(d) =
32963                            dlg.http_failure(&response, error.as_ref().ok())
32964                        {
32965                            sleep(d).await;
32966                            continue;
32967                        }
32968
32969                        dlg.finished(false);
32970
32971                        return Err(match error {
32972                            Ok(value) => common::Error::BadRequest(value),
32973                            _ => common::Error::Failure(response),
32974                        });
32975                    }
32976                    let response = {
32977                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32978                        let encoded = common::to_string(&bytes);
32979                        match serde_json::from_str(&encoded) {
32980                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32981                            Err(error) => {
32982                                dlg.response_json_decode_error(&encoded, &error);
32983                                return Err(common::Error::JsonDecodeError(
32984                                    encoded.to_string(),
32985                                    error,
32986                                ));
32987                            }
32988                        }
32989                    };
32990
32991                    dlg.finished(true);
32992                    return Ok(response);
32993                }
32994            }
32995        }
32996    }
32997
32998    ///
32999    /// Sets the *request* property to the given value.
33000    ///
33001    /// Even though the property as already been set when instantiating this call,
33002    /// we provide this method for API completeness.
33003    pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyInsertCall<'a, C> {
33004        self._request = new_value;
33005        self
33006    }
33007    /// Account ID to create the web property for.
33008    ///
33009    /// Sets the *account id* path property to the given value.
33010    ///
33011    /// Even though the property as already been set when instantiating this call,
33012    /// we provide this method for API completeness.
33013    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyInsertCall<'a, C> {
33014        self._account_id = new_value.to_string();
33015        self
33016    }
33017    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33018    /// while executing the actual API request.
33019    ///
33020    /// ````text
33021    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33022    /// ````
33023    ///
33024    /// Sets the *delegate* property to the given value.
33025    pub fn delegate(
33026        mut self,
33027        new_value: &'a mut dyn common::Delegate,
33028    ) -> ManagementWebpropertyInsertCall<'a, C> {
33029        self._delegate = Some(new_value);
33030        self
33031    }
33032
33033    /// Set any additional parameter of the query string used in the request.
33034    /// It should be used to set parameters which are not yet available through their own
33035    /// setters.
33036    ///
33037    /// Please note that this method must not be used to set any of the known parameters
33038    /// which have their own setter method. If done anyway, the request will fail.
33039    ///
33040    /// # Additional Parameters
33041    ///
33042    /// * *alt* (query-string) - Data format for the response.
33043    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33044    /// * *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.
33045    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33046    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33047    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33048    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33049    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyInsertCall<'a, C>
33050    where
33051        T: AsRef<str>,
33052    {
33053        self._additional_params
33054            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33055        self
33056    }
33057
33058    /// Identifies the authorization scope for the method you are building.
33059    ///
33060    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33061    /// [`Scope::Edit`].
33062    ///
33063    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33064    /// tokens for more than one scope.
33065    ///
33066    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33067    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33068    /// sufficient, a read-write scope will do as well.
33069    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyInsertCall<'a, C>
33070    where
33071        St: AsRef<str>,
33072    {
33073        self._scopes.insert(String::from(scope.as_ref()));
33074        self
33075    }
33076    /// Identifies the authorization scope(s) for the method you are building.
33077    ///
33078    /// See [`Self::add_scope()`] for details.
33079    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyInsertCall<'a, C>
33080    where
33081        I: IntoIterator<Item = St>,
33082        St: AsRef<str>,
33083    {
33084        self._scopes
33085            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33086        self
33087    }
33088
33089    /// Removes all scopes, and no default scope will be used either.
33090    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33091    /// for details).
33092    pub fn clear_scopes(mut self) -> ManagementWebpropertyInsertCall<'a, C> {
33093        self._scopes.clear();
33094        self
33095    }
33096}
33097
33098/// Lists web properties to which the user has access.
33099///
33100/// A builder for the *webproperties.list* method supported by a *management* resource.
33101/// It is not used directly, but through a [`ManagementMethods`] instance.
33102///
33103/// # Example
33104///
33105/// Instantiate a resource method builder
33106///
33107/// ```test_harness,no_run
33108/// # extern crate hyper;
33109/// # extern crate hyper_rustls;
33110/// # extern crate google_analytics3 as analytics3;
33111/// # async fn dox() {
33112/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33113///
33114/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33115/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33116/// #     .with_native_roots()
33117/// #     .unwrap()
33118/// #     .https_only()
33119/// #     .enable_http2()
33120/// #     .build();
33121///
33122/// # let executor = hyper_util::rt::TokioExecutor::new();
33123/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33124/// #     secret,
33125/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33126/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
33127/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
33128/// #     ),
33129/// # ).build().await.unwrap();
33130///
33131/// # let client = hyper_util::client::legacy::Client::builder(
33132/// #     hyper_util::rt::TokioExecutor::new()
33133/// # )
33134/// # .build(
33135/// #     hyper_rustls::HttpsConnectorBuilder::new()
33136/// #         .with_native_roots()
33137/// #         .unwrap()
33138/// #         .https_or_http()
33139/// #         .enable_http2()
33140/// #         .build()
33141/// # );
33142/// # let mut hub = Analytics::new(client, auth);
33143/// // You can configure optional parameters by calling the respective setters at will, and
33144/// // execute the final call using `doit()`.
33145/// // Values shown here are possibly random and not representative !
33146/// let result = hub.management().webproperties_list("accountId")
33147///              .start_index(-15)
33148///              .max_results(-62)
33149///              .doit().await;
33150/// # }
33151/// ```
33152pub struct ManagementWebpropertyListCall<'a, C>
33153where
33154    C: 'a,
33155{
33156    hub: &'a Analytics<C>,
33157    _account_id: String,
33158    _start_index: Option<i32>,
33159    _max_results: Option<i32>,
33160    _delegate: Option<&'a mut dyn common::Delegate>,
33161    _additional_params: HashMap<String, String>,
33162    _scopes: BTreeSet<String>,
33163}
33164
33165impl<'a, C> common::CallBuilder for ManagementWebpropertyListCall<'a, C> {}
33166
33167impl<'a, C> ManagementWebpropertyListCall<'a, C>
33168where
33169    C: common::Connector,
33170{
33171    /// Perform the operation you have build so far.
33172    pub async fn doit(mut self) -> common::Result<(common::Response, Webproperties)> {
33173        use std::borrow::Cow;
33174        use std::io::{Read, Seek};
33175
33176        use common::{url::Params, ToParts};
33177        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33178
33179        let mut dd = common::DefaultDelegate;
33180        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33181        dlg.begin(common::MethodInfo {
33182            id: "analytics.management.webproperties.list",
33183            http_method: hyper::Method::GET,
33184        });
33185
33186        for &field in ["alt", "accountId", "start-index", "max-results"].iter() {
33187            if self._additional_params.contains_key(field) {
33188                dlg.finished(false);
33189                return Err(common::Error::FieldClash(field));
33190            }
33191        }
33192
33193        let mut params = Params::with_capacity(5 + self._additional_params.len());
33194        params.push("accountId", self._account_id);
33195        if let Some(value) = self._start_index.as_ref() {
33196            params.push("start-index", value.to_string());
33197        }
33198        if let Some(value) = self._max_results.as_ref() {
33199            params.push("max-results", value.to_string());
33200        }
33201
33202        params.extend(self._additional_params.iter());
33203
33204        params.push("alt", "json");
33205        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties";
33206        if self._scopes.is_empty() {
33207            self._scopes.insert(Scope::Readonly.as_ref().to_string());
33208        }
33209
33210        #[allow(clippy::single_element_loop)]
33211        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
33212            url = params.uri_replacement(url, param_name, find_this, false);
33213        }
33214        {
33215            let to_remove = ["accountId"];
33216            params.remove_params(&to_remove);
33217        }
33218
33219        let url = params.parse_with_url(&url);
33220
33221        loop {
33222            let token = match self
33223                .hub
33224                .auth
33225                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33226                .await
33227            {
33228                Ok(token) => token,
33229                Err(e) => match dlg.token(e) {
33230                    Ok(token) => token,
33231                    Err(e) => {
33232                        dlg.finished(false);
33233                        return Err(common::Error::MissingToken(e));
33234                    }
33235                },
33236            };
33237            let mut req_result = {
33238                let client = &self.hub.client;
33239                dlg.pre_request();
33240                let mut req_builder = hyper::Request::builder()
33241                    .method(hyper::Method::GET)
33242                    .uri(url.as_str())
33243                    .header(USER_AGENT, self.hub._user_agent.clone());
33244
33245                if let Some(token) = token.as_ref() {
33246                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33247                }
33248
33249                let request = req_builder
33250                    .header(CONTENT_LENGTH, 0_u64)
33251                    .body(common::to_body::<String>(None));
33252
33253                client.request(request.unwrap()).await
33254            };
33255
33256            match req_result {
33257                Err(err) => {
33258                    if let common::Retry::After(d) = dlg.http_error(&err) {
33259                        sleep(d).await;
33260                        continue;
33261                    }
33262                    dlg.finished(false);
33263                    return Err(common::Error::HttpError(err));
33264                }
33265                Ok(res) => {
33266                    let (mut parts, body) = res.into_parts();
33267                    let mut body = common::Body::new(body);
33268                    if !parts.status.is_success() {
33269                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33270                        let error = serde_json::from_str(&common::to_string(&bytes));
33271                        let response = common::to_response(parts, bytes.into());
33272
33273                        if let common::Retry::After(d) =
33274                            dlg.http_failure(&response, error.as_ref().ok())
33275                        {
33276                            sleep(d).await;
33277                            continue;
33278                        }
33279
33280                        dlg.finished(false);
33281
33282                        return Err(match error {
33283                            Ok(value) => common::Error::BadRequest(value),
33284                            _ => common::Error::Failure(response),
33285                        });
33286                    }
33287                    let response = {
33288                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33289                        let encoded = common::to_string(&bytes);
33290                        match serde_json::from_str(&encoded) {
33291                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33292                            Err(error) => {
33293                                dlg.response_json_decode_error(&encoded, &error);
33294                                return Err(common::Error::JsonDecodeError(
33295                                    encoded.to_string(),
33296                                    error,
33297                                ));
33298                            }
33299                        }
33300                    };
33301
33302                    dlg.finished(true);
33303                    return Ok(response);
33304                }
33305            }
33306        }
33307    }
33308
33309    /// Account ID to retrieve web properties for. Can either be a specific account ID or '~all', which refers to all the accounts that user has access to.
33310    ///
33311    /// Sets the *account id* path property to the given value.
33312    ///
33313    /// Even though the property as already been set when instantiating this call,
33314    /// we provide this method for API completeness.
33315    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyListCall<'a, C> {
33316        self._account_id = new_value.to_string();
33317        self
33318    }
33319    /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
33320    ///
33321    /// Sets the *start-index* query property to the given value.
33322    pub fn start_index(mut self, new_value: i32) -> ManagementWebpropertyListCall<'a, C> {
33323        self._start_index = Some(new_value);
33324        self
33325    }
33326    /// The maximum number of web properties to include in this response.
33327    ///
33328    /// Sets the *max-results* query property to the given value.
33329    pub fn max_results(mut self, new_value: i32) -> ManagementWebpropertyListCall<'a, C> {
33330        self._max_results = Some(new_value);
33331        self
33332    }
33333    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33334    /// while executing the actual API request.
33335    ///
33336    /// ````text
33337    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33338    /// ````
33339    ///
33340    /// Sets the *delegate* property to the given value.
33341    pub fn delegate(
33342        mut self,
33343        new_value: &'a mut dyn common::Delegate,
33344    ) -> ManagementWebpropertyListCall<'a, C> {
33345        self._delegate = Some(new_value);
33346        self
33347    }
33348
33349    /// Set any additional parameter of the query string used in the request.
33350    /// It should be used to set parameters which are not yet available through their own
33351    /// setters.
33352    ///
33353    /// Please note that this method must not be used to set any of the known parameters
33354    /// which have their own setter method. If done anyway, the request will fail.
33355    ///
33356    /// # Additional Parameters
33357    ///
33358    /// * *alt* (query-string) - Data format for the response.
33359    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33360    /// * *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.
33361    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33362    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33363    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33364    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33365    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyListCall<'a, C>
33366    where
33367        T: AsRef<str>,
33368    {
33369        self._additional_params
33370            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33371        self
33372    }
33373
33374    /// Identifies the authorization scope for the method you are building.
33375    ///
33376    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33377    /// [`Scope::Readonly`].
33378    ///
33379    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33380    /// tokens for more than one scope.
33381    ///
33382    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33383    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33384    /// sufficient, a read-write scope will do as well.
33385    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyListCall<'a, C>
33386    where
33387        St: AsRef<str>,
33388    {
33389        self._scopes.insert(String::from(scope.as_ref()));
33390        self
33391    }
33392    /// Identifies the authorization scope(s) for the method you are building.
33393    ///
33394    /// See [`Self::add_scope()`] for details.
33395    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyListCall<'a, C>
33396    where
33397        I: IntoIterator<Item = St>,
33398        St: AsRef<str>,
33399    {
33400        self._scopes
33401            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33402        self
33403    }
33404
33405    /// Removes all scopes, and no default scope will be used either.
33406    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33407    /// for details).
33408    pub fn clear_scopes(mut self) -> ManagementWebpropertyListCall<'a, C> {
33409        self._scopes.clear();
33410        self
33411    }
33412}
33413
33414/// Updates an existing web property. This method supports patch semantics.
33415///
33416/// A builder for the *webproperties.patch* method supported by a *management* resource.
33417/// It is not used directly, but through a [`ManagementMethods`] instance.
33418///
33419/// # Example
33420///
33421/// Instantiate a resource method builder
33422///
33423/// ```test_harness,no_run
33424/// # extern crate hyper;
33425/// # extern crate hyper_rustls;
33426/// # extern crate google_analytics3 as analytics3;
33427/// use analytics3::api::Webproperty;
33428/// # async fn dox() {
33429/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33430///
33431/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33432/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33433/// #     .with_native_roots()
33434/// #     .unwrap()
33435/// #     .https_only()
33436/// #     .enable_http2()
33437/// #     .build();
33438///
33439/// # let executor = hyper_util::rt::TokioExecutor::new();
33440/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33441/// #     secret,
33442/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33443/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
33444/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
33445/// #     ),
33446/// # ).build().await.unwrap();
33447///
33448/// # let client = hyper_util::client::legacy::Client::builder(
33449/// #     hyper_util::rt::TokioExecutor::new()
33450/// # )
33451/// # .build(
33452/// #     hyper_rustls::HttpsConnectorBuilder::new()
33453/// #         .with_native_roots()
33454/// #         .unwrap()
33455/// #         .https_or_http()
33456/// #         .enable_http2()
33457/// #         .build()
33458/// # );
33459/// # let mut hub = Analytics::new(client, auth);
33460/// // As the method needs a request, you would usually fill it with the desired information
33461/// // into the respective structure. Some of the parts shown here might not be applicable !
33462/// // Values shown here are possibly random and not representative !
33463/// let mut req = Webproperty::default();
33464///
33465/// // You can configure optional parameters by calling the respective setters at will, and
33466/// // execute the final call using `doit()`.
33467/// // Values shown here are possibly random and not representative !
33468/// let result = hub.management().webproperties_patch(req, "accountId", "webPropertyId")
33469///              .doit().await;
33470/// # }
33471/// ```
33472pub struct ManagementWebpropertyPatchCall<'a, C>
33473where
33474    C: 'a,
33475{
33476    hub: &'a Analytics<C>,
33477    _request: Webproperty,
33478    _account_id: String,
33479    _web_property_id: String,
33480    _delegate: Option<&'a mut dyn common::Delegate>,
33481    _additional_params: HashMap<String, String>,
33482    _scopes: BTreeSet<String>,
33483}
33484
33485impl<'a, C> common::CallBuilder for ManagementWebpropertyPatchCall<'a, C> {}
33486
33487impl<'a, C> ManagementWebpropertyPatchCall<'a, C>
33488where
33489    C: common::Connector,
33490{
33491    /// Perform the operation you have build so far.
33492    pub async fn doit(mut self) -> common::Result<(common::Response, Webproperty)> {
33493        use std::borrow::Cow;
33494        use std::io::{Read, Seek};
33495
33496        use common::{url::Params, ToParts};
33497        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33498
33499        let mut dd = common::DefaultDelegate;
33500        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33501        dlg.begin(common::MethodInfo {
33502            id: "analytics.management.webproperties.patch",
33503            http_method: hyper::Method::PATCH,
33504        });
33505
33506        for &field in ["alt", "accountId", "webPropertyId"].iter() {
33507            if self._additional_params.contains_key(field) {
33508                dlg.finished(false);
33509                return Err(common::Error::FieldClash(field));
33510            }
33511        }
33512
33513        let mut params = Params::with_capacity(5 + self._additional_params.len());
33514        params.push("accountId", self._account_id);
33515        params.push("webPropertyId", self._web_property_id);
33516
33517        params.extend(self._additional_params.iter());
33518
33519        params.push("alt", "json");
33520        let mut url = self.hub._base_url.clone()
33521            + "management/accounts/{accountId}/webproperties/{webPropertyId}";
33522        if self._scopes.is_empty() {
33523            self._scopes.insert(Scope::Edit.as_ref().to_string());
33524        }
33525
33526        #[allow(clippy::single_element_loop)]
33527        for &(find_this, param_name) in [
33528            ("{accountId}", "accountId"),
33529            ("{webPropertyId}", "webPropertyId"),
33530        ]
33531        .iter()
33532        {
33533            url = params.uri_replacement(url, param_name, find_this, false);
33534        }
33535        {
33536            let to_remove = ["webPropertyId", "accountId"];
33537            params.remove_params(&to_remove);
33538        }
33539
33540        let url = params.parse_with_url(&url);
33541
33542        let mut json_mime_type = mime::APPLICATION_JSON;
33543        let mut request_value_reader = {
33544            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33545            common::remove_json_null_values(&mut value);
33546            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33547            serde_json::to_writer(&mut dst, &value).unwrap();
33548            dst
33549        };
33550        let request_size = request_value_reader
33551            .seek(std::io::SeekFrom::End(0))
33552            .unwrap();
33553        request_value_reader
33554            .seek(std::io::SeekFrom::Start(0))
33555            .unwrap();
33556
33557        loop {
33558            let token = match self
33559                .hub
33560                .auth
33561                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33562                .await
33563            {
33564                Ok(token) => token,
33565                Err(e) => match dlg.token(e) {
33566                    Ok(token) => token,
33567                    Err(e) => {
33568                        dlg.finished(false);
33569                        return Err(common::Error::MissingToken(e));
33570                    }
33571                },
33572            };
33573            request_value_reader
33574                .seek(std::io::SeekFrom::Start(0))
33575                .unwrap();
33576            let mut req_result = {
33577                let client = &self.hub.client;
33578                dlg.pre_request();
33579                let mut req_builder = hyper::Request::builder()
33580                    .method(hyper::Method::PATCH)
33581                    .uri(url.as_str())
33582                    .header(USER_AGENT, self.hub._user_agent.clone());
33583
33584                if let Some(token) = token.as_ref() {
33585                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33586                }
33587
33588                let request = req_builder
33589                    .header(CONTENT_TYPE, json_mime_type.to_string())
33590                    .header(CONTENT_LENGTH, request_size as u64)
33591                    .body(common::to_body(
33592                        request_value_reader.get_ref().clone().into(),
33593                    ));
33594
33595                client.request(request.unwrap()).await
33596            };
33597
33598            match req_result {
33599                Err(err) => {
33600                    if let common::Retry::After(d) = dlg.http_error(&err) {
33601                        sleep(d).await;
33602                        continue;
33603                    }
33604                    dlg.finished(false);
33605                    return Err(common::Error::HttpError(err));
33606                }
33607                Ok(res) => {
33608                    let (mut parts, body) = res.into_parts();
33609                    let mut body = common::Body::new(body);
33610                    if !parts.status.is_success() {
33611                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33612                        let error = serde_json::from_str(&common::to_string(&bytes));
33613                        let response = common::to_response(parts, bytes.into());
33614
33615                        if let common::Retry::After(d) =
33616                            dlg.http_failure(&response, error.as_ref().ok())
33617                        {
33618                            sleep(d).await;
33619                            continue;
33620                        }
33621
33622                        dlg.finished(false);
33623
33624                        return Err(match error {
33625                            Ok(value) => common::Error::BadRequest(value),
33626                            _ => common::Error::Failure(response),
33627                        });
33628                    }
33629                    let response = {
33630                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33631                        let encoded = common::to_string(&bytes);
33632                        match serde_json::from_str(&encoded) {
33633                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33634                            Err(error) => {
33635                                dlg.response_json_decode_error(&encoded, &error);
33636                                return Err(common::Error::JsonDecodeError(
33637                                    encoded.to_string(),
33638                                    error,
33639                                ));
33640                            }
33641                        }
33642                    };
33643
33644                    dlg.finished(true);
33645                    return Ok(response);
33646                }
33647            }
33648        }
33649    }
33650
33651    ///
33652    /// Sets the *request* property to the given value.
33653    ///
33654    /// Even though the property as already been set when instantiating this call,
33655    /// we provide this method for API completeness.
33656    pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyPatchCall<'a, C> {
33657        self._request = new_value;
33658        self
33659    }
33660    /// Account ID to which the web property belongs
33661    ///
33662    /// Sets the *account id* path property to the given value.
33663    ///
33664    /// Even though the property as already been set when instantiating this call,
33665    /// we provide this method for API completeness.
33666    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyPatchCall<'a, C> {
33667        self._account_id = new_value.to_string();
33668        self
33669    }
33670    /// Web property ID
33671    ///
33672    /// Sets the *web property id* path property to the given value.
33673    ///
33674    /// Even though the property as already been set when instantiating this call,
33675    /// we provide this method for API completeness.
33676    pub fn web_property_id(mut self, new_value: &str) -> ManagementWebpropertyPatchCall<'a, C> {
33677        self._web_property_id = new_value.to_string();
33678        self
33679    }
33680    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33681    /// while executing the actual API request.
33682    ///
33683    /// ````text
33684    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33685    /// ````
33686    ///
33687    /// Sets the *delegate* property to the given value.
33688    pub fn delegate(
33689        mut self,
33690        new_value: &'a mut dyn common::Delegate,
33691    ) -> ManagementWebpropertyPatchCall<'a, C> {
33692        self._delegate = Some(new_value);
33693        self
33694    }
33695
33696    /// Set any additional parameter of the query string used in the request.
33697    /// It should be used to set parameters which are not yet available through their own
33698    /// setters.
33699    ///
33700    /// Please note that this method must not be used to set any of the known parameters
33701    /// which have their own setter method. If done anyway, the request will fail.
33702    ///
33703    /// # Additional Parameters
33704    ///
33705    /// * *alt* (query-string) - Data format for the response.
33706    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33707    /// * *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.
33708    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33709    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33710    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33711    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33712    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyPatchCall<'a, C>
33713    where
33714        T: AsRef<str>,
33715    {
33716        self._additional_params
33717            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33718        self
33719    }
33720
33721    /// Identifies the authorization scope for the method you are building.
33722    ///
33723    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33724    /// [`Scope::Edit`].
33725    ///
33726    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33727    /// tokens for more than one scope.
33728    ///
33729    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33730    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33731    /// sufficient, a read-write scope will do as well.
33732    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyPatchCall<'a, C>
33733    where
33734        St: AsRef<str>,
33735    {
33736        self._scopes.insert(String::from(scope.as_ref()));
33737        self
33738    }
33739    /// Identifies the authorization scope(s) for the method you are building.
33740    ///
33741    /// See [`Self::add_scope()`] for details.
33742    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyPatchCall<'a, C>
33743    where
33744        I: IntoIterator<Item = St>,
33745        St: AsRef<str>,
33746    {
33747        self._scopes
33748            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33749        self
33750    }
33751
33752    /// Removes all scopes, and no default scope will be used either.
33753    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33754    /// for details).
33755    pub fn clear_scopes(mut self) -> ManagementWebpropertyPatchCall<'a, C> {
33756        self._scopes.clear();
33757        self
33758    }
33759}
33760
33761/// Updates an existing web property.
33762///
33763/// A builder for the *webproperties.update* method supported by a *management* resource.
33764/// It is not used directly, but through a [`ManagementMethods`] instance.
33765///
33766/// # Example
33767///
33768/// Instantiate a resource method builder
33769///
33770/// ```test_harness,no_run
33771/// # extern crate hyper;
33772/// # extern crate hyper_rustls;
33773/// # extern crate google_analytics3 as analytics3;
33774/// use analytics3::api::Webproperty;
33775/// # async fn dox() {
33776/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33777///
33778/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33779/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33780/// #     .with_native_roots()
33781/// #     .unwrap()
33782/// #     .https_only()
33783/// #     .enable_http2()
33784/// #     .build();
33785///
33786/// # let executor = hyper_util::rt::TokioExecutor::new();
33787/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33788/// #     secret,
33789/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33790/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
33791/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
33792/// #     ),
33793/// # ).build().await.unwrap();
33794///
33795/// # let client = hyper_util::client::legacy::Client::builder(
33796/// #     hyper_util::rt::TokioExecutor::new()
33797/// # )
33798/// # .build(
33799/// #     hyper_rustls::HttpsConnectorBuilder::new()
33800/// #         .with_native_roots()
33801/// #         .unwrap()
33802/// #         .https_or_http()
33803/// #         .enable_http2()
33804/// #         .build()
33805/// # );
33806/// # let mut hub = Analytics::new(client, auth);
33807/// // As the method needs a request, you would usually fill it with the desired information
33808/// // into the respective structure. Some of the parts shown here might not be applicable !
33809/// // Values shown here are possibly random and not representative !
33810/// let mut req = Webproperty::default();
33811///
33812/// // You can configure optional parameters by calling the respective setters at will, and
33813/// // execute the final call using `doit()`.
33814/// // Values shown here are possibly random and not representative !
33815/// let result = hub.management().webproperties_update(req, "accountId", "webPropertyId")
33816///              .doit().await;
33817/// # }
33818/// ```
33819pub struct ManagementWebpropertyUpdateCall<'a, C>
33820where
33821    C: 'a,
33822{
33823    hub: &'a Analytics<C>,
33824    _request: Webproperty,
33825    _account_id: String,
33826    _web_property_id: String,
33827    _delegate: Option<&'a mut dyn common::Delegate>,
33828    _additional_params: HashMap<String, String>,
33829    _scopes: BTreeSet<String>,
33830}
33831
33832impl<'a, C> common::CallBuilder for ManagementWebpropertyUpdateCall<'a, C> {}
33833
33834impl<'a, C> ManagementWebpropertyUpdateCall<'a, C>
33835where
33836    C: common::Connector,
33837{
33838    /// Perform the operation you have build so far.
33839    pub async fn doit(mut self) -> common::Result<(common::Response, Webproperty)> {
33840        use std::borrow::Cow;
33841        use std::io::{Read, Seek};
33842
33843        use common::{url::Params, ToParts};
33844        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33845
33846        let mut dd = common::DefaultDelegate;
33847        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33848        dlg.begin(common::MethodInfo {
33849            id: "analytics.management.webproperties.update",
33850            http_method: hyper::Method::PUT,
33851        });
33852
33853        for &field in ["alt", "accountId", "webPropertyId"].iter() {
33854            if self._additional_params.contains_key(field) {
33855                dlg.finished(false);
33856                return Err(common::Error::FieldClash(field));
33857            }
33858        }
33859
33860        let mut params = Params::with_capacity(5 + self._additional_params.len());
33861        params.push("accountId", self._account_id);
33862        params.push("webPropertyId", self._web_property_id);
33863
33864        params.extend(self._additional_params.iter());
33865
33866        params.push("alt", "json");
33867        let mut url = self.hub._base_url.clone()
33868            + "management/accounts/{accountId}/webproperties/{webPropertyId}";
33869        if self._scopes.is_empty() {
33870            self._scopes.insert(Scope::Edit.as_ref().to_string());
33871        }
33872
33873        #[allow(clippy::single_element_loop)]
33874        for &(find_this, param_name) in [
33875            ("{accountId}", "accountId"),
33876            ("{webPropertyId}", "webPropertyId"),
33877        ]
33878        .iter()
33879        {
33880            url = params.uri_replacement(url, param_name, find_this, false);
33881        }
33882        {
33883            let to_remove = ["webPropertyId", "accountId"];
33884            params.remove_params(&to_remove);
33885        }
33886
33887        let url = params.parse_with_url(&url);
33888
33889        let mut json_mime_type = mime::APPLICATION_JSON;
33890        let mut request_value_reader = {
33891            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33892            common::remove_json_null_values(&mut value);
33893            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33894            serde_json::to_writer(&mut dst, &value).unwrap();
33895            dst
33896        };
33897        let request_size = request_value_reader
33898            .seek(std::io::SeekFrom::End(0))
33899            .unwrap();
33900        request_value_reader
33901            .seek(std::io::SeekFrom::Start(0))
33902            .unwrap();
33903
33904        loop {
33905            let token = match self
33906                .hub
33907                .auth
33908                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33909                .await
33910            {
33911                Ok(token) => token,
33912                Err(e) => match dlg.token(e) {
33913                    Ok(token) => token,
33914                    Err(e) => {
33915                        dlg.finished(false);
33916                        return Err(common::Error::MissingToken(e));
33917                    }
33918                },
33919            };
33920            request_value_reader
33921                .seek(std::io::SeekFrom::Start(0))
33922                .unwrap();
33923            let mut req_result = {
33924                let client = &self.hub.client;
33925                dlg.pre_request();
33926                let mut req_builder = hyper::Request::builder()
33927                    .method(hyper::Method::PUT)
33928                    .uri(url.as_str())
33929                    .header(USER_AGENT, self.hub._user_agent.clone());
33930
33931                if let Some(token) = token.as_ref() {
33932                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33933                }
33934
33935                let request = req_builder
33936                    .header(CONTENT_TYPE, json_mime_type.to_string())
33937                    .header(CONTENT_LENGTH, request_size as u64)
33938                    .body(common::to_body(
33939                        request_value_reader.get_ref().clone().into(),
33940                    ));
33941
33942                client.request(request.unwrap()).await
33943            };
33944
33945            match req_result {
33946                Err(err) => {
33947                    if let common::Retry::After(d) = dlg.http_error(&err) {
33948                        sleep(d).await;
33949                        continue;
33950                    }
33951                    dlg.finished(false);
33952                    return Err(common::Error::HttpError(err));
33953                }
33954                Ok(res) => {
33955                    let (mut parts, body) = res.into_parts();
33956                    let mut body = common::Body::new(body);
33957                    if !parts.status.is_success() {
33958                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33959                        let error = serde_json::from_str(&common::to_string(&bytes));
33960                        let response = common::to_response(parts, bytes.into());
33961
33962                        if let common::Retry::After(d) =
33963                            dlg.http_failure(&response, error.as_ref().ok())
33964                        {
33965                            sleep(d).await;
33966                            continue;
33967                        }
33968
33969                        dlg.finished(false);
33970
33971                        return Err(match error {
33972                            Ok(value) => common::Error::BadRequest(value),
33973                            _ => common::Error::Failure(response),
33974                        });
33975                    }
33976                    let response = {
33977                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33978                        let encoded = common::to_string(&bytes);
33979                        match serde_json::from_str(&encoded) {
33980                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33981                            Err(error) => {
33982                                dlg.response_json_decode_error(&encoded, &error);
33983                                return Err(common::Error::JsonDecodeError(
33984                                    encoded.to_string(),
33985                                    error,
33986                                ));
33987                            }
33988                        }
33989                    };
33990
33991                    dlg.finished(true);
33992                    return Ok(response);
33993                }
33994            }
33995        }
33996    }
33997
33998    ///
33999    /// Sets the *request* property to the given value.
34000    ///
34001    /// Even though the property as already been set when instantiating this call,
34002    /// we provide this method for API completeness.
34003    pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyUpdateCall<'a, C> {
34004        self._request = new_value;
34005        self
34006    }
34007    /// Account ID to which the web property belongs
34008    ///
34009    /// Sets the *account id* path property to the given value.
34010    ///
34011    /// Even though the property as already been set when instantiating this call,
34012    /// we provide this method for API completeness.
34013    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUpdateCall<'a, C> {
34014        self._account_id = new_value.to_string();
34015        self
34016    }
34017    /// Web property ID
34018    ///
34019    /// Sets the *web property id* path property to the given value.
34020    ///
34021    /// Even though the property as already been set when instantiating this call,
34022    /// we provide this method for API completeness.
34023    pub fn web_property_id(mut self, new_value: &str) -> ManagementWebpropertyUpdateCall<'a, C> {
34024        self._web_property_id = new_value.to_string();
34025        self
34026    }
34027    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34028    /// while executing the actual API request.
34029    ///
34030    /// ````text
34031    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34032    /// ````
34033    ///
34034    /// Sets the *delegate* property to the given value.
34035    pub fn delegate(
34036        mut self,
34037        new_value: &'a mut dyn common::Delegate,
34038    ) -> ManagementWebpropertyUpdateCall<'a, C> {
34039        self._delegate = Some(new_value);
34040        self
34041    }
34042
34043    /// Set any additional parameter of the query string used in the request.
34044    /// It should be used to set parameters which are not yet available through their own
34045    /// setters.
34046    ///
34047    /// Please note that this method must not be used to set any of the known parameters
34048    /// which have their own setter method. If done anyway, the request will fail.
34049    ///
34050    /// # Additional Parameters
34051    ///
34052    /// * *alt* (query-string) - Data format for the response.
34053    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34054    /// * *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.
34055    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34056    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34057    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34058    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34059    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUpdateCall<'a, C>
34060    where
34061        T: AsRef<str>,
34062    {
34063        self._additional_params
34064            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34065        self
34066    }
34067
34068    /// Identifies the authorization scope for the method you are building.
34069    ///
34070    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34071    /// [`Scope::Edit`].
34072    ///
34073    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34074    /// tokens for more than one scope.
34075    ///
34076    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34077    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34078    /// sufficient, a read-write scope will do as well.
34079    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUpdateCall<'a, C>
34080    where
34081        St: AsRef<str>,
34082    {
34083        self._scopes.insert(String::from(scope.as_ref()));
34084        self
34085    }
34086    /// Identifies the authorization scope(s) for the method you are building.
34087    ///
34088    /// See [`Self::add_scope()`] for details.
34089    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUpdateCall<'a, C>
34090    where
34091        I: IntoIterator<Item = St>,
34092        St: AsRef<str>,
34093    {
34094        self._scopes
34095            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34096        self
34097    }
34098
34099    /// Removes all scopes, and no default scope will be used either.
34100    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34101    /// for details).
34102    pub fn clear_scopes(mut self) -> ManagementWebpropertyUpdateCall<'a, C> {
34103        self._scopes.clear();
34104        self
34105    }
34106}
34107
34108/// Removes a user from the given web property.
34109///
34110/// A builder for the *webpropertyUserLinks.delete* method supported by a *management* resource.
34111/// It is not used directly, but through a [`ManagementMethods`] instance.
34112///
34113/// # Example
34114///
34115/// Instantiate a resource method builder
34116///
34117/// ```test_harness,no_run
34118/// # extern crate hyper;
34119/// # extern crate hyper_rustls;
34120/// # extern crate google_analytics3 as analytics3;
34121/// # async fn dox() {
34122/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34123///
34124/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34125/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34126/// #     .with_native_roots()
34127/// #     .unwrap()
34128/// #     .https_only()
34129/// #     .enable_http2()
34130/// #     .build();
34131///
34132/// # let executor = hyper_util::rt::TokioExecutor::new();
34133/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34134/// #     secret,
34135/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34136/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
34137/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
34138/// #     ),
34139/// # ).build().await.unwrap();
34140///
34141/// # let client = hyper_util::client::legacy::Client::builder(
34142/// #     hyper_util::rt::TokioExecutor::new()
34143/// # )
34144/// # .build(
34145/// #     hyper_rustls::HttpsConnectorBuilder::new()
34146/// #         .with_native_roots()
34147/// #         .unwrap()
34148/// #         .https_or_http()
34149/// #         .enable_http2()
34150/// #         .build()
34151/// # );
34152/// # let mut hub = Analytics::new(client, auth);
34153/// // You can configure optional parameters by calling the respective setters at will, and
34154/// // execute the final call using `doit()`.
34155/// // Values shown here are possibly random and not representative !
34156/// let result = hub.management().webproperty_user_links_delete("accountId", "webPropertyId", "linkId")
34157///              .doit().await;
34158/// # }
34159/// ```
34160pub struct ManagementWebpropertyUserLinkDeleteCall<'a, C>
34161where
34162    C: 'a,
34163{
34164    hub: &'a Analytics<C>,
34165    _account_id: String,
34166    _web_property_id: String,
34167    _link_id: String,
34168    _delegate: Option<&'a mut dyn common::Delegate>,
34169    _additional_params: HashMap<String, String>,
34170    _scopes: BTreeSet<String>,
34171}
34172
34173impl<'a, C> common::CallBuilder for ManagementWebpropertyUserLinkDeleteCall<'a, C> {}
34174
34175impl<'a, C> ManagementWebpropertyUserLinkDeleteCall<'a, C>
34176where
34177    C: common::Connector,
34178{
34179    /// Perform the operation you have build so far.
34180    pub async fn doit(mut self) -> common::Result<common::Response> {
34181        use std::borrow::Cow;
34182        use std::io::{Read, Seek};
34183
34184        use common::{url::Params, ToParts};
34185        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34186
34187        let mut dd = common::DefaultDelegate;
34188        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34189        dlg.begin(common::MethodInfo {
34190            id: "analytics.management.webpropertyUserLinks.delete",
34191            http_method: hyper::Method::DELETE,
34192        });
34193
34194        for &field in ["accountId", "webPropertyId", "linkId"].iter() {
34195            if self._additional_params.contains_key(field) {
34196                dlg.finished(false);
34197                return Err(common::Error::FieldClash(field));
34198            }
34199        }
34200
34201        let mut params = Params::with_capacity(4 + self._additional_params.len());
34202        params.push("accountId", self._account_id);
34203        params.push("webPropertyId", self._web_property_id);
34204        params.push("linkId", self._link_id);
34205
34206        params.extend(self._additional_params.iter());
34207
34208        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks/{linkId}";
34209        if self._scopes.is_empty() {
34210            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
34211        }
34212
34213        #[allow(clippy::single_element_loop)]
34214        for &(find_this, param_name) in [
34215            ("{accountId}", "accountId"),
34216            ("{webPropertyId}", "webPropertyId"),
34217            ("{linkId}", "linkId"),
34218        ]
34219        .iter()
34220        {
34221            url = params.uri_replacement(url, param_name, find_this, false);
34222        }
34223        {
34224            let to_remove = ["linkId", "webPropertyId", "accountId"];
34225            params.remove_params(&to_remove);
34226        }
34227
34228        let url = params.parse_with_url(&url);
34229
34230        loop {
34231            let token = match self
34232                .hub
34233                .auth
34234                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34235                .await
34236            {
34237                Ok(token) => token,
34238                Err(e) => match dlg.token(e) {
34239                    Ok(token) => token,
34240                    Err(e) => {
34241                        dlg.finished(false);
34242                        return Err(common::Error::MissingToken(e));
34243                    }
34244                },
34245            };
34246            let mut req_result = {
34247                let client = &self.hub.client;
34248                dlg.pre_request();
34249                let mut req_builder = hyper::Request::builder()
34250                    .method(hyper::Method::DELETE)
34251                    .uri(url.as_str())
34252                    .header(USER_AGENT, self.hub._user_agent.clone());
34253
34254                if let Some(token) = token.as_ref() {
34255                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34256                }
34257
34258                let request = req_builder
34259                    .header(CONTENT_LENGTH, 0_u64)
34260                    .body(common::to_body::<String>(None));
34261
34262                client.request(request.unwrap()).await
34263            };
34264
34265            match req_result {
34266                Err(err) => {
34267                    if let common::Retry::After(d) = dlg.http_error(&err) {
34268                        sleep(d).await;
34269                        continue;
34270                    }
34271                    dlg.finished(false);
34272                    return Err(common::Error::HttpError(err));
34273                }
34274                Ok(res) => {
34275                    let (mut parts, body) = res.into_parts();
34276                    let mut body = common::Body::new(body);
34277                    if !parts.status.is_success() {
34278                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34279                        let error = serde_json::from_str(&common::to_string(&bytes));
34280                        let response = common::to_response(parts, bytes.into());
34281
34282                        if let common::Retry::After(d) =
34283                            dlg.http_failure(&response, error.as_ref().ok())
34284                        {
34285                            sleep(d).await;
34286                            continue;
34287                        }
34288
34289                        dlg.finished(false);
34290
34291                        return Err(match error {
34292                            Ok(value) => common::Error::BadRequest(value),
34293                            _ => common::Error::Failure(response),
34294                        });
34295                    }
34296                    let response = common::Response::from_parts(parts, body);
34297
34298                    dlg.finished(true);
34299                    return Ok(response);
34300                }
34301            }
34302        }
34303    }
34304
34305    /// Account ID to delete the user link for.
34306    ///
34307    /// Sets the *account id* path property to the given value.
34308    ///
34309    /// Even though the property as already been set when instantiating this call,
34310    /// we provide this method for API completeness.
34311    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
34312        self._account_id = new_value.to_string();
34313        self
34314    }
34315    /// Web Property ID to delete the user link for.
34316    ///
34317    /// Sets the *web property id* path property to the given value.
34318    ///
34319    /// Even though the property as already been set when instantiating this call,
34320    /// we provide this method for API completeness.
34321    pub fn web_property_id(
34322        mut self,
34323        new_value: &str,
34324    ) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
34325        self._web_property_id = new_value.to_string();
34326        self
34327    }
34328    /// Link ID to delete the user link for.
34329    ///
34330    /// Sets the *link id* path property to the given value.
34331    ///
34332    /// Even though the property as already been set when instantiating this call,
34333    /// we provide this method for API completeness.
34334    pub fn link_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
34335        self._link_id = new_value.to_string();
34336        self
34337    }
34338    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34339    /// while executing the actual API request.
34340    ///
34341    /// ````text
34342    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34343    /// ````
34344    ///
34345    /// Sets the *delegate* property to the given value.
34346    pub fn delegate(
34347        mut self,
34348        new_value: &'a mut dyn common::Delegate,
34349    ) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
34350        self._delegate = Some(new_value);
34351        self
34352    }
34353
34354    /// Set any additional parameter of the query string used in the request.
34355    /// It should be used to set parameters which are not yet available through their own
34356    /// setters.
34357    ///
34358    /// Please note that this method must not be used to set any of the known parameters
34359    /// which have their own setter method. If done anyway, the request will fail.
34360    ///
34361    /// # Additional Parameters
34362    ///
34363    /// * *alt* (query-string) - Data format for the response.
34364    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34365    /// * *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.
34366    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34367    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34368    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34369    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34370    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUserLinkDeleteCall<'a, C>
34371    where
34372        T: AsRef<str>,
34373    {
34374        self._additional_params
34375            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34376        self
34377    }
34378
34379    /// Identifies the authorization scope for the method you are building.
34380    ///
34381    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34382    /// [`Scope::ManageUser`].
34383    ///
34384    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34385    /// tokens for more than one scope.
34386    ///
34387    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34388    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34389    /// sufficient, a read-write scope will do as well.
34390    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUserLinkDeleteCall<'a, C>
34391    where
34392        St: AsRef<str>,
34393    {
34394        self._scopes.insert(String::from(scope.as_ref()));
34395        self
34396    }
34397    /// Identifies the authorization scope(s) for the method you are building.
34398    ///
34399    /// See [`Self::add_scope()`] for details.
34400    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUserLinkDeleteCall<'a, C>
34401    where
34402        I: IntoIterator<Item = St>,
34403        St: AsRef<str>,
34404    {
34405        self._scopes
34406            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34407        self
34408    }
34409
34410    /// Removes all scopes, and no default scope will be used either.
34411    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34412    /// for details).
34413    pub fn clear_scopes(mut self) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
34414        self._scopes.clear();
34415        self
34416    }
34417}
34418
34419/// Adds a new user to the given web property.
34420///
34421/// A builder for the *webpropertyUserLinks.insert* method supported by a *management* resource.
34422/// It is not used directly, but through a [`ManagementMethods`] instance.
34423///
34424/// # Example
34425///
34426/// Instantiate a resource method builder
34427///
34428/// ```test_harness,no_run
34429/// # extern crate hyper;
34430/// # extern crate hyper_rustls;
34431/// # extern crate google_analytics3 as analytics3;
34432/// use analytics3::api::EntityUserLink;
34433/// # async fn dox() {
34434/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34435///
34436/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34437/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34438/// #     .with_native_roots()
34439/// #     .unwrap()
34440/// #     .https_only()
34441/// #     .enable_http2()
34442/// #     .build();
34443///
34444/// # let executor = hyper_util::rt::TokioExecutor::new();
34445/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34446/// #     secret,
34447/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34448/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
34449/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
34450/// #     ),
34451/// # ).build().await.unwrap();
34452///
34453/// # let client = hyper_util::client::legacy::Client::builder(
34454/// #     hyper_util::rt::TokioExecutor::new()
34455/// # )
34456/// # .build(
34457/// #     hyper_rustls::HttpsConnectorBuilder::new()
34458/// #         .with_native_roots()
34459/// #         .unwrap()
34460/// #         .https_or_http()
34461/// #         .enable_http2()
34462/// #         .build()
34463/// # );
34464/// # let mut hub = Analytics::new(client, auth);
34465/// // As the method needs a request, you would usually fill it with the desired information
34466/// // into the respective structure. Some of the parts shown here might not be applicable !
34467/// // Values shown here are possibly random and not representative !
34468/// let mut req = EntityUserLink::default();
34469///
34470/// // You can configure optional parameters by calling the respective setters at will, and
34471/// // execute the final call using `doit()`.
34472/// // Values shown here are possibly random and not representative !
34473/// let result = hub.management().webproperty_user_links_insert(req, "accountId", "webPropertyId")
34474///              .doit().await;
34475/// # }
34476/// ```
34477pub struct ManagementWebpropertyUserLinkInsertCall<'a, C>
34478where
34479    C: 'a,
34480{
34481    hub: &'a Analytics<C>,
34482    _request: EntityUserLink,
34483    _account_id: String,
34484    _web_property_id: String,
34485    _delegate: Option<&'a mut dyn common::Delegate>,
34486    _additional_params: HashMap<String, String>,
34487    _scopes: BTreeSet<String>,
34488}
34489
34490impl<'a, C> common::CallBuilder for ManagementWebpropertyUserLinkInsertCall<'a, C> {}
34491
34492impl<'a, C> ManagementWebpropertyUserLinkInsertCall<'a, C>
34493where
34494    C: common::Connector,
34495{
34496    /// Perform the operation you have build so far.
34497    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
34498        use std::borrow::Cow;
34499        use std::io::{Read, Seek};
34500
34501        use common::{url::Params, ToParts};
34502        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34503
34504        let mut dd = common::DefaultDelegate;
34505        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34506        dlg.begin(common::MethodInfo {
34507            id: "analytics.management.webpropertyUserLinks.insert",
34508            http_method: hyper::Method::POST,
34509        });
34510
34511        for &field in ["alt", "accountId", "webPropertyId"].iter() {
34512            if self._additional_params.contains_key(field) {
34513                dlg.finished(false);
34514                return Err(common::Error::FieldClash(field));
34515            }
34516        }
34517
34518        let mut params = Params::with_capacity(5 + self._additional_params.len());
34519        params.push("accountId", self._account_id);
34520        params.push("webPropertyId", self._web_property_id);
34521
34522        params.extend(self._additional_params.iter());
34523
34524        params.push("alt", "json");
34525        let mut url = self.hub._base_url.clone()
34526            + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks";
34527        if self._scopes.is_empty() {
34528            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
34529        }
34530
34531        #[allow(clippy::single_element_loop)]
34532        for &(find_this, param_name) in [
34533            ("{accountId}", "accountId"),
34534            ("{webPropertyId}", "webPropertyId"),
34535        ]
34536        .iter()
34537        {
34538            url = params.uri_replacement(url, param_name, find_this, false);
34539        }
34540        {
34541            let to_remove = ["webPropertyId", "accountId"];
34542            params.remove_params(&to_remove);
34543        }
34544
34545        let url = params.parse_with_url(&url);
34546
34547        let mut json_mime_type = mime::APPLICATION_JSON;
34548        let mut request_value_reader = {
34549            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
34550            common::remove_json_null_values(&mut value);
34551            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
34552            serde_json::to_writer(&mut dst, &value).unwrap();
34553            dst
34554        };
34555        let request_size = request_value_reader
34556            .seek(std::io::SeekFrom::End(0))
34557            .unwrap();
34558        request_value_reader
34559            .seek(std::io::SeekFrom::Start(0))
34560            .unwrap();
34561
34562        loop {
34563            let token = match self
34564                .hub
34565                .auth
34566                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34567                .await
34568            {
34569                Ok(token) => token,
34570                Err(e) => match dlg.token(e) {
34571                    Ok(token) => token,
34572                    Err(e) => {
34573                        dlg.finished(false);
34574                        return Err(common::Error::MissingToken(e));
34575                    }
34576                },
34577            };
34578            request_value_reader
34579                .seek(std::io::SeekFrom::Start(0))
34580                .unwrap();
34581            let mut req_result = {
34582                let client = &self.hub.client;
34583                dlg.pre_request();
34584                let mut req_builder = hyper::Request::builder()
34585                    .method(hyper::Method::POST)
34586                    .uri(url.as_str())
34587                    .header(USER_AGENT, self.hub._user_agent.clone());
34588
34589                if let Some(token) = token.as_ref() {
34590                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34591                }
34592
34593                let request = req_builder
34594                    .header(CONTENT_TYPE, json_mime_type.to_string())
34595                    .header(CONTENT_LENGTH, request_size as u64)
34596                    .body(common::to_body(
34597                        request_value_reader.get_ref().clone().into(),
34598                    ));
34599
34600                client.request(request.unwrap()).await
34601            };
34602
34603            match req_result {
34604                Err(err) => {
34605                    if let common::Retry::After(d) = dlg.http_error(&err) {
34606                        sleep(d).await;
34607                        continue;
34608                    }
34609                    dlg.finished(false);
34610                    return Err(common::Error::HttpError(err));
34611                }
34612                Ok(res) => {
34613                    let (mut parts, body) = res.into_parts();
34614                    let mut body = common::Body::new(body);
34615                    if !parts.status.is_success() {
34616                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34617                        let error = serde_json::from_str(&common::to_string(&bytes));
34618                        let response = common::to_response(parts, bytes.into());
34619
34620                        if let common::Retry::After(d) =
34621                            dlg.http_failure(&response, error.as_ref().ok())
34622                        {
34623                            sleep(d).await;
34624                            continue;
34625                        }
34626
34627                        dlg.finished(false);
34628
34629                        return Err(match error {
34630                            Ok(value) => common::Error::BadRequest(value),
34631                            _ => common::Error::Failure(response),
34632                        });
34633                    }
34634                    let response = {
34635                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34636                        let encoded = common::to_string(&bytes);
34637                        match serde_json::from_str(&encoded) {
34638                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34639                            Err(error) => {
34640                                dlg.response_json_decode_error(&encoded, &error);
34641                                return Err(common::Error::JsonDecodeError(
34642                                    encoded.to_string(),
34643                                    error,
34644                                ));
34645                            }
34646                        }
34647                    };
34648
34649                    dlg.finished(true);
34650                    return Ok(response);
34651                }
34652            }
34653        }
34654    }
34655
34656    ///
34657    /// Sets the *request* property to the given value.
34658    ///
34659    /// Even though the property as already been set when instantiating this call,
34660    /// we provide this method for API completeness.
34661    pub fn request(
34662        mut self,
34663        new_value: EntityUserLink,
34664    ) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
34665        self._request = new_value;
34666        self
34667    }
34668    /// Account ID to create the user link for.
34669    ///
34670    /// Sets the *account id* path property to the given value.
34671    ///
34672    /// Even though the property as already been set when instantiating this call,
34673    /// we provide this method for API completeness.
34674    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
34675        self._account_id = new_value.to_string();
34676        self
34677    }
34678    /// Web Property ID to create the user link for.
34679    ///
34680    /// Sets the *web property id* path property to the given value.
34681    ///
34682    /// Even though the property as already been set when instantiating this call,
34683    /// we provide this method for API completeness.
34684    pub fn web_property_id(
34685        mut self,
34686        new_value: &str,
34687    ) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
34688        self._web_property_id = new_value.to_string();
34689        self
34690    }
34691    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34692    /// while executing the actual API request.
34693    ///
34694    /// ````text
34695    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34696    /// ````
34697    ///
34698    /// Sets the *delegate* property to the given value.
34699    pub fn delegate(
34700        mut self,
34701        new_value: &'a mut dyn common::Delegate,
34702    ) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
34703        self._delegate = Some(new_value);
34704        self
34705    }
34706
34707    /// Set any additional parameter of the query string used in the request.
34708    /// It should be used to set parameters which are not yet available through their own
34709    /// setters.
34710    ///
34711    /// Please note that this method must not be used to set any of the known parameters
34712    /// which have their own setter method. If done anyway, the request will fail.
34713    ///
34714    /// # Additional Parameters
34715    ///
34716    /// * *alt* (query-string) - Data format for the response.
34717    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34718    /// * *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.
34719    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34720    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34721    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34722    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34723    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUserLinkInsertCall<'a, C>
34724    where
34725        T: AsRef<str>,
34726    {
34727        self._additional_params
34728            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34729        self
34730    }
34731
34732    /// Identifies the authorization scope for the method you are building.
34733    ///
34734    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34735    /// [`Scope::ManageUser`].
34736    ///
34737    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34738    /// tokens for more than one scope.
34739    ///
34740    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34741    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34742    /// sufficient, a read-write scope will do as well.
34743    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUserLinkInsertCall<'a, C>
34744    where
34745        St: AsRef<str>,
34746    {
34747        self._scopes.insert(String::from(scope.as_ref()));
34748        self
34749    }
34750    /// Identifies the authorization scope(s) for the method you are building.
34751    ///
34752    /// See [`Self::add_scope()`] for details.
34753    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUserLinkInsertCall<'a, C>
34754    where
34755        I: IntoIterator<Item = St>,
34756        St: AsRef<str>,
34757    {
34758        self._scopes
34759            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34760        self
34761    }
34762
34763    /// Removes all scopes, and no default scope will be used either.
34764    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34765    /// for details).
34766    pub fn clear_scopes(mut self) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
34767        self._scopes.clear();
34768        self
34769    }
34770}
34771
34772/// Lists webProperty-user links for a given web property.
34773///
34774/// A builder for the *webpropertyUserLinks.list* method supported by a *management* resource.
34775/// It is not used directly, but through a [`ManagementMethods`] instance.
34776///
34777/// # Example
34778///
34779/// Instantiate a resource method builder
34780///
34781/// ```test_harness,no_run
34782/// # extern crate hyper;
34783/// # extern crate hyper_rustls;
34784/// # extern crate google_analytics3 as analytics3;
34785/// # async fn dox() {
34786/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34787///
34788/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34789/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34790/// #     .with_native_roots()
34791/// #     .unwrap()
34792/// #     .https_only()
34793/// #     .enable_http2()
34794/// #     .build();
34795///
34796/// # let executor = hyper_util::rt::TokioExecutor::new();
34797/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34798/// #     secret,
34799/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34800/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
34801/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
34802/// #     ),
34803/// # ).build().await.unwrap();
34804///
34805/// # let client = hyper_util::client::legacy::Client::builder(
34806/// #     hyper_util::rt::TokioExecutor::new()
34807/// # )
34808/// # .build(
34809/// #     hyper_rustls::HttpsConnectorBuilder::new()
34810/// #         .with_native_roots()
34811/// #         .unwrap()
34812/// #         .https_or_http()
34813/// #         .enable_http2()
34814/// #         .build()
34815/// # );
34816/// # let mut hub = Analytics::new(client, auth);
34817/// // You can configure optional parameters by calling the respective setters at will, and
34818/// // execute the final call using `doit()`.
34819/// // Values shown here are possibly random and not representative !
34820/// let result = hub.management().webproperty_user_links_list("accountId", "webPropertyId")
34821///              .start_index(-100)
34822///              .max_results(-63)
34823///              .doit().await;
34824/// # }
34825/// ```
34826pub struct ManagementWebpropertyUserLinkListCall<'a, C>
34827where
34828    C: 'a,
34829{
34830    hub: &'a Analytics<C>,
34831    _account_id: String,
34832    _web_property_id: String,
34833    _start_index: Option<i32>,
34834    _max_results: Option<i32>,
34835    _delegate: Option<&'a mut dyn common::Delegate>,
34836    _additional_params: HashMap<String, String>,
34837    _scopes: BTreeSet<String>,
34838}
34839
34840impl<'a, C> common::CallBuilder for ManagementWebpropertyUserLinkListCall<'a, C> {}
34841
34842impl<'a, C> ManagementWebpropertyUserLinkListCall<'a, C>
34843where
34844    C: common::Connector,
34845{
34846    /// Perform the operation you have build so far.
34847    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLinks)> {
34848        use std::borrow::Cow;
34849        use std::io::{Read, Seek};
34850
34851        use common::{url::Params, ToParts};
34852        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34853
34854        let mut dd = common::DefaultDelegate;
34855        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34856        dlg.begin(common::MethodInfo {
34857            id: "analytics.management.webpropertyUserLinks.list",
34858            http_method: hyper::Method::GET,
34859        });
34860
34861        for &field in [
34862            "alt",
34863            "accountId",
34864            "webPropertyId",
34865            "start-index",
34866            "max-results",
34867        ]
34868        .iter()
34869        {
34870            if self._additional_params.contains_key(field) {
34871                dlg.finished(false);
34872                return Err(common::Error::FieldClash(field));
34873            }
34874        }
34875
34876        let mut params = Params::with_capacity(6 + self._additional_params.len());
34877        params.push("accountId", self._account_id);
34878        params.push("webPropertyId", self._web_property_id);
34879        if let Some(value) = self._start_index.as_ref() {
34880            params.push("start-index", value.to_string());
34881        }
34882        if let Some(value) = self._max_results.as_ref() {
34883            params.push("max-results", value.to_string());
34884        }
34885
34886        params.extend(self._additional_params.iter());
34887
34888        params.push("alt", "json");
34889        let mut url = self.hub._base_url.clone()
34890            + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks";
34891        if self._scopes.is_empty() {
34892            self._scopes
34893                .insert(Scope::ManageUserReadonly.as_ref().to_string());
34894        }
34895
34896        #[allow(clippy::single_element_loop)]
34897        for &(find_this, param_name) in [
34898            ("{accountId}", "accountId"),
34899            ("{webPropertyId}", "webPropertyId"),
34900        ]
34901        .iter()
34902        {
34903            url = params.uri_replacement(url, param_name, find_this, false);
34904        }
34905        {
34906            let to_remove = ["webPropertyId", "accountId"];
34907            params.remove_params(&to_remove);
34908        }
34909
34910        let url = params.parse_with_url(&url);
34911
34912        loop {
34913            let token = match self
34914                .hub
34915                .auth
34916                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34917                .await
34918            {
34919                Ok(token) => token,
34920                Err(e) => match dlg.token(e) {
34921                    Ok(token) => token,
34922                    Err(e) => {
34923                        dlg.finished(false);
34924                        return Err(common::Error::MissingToken(e));
34925                    }
34926                },
34927            };
34928            let mut req_result = {
34929                let client = &self.hub.client;
34930                dlg.pre_request();
34931                let mut req_builder = hyper::Request::builder()
34932                    .method(hyper::Method::GET)
34933                    .uri(url.as_str())
34934                    .header(USER_AGENT, self.hub._user_agent.clone());
34935
34936                if let Some(token) = token.as_ref() {
34937                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34938                }
34939
34940                let request = req_builder
34941                    .header(CONTENT_LENGTH, 0_u64)
34942                    .body(common::to_body::<String>(None));
34943
34944                client.request(request.unwrap()).await
34945            };
34946
34947            match req_result {
34948                Err(err) => {
34949                    if let common::Retry::After(d) = dlg.http_error(&err) {
34950                        sleep(d).await;
34951                        continue;
34952                    }
34953                    dlg.finished(false);
34954                    return Err(common::Error::HttpError(err));
34955                }
34956                Ok(res) => {
34957                    let (mut parts, body) = res.into_parts();
34958                    let mut body = common::Body::new(body);
34959                    if !parts.status.is_success() {
34960                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34961                        let error = serde_json::from_str(&common::to_string(&bytes));
34962                        let response = common::to_response(parts, bytes.into());
34963
34964                        if let common::Retry::After(d) =
34965                            dlg.http_failure(&response, error.as_ref().ok())
34966                        {
34967                            sleep(d).await;
34968                            continue;
34969                        }
34970
34971                        dlg.finished(false);
34972
34973                        return Err(match error {
34974                            Ok(value) => common::Error::BadRequest(value),
34975                            _ => common::Error::Failure(response),
34976                        });
34977                    }
34978                    let response = {
34979                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34980                        let encoded = common::to_string(&bytes);
34981                        match serde_json::from_str(&encoded) {
34982                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34983                            Err(error) => {
34984                                dlg.response_json_decode_error(&encoded, &error);
34985                                return Err(common::Error::JsonDecodeError(
34986                                    encoded.to_string(),
34987                                    error,
34988                                ));
34989                            }
34990                        }
34991                    };
34992
34993                    dlg.finished(true);
34994                    return Ok(response);
34995                }
34996            }
34997        }
34998    }
34999
35000    /// Account ID which the given web property belongs to.
35001    ///
35002    /// Sets the *account id* path property to the given value.
35003    ///
35004    /// Even though the property as already been set when instantiating this call,
35005    /// we provide this method for API completeness.
35006    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkListCall<'a, C> {
35007        self._account_id = new_value.to_string();
35008        self
35009    }
35010    /// Web Property ID for the webProperty-user links to retrieve. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.
35011    ///
35012    /// Sets the *web property id* path property to the given value.
35013    ///
35014    /// Even though the property as already been set when instantiating this call,
35015    /// we provide this method for API completeness.
35016    pub fn web_property_id(
35017        mut self,
35018        new_value: &str,
35019    ) -> ManagementWebpropertyUserLinkListCall<'a, C> {
35020        self._web_property_id = new_value.to_string();
35021        self
35022    }
35023    /// An index of the first webProperty-user link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
35024    ///
35025    /// Sets the *start-index* query property to the given value.
35026    pub fn start_index(mut self, new_value: i32) -> ManagementWebpropertyUserLinkListCall<'a, C> {
35027        self._start_index = Some(new_value);
35028        self
35029    }
35030    /// The maximum number of webProperty-user Links to include in this response.
35031    ///
35032    /// Sets the *max-results* query property to the given value.
35033    pub fn max_results(mut self, new_value: i32) -> ManagementWebpropertyUserLinkListCall<'a, C> {
35034        self._max_results = Some(new_value);
35035        self
35036    }
35037    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35038    /// while executing the actual API request.
35039    ///
35040    /// ````text
35041    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35042    /// ````
35043    ///
35044    /// Sets the *delegate* property to the given value.
35045    pub fn delegate(
35046        mut self,
35047        new_value: &'a mut dyn common::Delegate,
35048    ) -> ManagementWebpropertyUserLinkListCall<'a, C> {
35049        self._delegate = Some(new_value);
35050        self
35051    }
35052
35053    /// Set any additional parameter of the query string used in the request.
35054    /// It should be used to set parameters which are not yet available through their own
35055    /// setters.
35056    ///
35057    /// Please note that this method must not be used to set any of the known parameters
35058    /// which have their own setter method. If done anyway, the request will fail.
35059    ///
35060    /// # Additional Parameters
35061    ///
35062    /// * *alt* (query-string) - Data format for the response.
35063    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35064    /// * *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.
35065    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35066    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35067    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35068    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35069    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUserLinkListCall<'a, C>
35070    where
35071        T: AsRef<str>,
35072    {
35073        self._additional_params
35074            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35075        self
35076    }
35077
35078    /// Identifies the authorization scope for the method you are building.
35079    ///
35080    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35081    /// [`Scope::ManageUserReadonly`].
35082    ///
35083    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35084    /// tokens for more than one scope.
35085    ///
35086    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35087    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35088    /// sufficient, a read-write scope will do as well.
35089    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUserLinkListCall<'a, C>
35090    where
35091        St: AsRef<str>,
35092    {
35093        self._scopes.insert(String::from(scope.as_ref()));
35094        self
35095    }
35096    /// Identifies the authorization scope(s) for the method you are building.
35097    ///
35098    /// See [`Self::add_scope()`] for details.
35099    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUserLinkListCall<'a, C>
35100    where
35101        I: IntoIterator<Item = St>,
35102        St: AsRef<str>,
35103    {
35104        self._scopes
35105            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35106        self
35107    }
35108
35109    /// Removes all scopes, and no default scope will be used either.
35110    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35111    /// for details).
35112    pub fn clear_scopes(mut self) -> ManagementWebpropertyUserLinkListCall<'a, C> {
35113        self._scopes.clear();
35114        self
35115    }
35116}
35117
35118/// Updates permissions for an existing user on the given web property.
35119///
35120/// A builder for the *webpropertyUserLinks.update* method supported by a *management* resource.
35121/// It is not used directly, but through a [`ManagementMethods`] instance.
35122///
35123/// # Example
35124///
35125/// Instantiate a resource method builder
35126///
35127/// ```test_harness,no_run
35128/// # extern crate hyper;
35129/// # extern crate hyper_rustls;
35130/// # extern crate google_analytics3 as analytics3;
35131/// use analytics3::api::EntityUserLink;
35132/// # async fn dox() {
35133/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35134///
35135/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35136/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35137/// #     .with_native_roots()
35138/// #     .unwrap()
35139/// #     .https_only()
35140/// #     .enable_http2()
35141/// #     .build();
35142///
35143/// # let executor = hyper_util::rt::TokioExecutor::new();
35144/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35145/// #     secret,
35146/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35147/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
35148/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
35149/// #     ),
35150/// # ).build().await.unwrap();
35151///
35152/// # let client = hyper_util::client::legacy::Client::builder(
35153/// #     hyper_util::rt::TokioExecutor::new()
35154/// # )
35155/// # .build(
35156/// #     hyper_rustls::HttpsConnectorBuilder::new()
35157/// #         .with_native_roots()
35158/// #         .unwrap()
35159/// #         .https_or_http()
35160/// #         .enable_http2()
35161/// #         .build()
35162/// # );
35163/// # let mut hub = Analytics::new(client, auth);
35164/// // As the method needs a request, you would usually fill it with the desired information
35165/// // into the respective structure. Some of the parts shown here might not be applicable !
35166/// // Values shown here are possibly random and not representative !
35167/// let mut req = EntityUserLink::default();
35168///
35169/// // You can configure optional parameters by calling the respective setters at will, and
35170/// // execute the final call using `doit()`.
35171/// // Values shown here are possibly random and not representative !
35172/// let result = hub.management().webproperty_user_links_update(req, "accountId", "webPropertyId", "linkId")
35173///              .doit().await;
35174/// # }
35175/// ```
35176pub struct ManagementWebpropertyUserLinkUpdateCall<'a, C>
35177where
35178    C: 'a,
35179{
35180    hub: &'a Analytics<C>,
35181    _request: EntityUserLink,
35182    _account_id: String,
35183    _web_property_id: String,
35184    _link_id: String,
35185    _delegate: Option<&'a mut dyn common::Delegate>,
35186    _additional_params: HashMap<String, String>,
35187    _scopes: BTreeSet<String>,
35188}
35189
35190impl<'a, C> common::CallBuilder for ManagementWebpropertyUserLinkUpdateCall<'a, C> {}
35191
35192impl<'a, C> ManagementWebpropertyUserLinkUpdateCall<'a, C>
35193where
35194    C: common::Connector,
35195{
35196    /// Perform the operation you have build so far.
35197    pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
35198        use std::borrow::Cow;
35199        use std::io::{Read, Seek};
35200
35201        use common::{url::Params, ToParts};
35202        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35203
35204        let mut dd = common::DefaultDelegate;
35205        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35206        dlg.begin(common::MethodInfo {
35207            id: "analytics.management.webpropertyUserLinks.update",
35208            http_method: hyper::Method::PUT,
35209        });
35210
35211        for &field in ["alt", "accountId", "webPropertyId", "linkId"].iter() {
35212            if self._additional_params.contains_key(field) {
35213                dlg.finished(false);
35214                return Err(common::Error::FieldClash(field));
35215            }
35216        }
35217
35218        let mut params = Params::with_capacity(6 + self._additional_params.len());
35219        params.push("accountId", self._account_id);
35220        params.push("webPropertyId", self._web_property_id);
35221        params.push("linkId", self._link_id);
35222
35223        params.extend(self._additional_params.iter());
35224
35225        params.push("alt", "json");
35226        let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks/{linkId}";
35227        if self._scopes.is_empty() {
35228            self._scopes.insert(Scope::ManageUser.as_ref().to_string());
35229        }
35230
35231        #[allow(clippy::single_element_loop)]
35232        for &(find_this, param_name) in [
35233            ("{accountId}", "accountId"),
35234            ("{webPropertyId}", "webPropertyId"),
35235            ("{linkId}", "linkId"),
35236        ]
35237        .iter()
35238        {
35239            url = params.uri_replacement(url, param_name, find_this, false);
35240        }
35241        {
35242            let to_remove = ["linkId", "webPropertyId", "accountId"];
35243            params.remove_params(&to_remove);
35244        }
35245
35246        let url = params.parse_with_url(&url);
35247
35248        let mut json_mime_type = mime::APPLICATION_JSON;
35249        let mut request_value_reader = {
35250            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
35251            common::remove_json_null_values(&mut value);
35252            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
35253            serde_json::to_writer(&mut dst, &value).unwrap();
35254            dst
35255        };
35256        let request_size = request_value_reader
35257            .seek(std::io::SeekFrom::End(0))
35258            .unwrap();
35259        request_value_reader
35260            .seek(std::io::SeekFrom::Start(0))
35261            .unwrap();
35262
35263        loop {
35264            let token = match self
35265                .hub
35266                .auth
35267                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35268                .await
35269            {
35270                Ok(token) => token,
35271                Err(e) => match dlg.token(e) {
35272                    Ok(token) => token,
35273                    Err(e) => {
35274                        dlg.finished(false);
35275                        return Err(common::Error::MissingToken(e));
35276                    }
35277                },
35278            };
35279            request_value_reader
35280                .seek(std::io::SeekFrom::Start(0))
35281                .unwrap();
35282            let mut req_result = {
35283                let client = &self.hub.client;
35284                dlg.pre_request();
35285                let mut req_builder = hyper::Request::builder()
35286                    .method(hyper::Method::PUT)
35287                    .uri(url.as_str())
35288                    .header(USER_AGENT, self.hub._user_agent.clone());
35289
35290                if let Some(token) = token.as_ref() {
35291                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35292                }
35293
35294                let request = req_builder
35295                    .header(CONTENT_TYPE, json_mime_type.to_string())
35296                    .header(CONTENT_LENGTH, request_size as u64)
35297                    .body(common::to_body(
35298                        request_value_reader.get_ref().clone().into(),
35299                    ));
35300
35301                client.request(request.unwrap()).await
35302            };
35303
35304            match req_result {
35305                Err(err) => {
35306                    if let common::Retry::After(d) = dlg.http_error(&err) {
35307                        sleep(d).await;
35308                        continue;
35309                    }
35310                    dlg.finished(false);
35311                    return Err(common::Error::HttpError(err));
35312                }
35313                Ok(res) => {
35314                    let (mut parts, body) = res.into_parts();
35315                    let mut body = common::Body::new(body);
35316                    if !parts.status.is_success() {
35317                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35318                        let error = serde_json::from_str(&common::to_string(&bytes));
35319                        let response = common::to_response(parts, bytes.into());
35320
35321                        if let common::Retry::After(d) =
35322                            dlg.http_failure(&response, error.as_ref().ok())
35323                        {
35324                            sleep(d).await;
35325                            continue;
35326                        }
35327
35328                        dlg.finished(false);
35329
35330                        return Err(match error {
35331                            Ok(value) => common::Error::BadRequest(value),
35332                            _ => common::Error::Failure(response),
35333                        });
35334                    }
35335                    let response = {
35336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35337                        let encoded = common::to_string(&bytes);
35338                        match serde_json::from_str(&encoded) {
35339                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35340                            Err(error) => {
35341                                dlg.response_json_decode_error(&encoded, &error);
35342                                return Err(common::Error::JsonDecodeError(
35343                                    encoded.to_string(),
35344                                    error,
35345                                ));
35346                            }
35347                        }
35348                    };
35349
35350                    dlg.finished(true);
35351                    return Ok(response);
35352                }
35353            }
35354        }
35355    }
35356
35357    ///
35358    /// Sets the *request* property to the given value.
35359    ///
35360    /// Even though the property as already been set when instantiating this call,
35361    /// we provide this method for API completeness.
35362    pub fn request(
35363        mut self,
35364        new_value: EntityUserLink,
35365    ) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
35366        self._request = new_value;
35367        self
35368    }
35369    /// Account ID to update the account-user link for.
35370    ///
35371    /// Sets the *account id* path property to the given value.
35372    ///
35373    /// Even though the property as already been set when instantiating this call,
35374    /// we provide this method for API completeness.
35375    pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
35376        self._account_id = new_value.to_string();
35377        self
35378    }
35379    /// Web property ID to update the account-user link for.
35380    ///
35381    /// Sets the *web property id* path property to the given value.
35382    ///
35383    /// Even though the property as already been set when instantiating this call,
35384    /// we provide this method for API completeness.
35385    pub fn web_property_id(
35386        mut self,
35387        new_value: &str,
35388    ) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
35389        self._web_property_id = new_value.to_string();
35390        self
35391    }
35392    /// Link ID to update the account-user link for.
35393    ///
35394    /// Sets the *link id* path property to the given value.
35395    ///
35396    /// Even though the property as already been set when instantiating this call,
35397    /// we provide this method for API completeness.
35398    pub fn link_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
35399        self._link_id = new_value.to_string();
35400        self
35401    }
35402    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35403    /// while executing the actual API request.
35404    ///
35405    /// ````text
35406    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35407    /// ````
35408    ///
35409    /// Sets the *delegate* property to the given value.
35410    pub fn delegate(
35411        mut self,
35412        new_value: &'a mut dyn common::Delegate,
35413    ) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
35414        self._delegate = Some(new_value);
35415        self
35416    }
35417
35418    /// Set any additional parameter of the query string used in the request.
35419    /// It should be used to set parameters which are not yet available through their own
35420    /// setters.
35421    ///
35422    /// Please note that this method must not be used to set any of the known parameters
35423    /// which have their own setter method. If done anyway, the request will fail.
35424    ///
35425    /// # Additional Parameters
35426    ///
35427    /// * *alt* (query-string) - Data format for the response.
35428    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35429    /// * *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.
35430    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35431    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35432    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35433    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35434    pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUserLinkUpdateCall<'a, C>
35435    where
35436        T: AsRef<str>,
35437    {
35438        self._additional_params
35439            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35440        self
35441    }
35442
35443    /// Identifies the authorization scope for the method you are building.
35444    ///
35445    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35446    /// [`Scope::ManageUser`].
35447    ///
35448    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35449    /// tokens for more than one scope.
35450    ///
35451    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35452    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35453    /// sufficient, a read-write scope will do as well.
35454    pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUserLinkUpdateCall<'a, C>
35455    where
35456        St: AsRef<str>,
35457    {
35458        self._scopes.insert(String::from(scope.as_ref()));
35459        self
35460    }
35461    /// Identifies the authorization scope(s) for the method you are building.
35462    ///
35463    /// See [`Self::add_scope()`] for details.
35464    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUserLinkUpdateCall<'a, C>
35465    where
35466        I: IntoIterator<Item = St>,
35467        St: AsRef<str>,
35468    {
35469        self._scopes
35470            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35471        self
35472    }
35473
35474    /// Removes all scopes, and no default scope will be used either.
35475    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35476    /// for details).
35477    pub fn clear_scopes(mut self) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
35478        self._scopes.clear();
35479        self
35480    }
35481}
35482
35483/// Lists all columns for a report type
35484///
35485/// A builder for the *columns.list* method supported by a *metadata* resource.
35486/// It is not used directly, but through a [`MetadataMethods`] instance.
35487///
35488/// # Example
35489///
35490/// Instantiate a resource method builder
35491///
35492/// ```test_harness,no_run
35493/// # extern crate hyper;
35494/// # extern crate hyper_rustls;
35495/// # extern crate google_analytics3 as analytics3;
35496/// # async fn dox() {
35497/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35498///
35499/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35500/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35501/// #     .with_native_roots()
35502/// #     .unwrap()
35503/// #     .https_only()
35504/// #     .enable_http2()
35505/// #     .build();
35506///
35507/// # let executor = hyper_util::rt::TokioExecutor::new();
35508/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35509/// #     secret,
35510/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35511/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
35512/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
35513/// #     ),
35514/// # ).build().await.unwrap();
35515///
35516/// # let client = hyper_util::client::legacy::Client::builder(
35517/// #     hyper_util::rt::TokioExecutor::new()
35518/// # )
35519/// # .build(
35520/// #     hyper_rustls::HttpsConnectorBuilder::new()
35521/// #         .with_native_roots()
35522/// #         .unwrap()
35523/// #         .https_or_http()
35524/// #         .enable_http2()
35525/// #         .build()
35526/// # );
35527/// # let mut hub = Analytics::new(client, auth);
35528/// // You can configure optional parameters by calling the respective setters at will, and
35529/// // execute the final call using `doit()`.
35530/// // Values shown here are possibly random and not representative !
35531/// let result = hub.metadata().columns_list("reportType")
35532///              .doit().await;
35533/// # }
35534/// ```
35535pub struct MetadataColumnListCall<'a, C>
35536where
35537    C: 'a,
35538{
35539    hub: &'a Analytics<C>,
35540    _report_type: String,
35541    _delegate: Option<&'a mut dyn common::Delegate>,
35542    _additional_params: HashMap<String, String>,
35543    _scopes: BTreeSet<String>,
35544}
35545
35546impl<'a, C> common::CallBuilder for MetadataColumnListCall<'a, C> {}
35547
35548impl<'a, C> MetadataColumnListCall<'a, C>
35549where
35550    C: common::Connector,
35551{
35552    /// Perform the operation you have build so far.
35553    pub async fn doit(mut self) -> common::Result<(common::Response, Columns)> {
35554        use std::borrow::Cow;
35555        use std::io::{Read, Seek};
35556
35557        use common::{url::Params, ToParts};
35558        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35559
35560        let mut dd = common::DefaultDelegate;
35561        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35562        dlg.begin(common::MethodInfo {
35563            id: "analytics.metadata.columns.list",
35564            http_method: hyper::Method::GET,
35565        });
35566
35567        for &field in ["alt", "reportType"].iter() {
35568            if self._additional_params.contains_key(field) {
35569                dlg.finished(false);
35570                return Err(common::Error::FieldClash(field));
35571            }
35572        }
35573
35574        let mut params = Params::with_capacity(3 + self._additional_params.len());
35575        params.push("reportType", self._report_type);
35576
35577        params.extend(self._additional_params.iter());
35578
35579        params.push("alt", "json");
35580        let mut url = self.hub._base_url.clone() + "metadata/{reportType}/columns";
35581        if self._scopes.is_empty() {
35582            self._scopes.insert(Scope::Readonly.as_ref().to_string());
35583        }
35584
35585        #[allow(clippy::single_element_loop)]
35586        for &(find_this, param_name) in [("{reportType}", "reportType")].iter() {
35587            url = params.uri_replacement(url, param_name, find_this, false);
35588        }
35589        {
35590            let to_remove = ["reportType"];
35591            params.remove_params(&to_remove);
35592        }
35593
35594        let url = params.parse_with_url(&url);
35595
35596        loop {
35597            let token = match self
35598                .hub
35599                .auth
35600                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35601                .await
35602            {
35603                Ok(token) => token,
35604                Err(e) => match dlg.token(e) {
35605                    Ok(token) => token,
35606                    Err(e) => {
35607                        dlg.finished(false);
35608                        return Err(common::Error::MissingToken(e));
35609                    }
35610                },
35611            };
35612            let mut req_result = {
35613                let client = &self.hub.client;
35614                dlg.pre_request();
35615                let mut req_builder = hyper::Request::builder()
35616                    .method(hyper::Method::GET)
35617                    .uri(url.as_str())
35618                    .header(USER_AGENT, self.hub._user_agent.clone());
35619
35620                if let Some(token) = token.as_ref() {
35621                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35622                }
35623
35624                let request = req_builder
35625                    .header(CONTENT_LENGTH, 0_u64)
35626                    .body(common::to_body::<String>(None));
35627
35628                client.request(request.unwrap()).await
35629            };
35630
35631            match req_result {
35632                Err(err) => {
35633                    if let common::Retry::After(d) = dlg.http_error(&err) {
35634                        sleep(d).await;
35635                        continue;
35636                    }
35637                    dlg.finished(false);
35638                    return Err(common::Error::HttpError(err));
35639                }
35640                Ok(res) => {
35641                    let (mut parts, body) = res.into_parts();
35642                    let mut body = common::Body::new(body);
35643                    if !parts.status.is_success() {
35644                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35645                        let error = serde_json::from_str(&common::to_string(&bytes));
35646                        let response = common::to_response(parts, bytes.into());
35647
35648                        if let common::Retry::After(d) =
35649                            dlg.http_failure(&response, error.as_ref().ok())
35650                        {
35651                            sleep(d).await;
35652                            continue;
35653                        }
35654
35655                        dlg.finished(false);
35656
35657                        return Err(match error {
35658                            Ok(value) => common::Error::BadRequest(value),
35659                            _ => common::Error::Failure(response),
35660                        });
35661                    }
35662                    let response = {
35663                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35664                        let encoded = common::to_string(&bytes);
35665                        match serde_json::from_str(&encoded) {
35666                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35667                            Err(error) => {
35668                                dlg.response_json_decode_error(&encoded, &error);
35669                                return Err(common::Error::JsonDecodeError(
35670                                    encoded.to_string(),
35671                                    error,
35672                                ));
35673                            }
35674                        }
35675                    };
35676
35677                    dlg.finished(true);
35678                    return Ok(response);
35679                }
35680            }
35681        }
35682    }
35683
35684    /// Report type. Allowed Values: 'ga'. Where 'ga' corresponds to the Core Reporting API
35685    ///
35686    /// Sets the *report type* path property to the given value.
35687    ///
35688    /// Even though the property as already been set when instantiating this call,
35689    /// we provide this method for API completeness.
35690    pub fn report_type(mut self, new_value: &str) -> MetadataColumnListCall<'a, C> {
35691        self._report_type = new_value.to_string();
35692        self
35693    }
35694    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35695    /// while executing the actual API request.
35696    ///
35697    /// ````text
35698    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35699    /// ````
35700    ///
35701    /// Sets the *delegate* property to the given value.
35702    pub fn delegate(
35703        mut self,
35704        new_value: &'a mut dyn common::Delegate,
35705    ) -> MetadataColumnListCall<'a, C> {
35706        self._delegate = Some(new_value);
35707        self
35708    }
35709
35710    /// Set any additional parameter of the query string used in the request.
35711    /// It should be used to set parameters which are not yet available through their own
35712    /// setters.
35713    ///
35714    /// Please note that this method must not be used to set any of the known parameters
35715    /// which have their own setter method. If done anyway, the request will fail.
35716    ///
35717    /// # Additional Parameters
35718    ///
35719    /// * *alt* (query-string) - Data format for the response.
35720    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35721    /// * *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.
35722    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35723    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35724    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35725    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35726    pub fn param<T>(mut self, name: T, value: T) -> MetadataColumnListCall<'a, C>
35727    where
35728        T: AsRef<str>,
35729    {
35730        self._additional_params
35731            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35732        self
35733    }
35734
35735    /// Identifies the authorization scope for the method you are building.
35736    ///
35737    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35738    /// [`Scope::Readonly`].
35739    ///
35740    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35741    /// tokens for more than one scope.
35742    ///
35743    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35744    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35745    /// sufficient, a read-write scope will do as well.
35746    pub fn add_scope<St>(mut self, scope: St) -> MetadataColumnListCall<'a, C>
35747    where
35748        St: AsRef<str>,
35749    {
35750        self._scopes.insert(String::from(scope.as_ref()));
35751        self
35752    }
35753    /// Identifies the authorization scope(s) for the method you are building.
35754    ///
35755    /// See [`Self::add_scope()`] for details.
35756    pub fn add_scopes<I, St>(mut self, scopes: I) -> MetadataColumnListCall<'a, C>
35757    where
35758        I: IntoIterator<Item = St>,
35759        St: AsRef<str>,
35760    {
35761        self._scopes
35762            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35763        self
35764    }
35765
35766    /// Removes all scopes, and no default scope will be used either.
35767    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35768    /// for details).
35769    pub fn clear_scopes(mut self) -> MetadataColumnListCall<'a, C> {
35770        self._scopes.clear();
35771        self
35772    }
35773}
35774
35775/// Creates an account ticket.
35776///
35777/// A builder for the *createAccountTicket* method supported by a *provisioning* resource.
35778/// It is not used directly, but through a [`ProvisioningMethods`] instance.
35779///
35780/// # Example
35781///
35782/// Instantiate a resource method builder
35783///
35784/// ```test_harness,no_run
35785/// # extern crate hyper;
35786/// # extern crate hyper_rustls;
35787/// # extern crate google_analytics3 as analytics3;
35788/// use analytics3::api::AccountTicket;
35789/// # async fn dox() {
35790/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35791///
35792/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35793/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35794/// #     .with_native_roots()
35795/// #     .unwrap()
35796/// #     .https_only()
35797/// #     .enable_http2()
35798/// #     .build();
35799///
35800/// # let executor = hyper_util::rt::TokioExecutor::new();
35801/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35802/// #     secret,
35803/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35804/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
35805/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
35806/// #     ),
35807/// # ).build().await.unwrap();
35808///
35809/// # let client = hyper_util::client::legacy::Client::builder(
35810/// #     hyper_util::rt::TokioExecutor::new()
35811/// # )
35812/// # .build(
35813/// #     hyper_rustls::HttpsConnectorBuilder::new()
35814/// #         .with_native_roots()
35815/// #         .unwrap()
35816/// #         .https_or_http()
35817/// #         .enable_http2()
35818/// #         .build()
35819/// # );
35820/// # let mut hub = Analytics::new(client, auth);
35821/// // As the method needs a request, you would usually fill it with the desired information
35822/// // into the respective structure. Some of the parts shown here might not be applicable !
35823/// // Values shown here are possibly random and not representative !
35824/// let mut req = AccountTicket::default();
35825///
35826/// // You can configure optional parameters by calling the respective setters at will, and
35827/// // execute the final call using `doit()`.
35828/// // Values shown here are possibly random and not representative !
35829/// let result = hub.provisioning().create_account_ticket(req)
35830///              .doit().await;
35831/// # }
35832/// ```
35833pub struct ProvisioningCreateAccountTicketCall<'a, C>
35834where
35835    C: 'a,
35836{
35837    hub: &'a Analytics<C>,
35838    _request: AccountTicket,
35839    _delegate: Option<&'a mut dyn common::Delegate>,
35840    _additional_params: HashMap<String, String>,
35841    _scopes: BTreeSet<String>,
35842}
35843
35844impl<'a, C> common::CallBuilder for ProvisioningCreateAccountTicketCall<'a, C> {}
35845
35846impl<'a, C> ProvisioningCreateAccountTicketCall<'a, C>
35847where
35848    C: common::Connector,
35849{
35850    /// Perform the operation you have build so far.
35851    pub async fn doit(mut self) -> common::Result<(common::Response, AccountTicket)> {
35852        use std::borrow::Cow;
35853        use std::io::{Read, Seek};
35854
35855        use common::{url::Params, ToParts};
35856        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35857
35858        let mut dd = common::DefaultDelegate;
35859        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35860        dlg.begin(common::MethodInfo {
35861            id: "analytics.provisioning.createAccountTicket",
35862            http_method: hyper::Method::POST,
35863        });
35864
35865        for &field in ["alt"].iter() {
35866            if self._additional_params.contains_key(field) {
35867                dlg.finished(false);
35868                return Err(common::Error::FieldClash(field));
35869            }
35870        }
35871
35872        let mut params = Params::with_capacity(3 + self._additional_params.len());
35873
35874        params.extend(self._additional_params.iter());
35875
35876        params.push("alt", "json");
35877        let mut url = self.hub._base_url.clone() + "provisioning/createAccountTicket";
35878        if self._scopes.is_empty() {
35879            self._scopes.insert(Scope::Provision.as_ref().to_string());
35880        }
35881
35882        let url = params.parse_with_url(&url);
35883
35884        let mut json_mime_type = mime::APPLICATION_JSON;
35885        let mut request_value_reader = {
35886            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
35887            common::remove_json_null_values(&mut value);
35888            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
35889            serde_json::to_writer(&mut dst, &value).unwrap();
35890            dst
35891        };
35892        let request_size = request_value_reader
35893            .seek(std::io::SeekFrom::End(0))
35894            .unwrap();
35895        request_value_reader
35896            .seek(std::io::SeekFrom::Start(0))
35897            .unwrap();
35898
35899        loop {
35900            let token = match self
35901                .hub
35902                .auth
35903                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35904                .await
35905            {
35906                Ok(token) => token,
35907                Err(e) => match dlg.token(e) {
35908                    Ok(token) => token,
35909                    Err(e) => {
35910                        dlg.finished(false);
35911                        return Err(common::Error::MissingToken(e));
35912                    }
35913                },
35914            };
35915            request_value_reader
35916                .seek(std::io::SeekFrom::Start(0))
35917                .unwrap();
35918            let mut req_result = {
35919                let client = &self.hub.client;
35920                dlg.pre_request();
35921                let mut req_builder = hyper::Request::builder()
35922                    .method(hyper::Method::POST)
35923                    .uri(url.as_str())
35924                    .header(USER_AGENT, self.hub._user_agent.clone());
35925
35926                if let Some(token) = token.as_ref() {
35927                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35928                }
35929
35930                let request = req_builder
35931                    .header(CONTENT_TYPE, json_mime_type.to_string())
35932                    .header(CONTENT_LENGTH, request_size as u64)
35933                    .body(common::to_body(
35934                        request_value_reader.get_ref().clone().into(),
35935                    ));
35936
35937                client.request(request.unwrap()).await
35938            };
35939
35940            match req_result {
35941                Err(err) => {
35942                    if let common::Retry::After(d) = dlg.http_error(&err) {
35943                        sleep(d).await;
35944                        continue;
35945                    }
35946                    dlg.finished(false);
35947                    return Err(common::Error::HttpError(err));
35948                }
35949                Ok(res) => {
35950                    let (mut parts, body) = res.into_parts();
35951                    let mut body = common::Body::new(body);
35952                    if !parts.status.is_success() {
35953                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35954                        let error = serde_json::from_str(&common::to_string(&bytes));
35955                        let response = common::to_response(parts, bytes.into());
35956
35957                        if let common::Retry::After(d) =
35958                            dlg.http_failure(&response, error.as_ref().ok())
35959                        {
35960                            sleep(d).await;
35961                            continue;
35962                        }
35963
35964                        dlg.finished(false);
35965
35966                        return Err(match error {
35967                            Ok(value) => common::Error::BadRequest(value),
35968                            _ => common::Error::Failure(response),
35969                        });
35970                    }
35971                    let response = {
35972                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35973                        let encoded = common::to_string(&bytes);
35974                        match serde_json::from_str(&encoded) {
35975                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35976                            Err(error) => {
35977                                dlg.response_json_decode_error(&encoded, &error);
35978                                return Err(common::Error::JsonDecodeError(
35979                                    encoded.to_string(),
35980                                    error,
35981                                ));
35982                            }
35983                        }
35984                    };
35985
35986                    dlg.finished(true);
35987                    return Ok(response);
35988                }
35989            }
35990        }
35991    }
35992
35993    ///
35994    /// Sets the *request* property to the given value.
35995    ///
35996    /// Even though the property as already been set when instantiating this call,
35997    /// we provide this method for API completeness.
35998    pub fn request(
35999        mut self,
36000        new_value: AccountTicket,
36001    ) -> ProvisioningCreateAccountTicketCall<'a, C> {
36002        self._request = new_value;
36003        self
36004    }
36005    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36006    /// while executing the actual API request.
36007    ///
36008    /// ````text
36009    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36010    /// ````
36011    ///
36012    /// Sets the *delegate* property to the given value.
36013    pub fn delegate(
36014        mut self,
36015        new_value: &'a mut dyn common::Delegate,
36016    ) -> ProvisioningCreateAccountTicketCall<'a, C> {
36017        self._delegate = Some(new_value);
36018        self
36019    }
36020
36021    /// Set any additional parameter of the query string used in the request.
36022    /// It should be used to set parameters which are not yet available through their own
36023    /// setters.
36024    ///
36025    /// Please note that this method must not be used to set any of the known parameters
36026    /// which have their own setter method. If done anyway, the request will fail.
36027    ///
36028    /// # Additional Parameters
36029    ///
36030    /// * *alt* (query-string) - Data format for the response.
36031    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36032    /// * *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.
36033    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36034    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36035    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
36036    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
36037    pub fn param<T>(mut self, name: T, value: T) -> ProvisioningCreateAccountTicketCall<'a, C>
36038    where
36039        T: AsRef<str>,
36040    {
36041        self._additional_params
36042            .insert(name.as_ref().to_string(), value.as_ref().to_string());
36043        self
36044    }
36045
36046    /// Identifies the authorization scope for the method you are building.
36047    ///
36048    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36049    /// [`Scope::Provision`].
36050    ///
36051    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36052    /// tokens for more than one scope.
36053    ///
36054    /// Usually there is more than one suitable scope to authorize an operation, some of which may
36055    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36056    /// sufficient, a read-write scope will do as well.
36057    pub fn add_scope<St>(mut self, scope: St) -> ProvisioningCreateAccountTicketCall<'a, C>
36058    where
36059        St: AsRef<str>,
36060    {
36061        self._scopes.insert(String::from(scope.as_ref()));
36062        self
36063    }
36064    /// Identifies the authorization scope(s) for the method you are building.
36065    ///
36066    /// See [`Self::add_scope()`] for details.
36067    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProvisioningCreateAccountTicketCall<'a, C>
36068    where
36069        I: IntoIterator<Item = St>,
36070        St: AsRef<str>,
36071    {
36072        self._scopes
36073            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36074        self
36075    }
36076
36077    /// Removes all scopes, and no default scope will be used either.
36078    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36079    /// for details).
36080    pub fn clear_scopes(mut self) -> ProvisioningCreateAccountTicketCall<'a, C> {
36081        self._scopes.clear();
36082        self
36083    }
36084}
36085
36086/// Provision account.
36087///
36088/// A builder for the *createAccountTree* method supported by a *provisioning* resource.
36089/// It is not used directly, but through a [`ProvisioningMethods`] instance.
36090///
36091/// # Example
36092///
36093/// Instantiate a resource method builder
36094///
36095/// ```test_harness,no_run
36096/// # extern crate hyper;
36097/// # extern crate hyper_rustls;
36098/// # extern crate google_analytics3 as analytics3;
36099/// use analytics3::api::AccountTreeRequest;
36100/// # async fn dox() {
36101/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36102///
36103/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36104/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
36105/// #     .with_native_roots()
36106/// #     .unwrap()
36107/// #     .https_only()
36108/// #     .enable_http2()
36109/// #     .build();
36110///
36111/// # let executor = hyper_util::rt::TokioExecutor::new();
36112/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
36113/// #     secret,
36114/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36115/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
36116/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
36117/// #     ),
36118/// # ).build().await.unwrap();
36119///
36120/// # let client = hyper_util::client::legacy::Client::builder(
36121/// #     hyper_util::rt::TokioExecutor::new()
36122/// # )
36123/// # .build(
36124/// #     hyper_rustls::HttpsConnectorBuilder::new()
36125/// #         .with_native_roots()
36126/// #         .unwrap()
36127/// #         .https_or_http()
36128/// #         .enable_http2()
36129/// #         .build()
36130/// # );
36131/// # let mut hub = Analytics::new(client, auth);
36132/// // As the method needs a request, you would usually fill it with the desired information
36133/// // into the respective structure. Some of the parts shown here might not be applicable !
36134/// // Values shown here are possibly random and not representative !
36135/// let mut req = AccountTreeRequest::default();
36136///
36137/// // You can configure optional parameters by calling the respective setters at will, and
36138/// // execute the final call using `doit()`.
36139/// // Values shown here are possibly random and not representative !
36140/// let result = hub.provisioning().create_account_tree(req)
36141///              .doit().await;
36142/// # }
36143/// ```
36144pub struct ProvisioningCreateAccountTreeCall<'a, C>
36145where
36146    C: 'a,
36147{
36148    hub: &'a Analytics<C>,
36149    _request: AccountTreeRequest,
36150    _delegate: Option<&'a mut dyn common::Delegate>,
36151    _additional_params: HashMap<String, String>,
36152    _scopes: BTreeSet<String>,
36153}
36154
36155impl<'a, C> common::CallBuilder for ProvisioningCreateAccountTreeCall<'a, C> {}
36156
36157impl<'a, C> ProvisioningCreateAccountTreeCall<'a, C>
36158where
36159    C: common::Connector,
36160{
36161    /// Perform the operation you have build so far.
36162    pub async fn doit(mut self) -> common::Result<(common::Response, AccountTreeResponse)> {
36163        use std::borrow::Cow;
36164        use std::io::{Read, Seek};
36165
36166        use common::{url::Params, ToParts};
36167        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36168
36169        let mut dd = common::DefaultDelegate;
36170        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36171        dlg.begin(common::MethodInfo {
36172            id: "analytics.provisioning.createAccountTree",
36173            http_method: hyper::Method::POST,
36174        });
36175
36176        for &field in ["alt"].iter() {
36177            if self._additional_params.contains_key(field) {
36178                dlg.finished(false);
36179                return Err(common::Error::FieldClash(field));
36180            }
36181        }
36182
36183        let mut params = Params::with_capacity(3 + self._additional_params.len());
36184
36185        params.extend(self._additional_params.iter());
36186
36187        params.push("alt", "json");
36188        let mut url = self.hub._base_url.clone() + "provisioning/createAccountTree";
36189        if self._scopes.is_empty() {
36190            self._scopes.insert(Scope::Provision.as_ref().to_string());
36191        }
36192
36193        let url = params.parse_with_url(&url);
36194
36195        let mut json_mime_type = mime::APPLICATION_JSON;
36196        let mut request_value_reader = {
36197            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
36198            common::remove_json_null_values(&mut value);
36199            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
36200            serde_json::to_writer(&mut dst, &value).unwrap();
36201            dst
36202        };
36203        let request_size = request_value_reader
36204            .seek(std::io::SeekFrom::End(0))
36205            .unwrap();
36206        request_value_reader
36207            .seek(std::io::SeekFrom::Start(0))
36208            .unwrap();
36209
36210        loop {
36211            let token = match self
36212                .hub
36213                .auth
36214                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36215                .await
36216            {
36217                Ok(token) => token,
36218                Err(e) => match dlg.token(e) {
36219                    Ok(token) => token,
36220                    Err(e) => {
36221                        dlg.finished(false);
36222                        return Err(common::Error::MissingToken(e));
36223                    }
36224                },
36225            };
36226            request_value_reader
36227                .seek(std::io::SeekFrom::Start(0))
36228                .unwrap();
36229            let mut req_result = {
36230                let client = &self.hub.client;
36231                dlg.pre_request();
36232                let mut req_builder = hyper::Request::builder()
36233                    .method(hyper::Method::POST)
36234                    .uri(url.as_str())
36235                    .header(USER_AGENT, self.hub._user_agent.clone());
36236
36237                if let Some(token) = token.as_ref() {
36238                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36239                }
36240
36241                let request = req_builder
36242                    .header(CONTENT_TYPE, json_mime_type.to_string())
36243                    .header(CONTENT_LENGTH, request_size as u64)
36244                    .body(common::to_body(
36245                        request_value_reader.get_ref().clone().into(),
36246                    ));
36247
36248                client.request(request.unwrap()).await
36249            };
36250
36251            match req_result {
36252                Err(err) => {
36253                    if let common::Retry::After(d) = dlg.http_error(&err) {
36254                        sleep(d).await;
36255                        continue;
36256                    }
36257                    dlg.finished(false);
36258                    return Err(common::Error::HttpError(err));
36259                }
36260                Ok(res) => {
36261                    let (mut parts, body) = res.into_parts();
36262                    let mut body = common::Body::new(body);
36263                    if !parts.status.is_success() {
36264                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36265                        let error = serde_json::from_str(&common::to_string(&bytes));
36266                        let response = common::to_response(parts, bytes.into());
36267
36268                        if let common::Retry::After(d) =
36269                            dlg.http_failure(&response, error.as_ref().ok())
36270                        {
36271                            sleep(d).await;
36272                            continue;
36273                        }
36274
36275                        dlg.finished(false);
36276
36277                        return Err(match error {
36278                            Ok(value) => common::Error::BadRequest(value),
36279                            _ => common::Error::Failure(response),
36280                        });
36281                    }
36282                    let response = {
36283                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36284                        let encoded = common::to_string(&bytes);
36285                        match serde_json::from_str(&encoded) {
36286                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36287                            Err(error) => {
36288                                dlg.response_json_decode_error(&encoded, &error);
36289                                return Err(common::Error::JsonDecodeError(
36290                                    encoded.to_string(),
36291                                    error,
36292                                ));
36293                            }
36294                        }
36295                    };
36296
36297                    dlg.finished(true);
36298                    return Ok(response);
36299                }
36300            }
36301        }
36302    }
36303
36304    ///
36305    /// Sets the *request* property to the given value.
36306    ///
36307    /// Even though the property as already been set when instantiating this call,
36308    /// we provide this method for API completeness.
36309    pub fn request(
36310        mut self,
36311        new_value: AccountTreeRequest,
36312    ) -> ProvisioningCreateAccountTreeCall<'a, C> {
36313        self._request = new_value;
36314        self
36315    }
36316    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36317    /// while executing the actual API request.
36318    ///
36319    /// ````text
36320    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36321    /// ````
36322    ///
36323    /// Sets the *delegate* property to the given value.
36324    pub fn delegate(
36325        mut self,
36326        new_value: &'a mut dyn common::Delegate,
36327    ) -> ProvisioningCreateAccountTreeCall<'a, C> {
36328        self._delegate = Some(new_value);
36329        self
36330    }
36331
36332    /// Set any additional parameter of the query string used in the request.
36333    /// It should be used to set parameters which are not yet available through their own
36334    /// setters.
36335    ///
36336    /// Please note that this method must not be used to set any of the known parameters
36337    /// which have their own setter method. If done anyway, the request will fail.
36338    ///
36339    /// # Additional Parameters
36340    ///
36341    /// * *alt* (query-string) - Data format for the response.
36342    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36343    /// * *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.
36344    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36345    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36346    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
36347    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
36348    pub fn param<T>(mut self, name: T, value: T) -> ProvisioningCreateAccountTreeCall<'a, C>
36349    where
36350        T: AsRef<str>,
36351    {
36352        self._additional_params
36353            .insert(name.as_ref().to_string(), value.as_ref().to_string());
36354        self
36355    }
36356
36357    /// Identifies the authorization scope for the method you are building.
36358    ///
36359    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36360    /// [`Scope::Provision`].
36361    ///
36362    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36363    /// tokens for more than one scope.
36364    ///
36365    /// Usually there is more than one suitable scope to authorize an operation, some of which may
36366    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36367    /// sufficient, a read-write scope will do as well.
36368    pub fn add_scope<St>(mut self, scope: St) -> ProvisioningCreateAccountTreeCall<'a, C>
36369    where
36370        St: AsRef<str>,
36371    {
36372        self._scopes.insert(String::from(scope.as_ref()));
36373        self
36374    }
36375    /// Identifies the authorization scope(s) for the method you are building.
36376    ///
36377    /// See [`Self::add_scope()`] for details.
36378    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProvisioningCreateAccountTreeCall<'a, C>
36379    where
36380        I: IntoIterator<Item = St>,
36381        St: AsRef<str>,
36382    {
36383        self._scopes
36384            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36385        self
36386    }
36387
36388    /// Removes all scopes, and no default scope will be used either.
36389    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36390    /// for details).
36391    pub fn clear_scopes(mut self) -> ProvisioningCreateAccountTreeCall<'a, C> {
36392        self._scopes.clear();
36393        self
36394    }
36395}
36396
36397/// Insert or update a user deletion requests.
36398///
36399/// A builder for the *userDeletionRequest.upsert* method supported by a *userDeletion* resource.
36400/// It is not used directly, but through a [`UserDeletionMethods`] instance.
36401///
36402/// # Example
36403///
36404/// Instantiate a resource method builder
36405///
36406/// ```test_harness,no_run
36407/// # extern crate hyper;
36408/// # extern crate hyper_rustls;
36409/// # extern crate google_analytics3 as analytics3;
36410/// use analytics3::api::UserDeletionRequest;
36411/// # async fn dox() {
36412/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36413///
36414/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36415/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
36416/// #     .with_native_roots()
36417/// #     .unwrap()
36418/// #     .https_only()
36419/// #     .enable_http2()
36420/// #     .build();
36421///
36422/// # let executor = hyper_util::rt::TokioExecutor::new();
36423/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
36424/// #     secret,
36425/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36426/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
36427/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
36428/// #     ),
36429/// # ).build().await.unwrap();
36430///
36431/// # let client = hyper_util::client::legacy::Client::builder(
36432/// #     hyper_util::rt::TokioExecutor::new()
36433/// # )
36434/// # .build(
36435/// #     hyper_rustls::HttpsConnectorBuilder::new()
36436/// #         .with_native_roots()
36437/// #         .unwrap()
36438/// #         .https_or_http()
36439/// #         .enable_http2()
36440/// #         .build()
36441/// # );
36442/// # let mut hub = Analytics::new(client, auth);
36443/// // As the method needs a request, you would usually fill it with the desired information
36444/// // into the respective structure. Some of the parts shown here might not be applicable !
36445/// // Values shown here are possibly random and not representative !
36446/// let mut req = UserDeletionRequest::default();
36447///
36448/// // You can configure optional parameters by calling the respective setters at will, and
36449/// // execute the final call using `doit()`.
36450/// // Values shown here are possibly random and not representative !
36451/// let result = hub.user_deletion().user_deletion_request_upsert(req)
36452///              .doit().await;
36453/// # }
36454/// ```
36455pub struct UserDeletionUserDeletionRequestUpsertCall<'a, C>
36456where
36457    C: 'a,
36458{
36459    hub: &'a Analytics<C>,
36460    _request: UserDeletionRequest,
36461    _delegate: Option<&'a mut dyn common::Delegate>,
36462    _additional_params: HashMap<String, String>,
36463    _scopes: BTreeSet<String>,
36464}
36465
36466impl<'a, C> common::CallBuilder for UserDeletionUserDeletionRequestUpsertCall<'a, C> {}
36467
36468impl<'a, C> UserDeletionUserDeletionRequestUpsertCall<'a, C>
36469where
36470    C: common::Connector,
36471{
36472    /// Perform the operation you have build so far.
36473    pub async fn doit(mut self) -> common::Result<(common::Response, UserDeletionRequest)> {
36474        use std::borrow::Cow;
36475        use std::io::{Read, Seek};
36476
36477        use common::{url::Params, ToParts};
36478        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36479
36480        let mut dd = common::DefaultDelegate;
36481        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36482        dlg.begin(common::MethodInfo {
36483            id: "analytics.userDeletion.userDeletionRequest.upsert",
36484            http_method: hyper::Method::POST,
36485        });
36486
36487        for &field in ["alt"].iter() {
36488            if self._additional_params.contains_key(field) {
36489                dlg.finished(false);
36490                return Err(common::Error::FieldClash(field));
36491            }
36492        }
36493
36494        let mut params = Params::with_capacity(3 + self._additional_params.len());
36495
36496        params.extend(self._additional_params.iter());
36497
36498        params.push("alt", "json");
36499        let mut url = self.hub._base_url.clone() + "userDeletion/userDeletionRequests:upsert";
36500        if self._scopes.is_empty() {
36501            self._scopes
36502                .insert(Scope::UserDeletion.as_ref().to_string());
36503        }
36504
36505        let url = params.parse_with_url(&url);
36506
36507        let mut json_mime_type = mime::APPLICATION_JSON;
36508        let mut request_value_reader = {
36509            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
36510            common::remove_json_null_values(&mut value);
36511            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
36512            serde_json::to_writer(&mut dst, &value).unwrap();
36513            dst
36514        };
36515        let request_size = request_value_reader
36516            .seek(std::io::SeekFrom::End(0))
36517            .unwrap();
36518        request_value_reader
36519            .seek(std::io::SeekFrom::Start(0))
36520            .unwrap();
36521
36522        loop {
36523            let token = match self
36524                .hub
36525                .auth
36526                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36527                .await
36528            {
36529                Ok(token) => token,
36530                Err(e) => match dlg.token(e) {
36531                    Ok(token) => token,
36532                    Err(e) => {
36533                        dlg.finished(false);
36534                        return Err(common::Error::MissingToken(e));
36535                    }
36536                },
36537            };
36538            request_value_reader
36539                .seek(std::io::SeekFrom::Start(0))
36540                .unwrap();
36541            let mut req_result = {
36542                let client = &self.hub.client;
36543                dlg.pre_request();
36544                let mut req_builder = hyper::Request::builder()
36545                    .method(hyper::Method::POST)
36546                    .uri(url.as_str())
36547                    .header(USER_AGENT, self.hub._user_agent.clone());
36548
36549                if let Some(token) = token.as_ref() {
36550                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36551                }
36552
36553                let request = req_builder
36554                    .header(CONTENT_TYPE, json_mime_type.to_string())
36555                    .header(CONTENT_LENGTH, request_size as u64)
36556                    .body(common::to_body(
36557                        request_value_reader.get_ref().clone().into(),
36558                    ));
36559
36560                client.request(request.unwrap()).await
36561            };
36562
36563            match req_result {
36564                Err(err) => {
36565                    if let common::Retry::After(d) = dlg.http_error(&err) {
36566                        sleep(d).await;
36567                        continue;
36568                    }
36569                    dlg.finished(false);
36570                    return Err(common::Error::HttpError(err));
36571                }
36572                Ok(res) => {
36573                    let (mut parts, body) = res.into_parts();
36574                    let mut body = common::Body::new(body);
36575                    if !parts.status.is_success() {
36576                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36577                        let error = serde_json::from_str(&common::to_string(&bytes));
36578                        let response = common::to_response(parts, bytes.into());
36579
36580                        if let common::Retry::After(d) =
36581                            dlg.http_failure(&response, error.as_ref().ok())
36582                        {
36583                            sleep(d).await;
36584                            continue;
36585                        }
36586
36587                        dlg.finished(false);
36588
36589                        return Err(match error {
36590                            Ok(value) => common::Error::BadRequest(value),
36591                            _ => common::Error::Failure(response),
36592                        });
36593                    }
36594                    let response = {
36595                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36596                        let encoded = common::to_string(&bytes);
36597                        match serde_json::from_str(&encoded) {
36598                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36599                            Err(error) => {
36600                                dlg.response_json_decode_error(&encoded, &error);
36601                                return Err(common::Error::JsonDecodeError(
36602                                    encoded.to_string(),
36603                                    error,
36604                                ));
36605                            }
36606                        }
36607                    };
36608
36609                    dlg.finished(true);
36610                    return Ok(response);
36611                }
36612            }
36613        }
36614    }
36615
36616    ///
36617    /// Sets the *request* property to the given value.
36618    ///
36619    /// Even though the property as already been set when instantiating this call,
36620    /// we provide this method for API completeness.
36621    pub fn request(
36622        mut self,
36623        new_value: UserDeletionRequest,
36624    ) -> UserDeletionUserDeletionRequestUpsertCall<'a, C> {
36625        self._request = new_value;
36626        self
36627    }
36628    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36629    /// while executing the actual API request.
36630    ///
36631    /// ````text
36632    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36633    /// ````
36634    ///
36635    /// Sets the *delegate* property to the given value.
36636    pub fn delegate(
36637        mut self,
36638        new_value: &'a mut dyn common::Delegate,
36639    ) -> UserDeletionUserDeletionRequestUpsertCall<'a, C> {
36640        self._delegate = Some(new_value);
36641        self
36642    }
36643
36644    /// Set any additional parameter of the query string used in the request.
36645    /// It should be used to set parameters which are not yet available through their own
36646    /// setters.
36647    ///
36648    /// Please note that this method must not be used to set any of the known parameters
36649    /// which have their own setter method. If done anyway, the request will fail.
36650    ///
36651    /// # Additional Parameters
36652    ///
36653    /// * *alt* (query-string) - Data format for the response.
36654    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36655    /// * *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.
36656    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36657    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36658    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
36659    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
36660    pub fn param<T>(mut self, name: T, value: T) -> UserDeletionUserDeletionRequestUpsertCall<'a, C>
36661    where
36662        T: AsRef<str>,
36663    {
36664        self._additional_params
36665            .insert(name.as_ref().to_string(), value.as_ref().to_string());
36666        self
36667    }
36668
36669    /// Identifies the authorization scope for the method you are building.
36670    ///
36671    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36672    /// [`Scope::UserDeletion`].
36673    ///
36674    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36675    /// tokens for more than one scope.
36676    ///
36677    /// Usually there is more than one suitable scope to authorize an operation, some of which may
36678    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36679    /// sufficient, a read-write scope will do as well.
36680    pub fn add_scope<St>(mut self, scope: St) -> UserDeletionUserDeletionRequestUpsertCall<'a, C>
36681    where
36682        St: AsRef<str>,
36683    {
36684        self._scopes.insert(String::from(scope.as_ref()));
36685        self
36686    }
36687    /// Identifies the authorization scope(s) for the method you are building.
36688    ///
36689    /// See [`Self::add_scope()`] for details.
36690    pub fn add_scopes<I, St>(
36691        mut self,
36692        scopes: I,
36693    ) -> UserDeletionUserDeletionRequestUpsertCall<'a, C>
36694    where
36695        I: IntoIterator<Item = St>,
36696        St: AsRef<str>,
36697    {
36698        self._scopes
36699            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36700        self
36701    }
36702
36703    /// Removes all scopes, and no default scope will be used either.
36704    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36705    /// for details).
36706    pub fn clear_scopes(mut self) -> UserDeletionUserDeletionRequestUpsertCall<'a, C> {
36707        self._scopes.clear();
36708        self
36709    }
36710}